win32-process 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.5.3 - 29-Jul-2007
2
+ * Added a Rakefile with tasks for installation and testing.
3
+ * Removed the install.rb file (now handled by the Rakefile).
4
+ * Updated the README and MANIFEST files.
5
+
1
6
  == 0.5.2 - 22-Jan-2007
2
7
  * The startup_info parameter for the Process.create method now accepts
3
8
  'stdin', 'stdout', and 'stderr' as valid parameters, which you can pass
@@ -101,4 +106,4 @@
101
106
  * Fixed up tc_process.rb a bit.
102
107
 
103
108
  == 0.1.0 - 19-Feb-2004
104
- * Initial release
109
+ * Initial release
data/MANIFEST CHANGED
@@ -1,14 +1,11 @@
1
- CHANGES
2
- README
3
- MANIFEST
4
- install.rb
5
- win32-process.gemspec
6
-
7
- examples/test_create.rb
8
- examples/test_fork_wait.rb
9
- examples/test_fork_waitpid.rb
10
- examples/test_kill.rb
11
-
12
- lib/win32/process.rb
13
-
14
- test/tc_process.rb
1
+ * CHANGES
2
+ * README
3
+ * MANIFEST
4
+ * Rakefile
5
+ * win32-process.gemspec
6
+ * examples/test_create.rb
7
+ * examples/test_fork_wait.rb
8
+ * examples/test_fork_waitpid.rb
9
+ * examples/test_kill.rb
10
+ * lib/win32/process.rb
11
+ * test/tc_process.rb
data/README CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  = Prerequisites
7
7
  Ruby 1.8.2 or later.
8
- The 'windows-pr' package 0.5.2 or later.
9
- The 'sys-proctable' package 0.7.0 or later (test suite only).
8
+ The 'windows-pr' library, 0.5.2 or later.
9
+ The 'sys-proctable' library, 0.7.0 or later (test suite only).
10
10
 
11
11
  = Supported Platforms
12
12
  This code is supported on Windows NT, Windows 2000 or Windows XP Pro only.
@@ -14,12 +14,8 @@
14
14
  platform.
15
15
 
16
16
  = Installation Instructions
17
- == Manual Installation
18
- ruby test/tc_process.rb (optional)
19
- ruby install.rb
20
- == Gem Installation
21
- ruby win32-process.gemspec
22
- win32-process-X.Y.Z-mswin32.gem
17
+ rake test (optional)
18
+ rake install (non-gem) or rake install_gem (gem)
23
19
 
24
20
  = Synopsis
25
21
  require 'win32/process'
@@ -89,6 +85,9 @@
89
85
  == Notes
90
86
  It is unlikely you will be able to kill system processes with this module.
91
87
  It's probably better that you don't.
88
+
89
+ You will see some warnings about redefined methods if you run your code
90
+ with warnings enabled. Yup, we redefined some methods. :)
92
91
 
93
92
  == Known Bugs
94
93
  None known (though please see the +Details+ section for quirks). Any
@@ -105,7 +104,7 @@
105
104
  Ruby's
106
105
 
107
106
  == Copyright
108
- (C) 2003-2006 Daniel J. Berger
107
+ (C) 2003-2007 Daniel J. Berger
109
108
  All Rights Reserved
110
109
 
111
110
  == Warranty
@@ -0,0 +1,24 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rbconfig'
4
+ include Config
5
+
6
+ desc 'Install the win32-process package (non-gem)'
7
+ task :install do
8
+ install_dir = File.join(CONFIG["sitelibdir"], 'win32')
9
+ Dir.mkdir(installdir) unless File.exists?(install_dir)
10
+ cp 'lib/win32/process.rb', install_dir, :verbose => true
11
+ end
12
+
13
+ task :install_gem do
14
+ ruby 'win32-process.gemspec'
15
+ file = Dir["*.gem"].first
16
+ sh "gem install #{file}"
17
+ end
18
+
19
+ Rake::TestTask.new do |t|
20
+ t.libs << 'test'
21
+ t.verbose = true
22
+ t.warning = true
23
+ t.test_files = FileList['test/tc_process.rb']
24
+ end
@@ -9,7 +9,7 @@ require 'windows/window'
9
9
  class ProcessError < RuntimeError; end
10
10
 
11
11
  module Process
12
- WIN32_PROCESS_VERSION = '0.5.2'
12
+ WIN32_PROCESS_VERSION = '0.5.3'
13
13
 
14
14
  include Windows::Process
15
15
  include Windows::Error
@@ -8,12 +8,9 @@
8
8
  # I haven't added a lot of test cases for fork/wait because it's difficult
9
9
  # to run such tests without causing havoc with TestUnit itself. Ideas
10
10
  # welcome.
11
+ #
12
+ # You should run this test case via the 'rake test' task.
11
13
  ###############################################################################
12
- Dir.chdir('..') if File.basename(Dir.pwd) == 'test'
13
- $LOAD_PATH.unshift Dir.pwd
14
- $LOAD_PATH.unshift Dir.pwd + '/lib'
15
- Dir.chdir('test') rescue nil
16
-
17
14
  require 'test/unit'
18
15
  require 'win32/process'
19
16
 
@@ -46,7 +43,7 @@ class TC_Win32Process < Test::Unit::TestCase
46
43
  end
47
44
 
48
45
  def test_version
49
- assert_equal('0.5.1', Process::WIN32_PROCESS_VERSION)
46
+ assert_equal('0.5.3', Process::WIN32_PROCESS_VERSION)
50
47
  end
51
48
 
52
49
  def test_kill
@@ -0,0 +1,134 @@
1
+ ###############################################################################
2
+ # tc_process.rb
3
+ #
4
+ # Test suite for the win32-process package. This test suite will start
5
+ # at least two instances of Notepad on your system, which will then
6
+ # be killed. Requires the sys-proctable package.
7
+ #
8
+ # I haven't added a lot of test cases for fork/wait because it's difficult
9
+ # to run such tests without causing havoc with TestUnit itself. Ideas
10
+ # welcome.
11
+ ###############################################################################
12
+ Dir.chdir('..') if File.basename(Dir.pwd) == 'test'
13
+ $LOAD_PATH.unshift Dir.pwd
14
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
15
+ Dir.chdir('test') rescue nil
16
+
17
+ require 'test/unit'
18
+ require 'win32/process'
19
+
20
+ begin
21
+ require 'sys/proctable'
22
+ rescue LoadError => e
23
+ site = 'http://www.rubyforge.org/projects/sysutils'
24
+ STDERR.puts "Stopping!"
25
+ STDERR.puts "The sys/proctable module is required to run this test suite."
26
+ STDERR.puts "You can find it at #{site} or the RAA"
27
+ exit!
28
+ end
29
+
30
+ include Sys
31
+
32
+ IO.popen("notepad")
33
+ IO.popen("notepad")
34
+ sleep 1
35
+
36
+ $pids = []
37
+ ProcTable.ps{ |s|
38
+ next unless s.comm =~ /notepad/i
39
+ $pids.push(s.pid)
40
+ }
41
+
42
+ class TC_Win32Process < Test::Unit::TestCase
43
+ def setup
44
+ @pids = $pids
45
+ @pid = nil
46
+ end
47
+
48
+ def test_version
49
+ assert_equal('0.5.3', Process::WIN32_PROCESS_VERSION)
50
+ end
51
+
52
+ def test_kill
53
+ assert_respond_to(Process, :kill)
54
+ end
55
+
56
+ def test_kill_expected_errors
57
+ assert_raises(ArgumentError){ Process.kill }
58
+ assert_raises(ProcessError){ Process.kill('SIGBOGUS') }
59
+ assert_raises(ProcessError){ Process.kill(0,9999999) }
60
+ end
61
+
62
+ def test_kill_signal_0
63
+ pid = @pids.first
64
+ assert_nothing_raised{ Process.kill(0, pid) }
65
+ end
66
+
67
+ def test_kill_signal_1
68
+ pid = @pids.shift
69
+ assert_nothing_raised{ Process.kill(1, pid) }
70
+ end
71
+
72
+ def test_kill_signal_9
73
+ pid = @pids.pop
74
+ msg = "Could not find pid #{pid}"
75
+ assert_nothing_raised(msg){ Process.kill(9,pid) }
76
+ end
77
+
78
+ def test_fork
79
+ assert_respond_to(Process, :fork)
80
+ end
81
+
82
+ def test_create
83
+ assert_respond_to(Process, :create)
84
+ assert_nothing_raised{
85
+ @pid = Process.create(
86
+ :app_name => "notepad.exe",
87
+ :creation_flags => Process::DETACHED_PROCESS,
88
+ :process_inherit => false,
89
+ :thread_inherit => true,
90
+ :cwd => "C:\\"
91
+ ).process_id
92
+ }
93
+ assert_nothing_raised{ Process.kill(1, @pid) }
94
+ end
95
+
96
+ def test_create_expected_errors
97
+ assert_raises(TypeError){ Process.create("bogusapp.exe") }
98
+ assert_raises(ProcessError){ Process.create(:app_name => "bogusapp.exe") }
99
+ end
100
+
101
+ def test_wait
102
+ assert_respond_to(Process, :wait)
103
+ end
104
+
105
+ def test_wait2
106
+ assert_respond_to(Process, :wait2)
107
+ end
108
+
109
+ def test_waitpid
110
+ assert_respond_to(Process, :waitpid)
111
+ end
112
+
113
+ def test_waitpid2
114
+ assert_respond_to(Process, :waitpid2)
115
+ end
116
+
117
+ def test_creation_constants
118
+ assert_not_nil(Process::CREATE_DEFAULT_ERROR_MODE)
119
+ assert_not_nil(Process::CREATE_NEW_CONSOLE)
120
+ assert_not_nil(Process::CREATE_NEW_PROCESS_GROUP)
121
+ assert_not_nil(Process::CREATE_NO_WINDOW)
122
+ assert_not_nil(Process::CREATE_SEPARATE_WOW_VDM)
123
+ assert_not_nil(Process::CREATE_SHARED_WOW_VDM)
124
+ assert_not_nil(Process::CREATE_SUSPENDED)
125
+ assert_not_nil(Process::CREATE_UNICODE_ENVIRONMENT)
126
+ assert_not_nil(Process::DEBUG_ONLY_THIS_PROCESS)
127
+ assert_not_nil(Process::DEBUG_PROCESS)
128
+ assert_not_nil(Process::DETACHED_PROCESS)
129
+ end
130
+
131
+ def teardown
132
+ @pids = []
133
+ end
134
+ end
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "win32-process"
5
- gem.version = "0.5.2"
5
+ gem.version = "0.5.3"
6
6
  gem.author = "Daniel J. Berger"
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |gem|
14
14
  gem.files = Dir["lib/win32/*.rb"] + Dir["test/*"] + Dir["[A-Z]*"]
15
15
  gem.files.reject! { |fn| fn.include? "CVS" }
16
16
  gem.require_path = "lib"
17
- gem.extra_rdoc_files = ["README", "CHANGES"]
17
+ gem.extra_rdoc_files = ["README", "CHANGES", "MANIFEST"]
18
18
  gem.add_dependency("windows-pr", ">= 0.5.2")
19
19
  end
20
20
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.8
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: win32-process
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.2
7
- date: 2007-01-22 00:00:00 -07:00
6
+ version: 0.5.3
7
+ date: 2007-07-29 00:00:00 -06:00
8
8
  summary: Adds fork, wait, wait2, waitpid, waitpid2 and a special kill method
9
9
  require_paths:
10
10
  - lib
@@ -32,12 +32,13 @@ files:
32
32
  - lib/win32/process.rb
33
33
  - test/CVS
34
34
  - test/tc_process.rb
35
+ - test/tc_process.rb~
35
36
  - CHANGES
36
37
  - CVS
37
38
  - examples
38
- - install.rb
39
39
  - lib
40
40
  - MANIFEST
41
+ - Rakefile
41
42
  - README
42
43
  - test
43
44
  - win32-process.gemspec
@@ -48,6 +49,7 @@ rdoc_options: []
48
49
  extra_rdoc_files:
49
50
  - README
50
51
  - CHANGES
52
+ - MANIFEST
51
53
  executables: []
52
54
 
53
55
  extensions: []
data/install.rb DELETED
@@ -1,11 +0,0 @@
1
- # For those who don't like gems...
2
- require 'rbconfig'
3
- require 'ftools'
4
- include Config
5
-
6
- sitelibdir = CONFIG['sitelibdir']
7
- installdir = sitelibdir + '/win32'
8
- file = 'lib\win32\process.rb'
9
-
10
- Dir.mkdir(installdir) unless File.exists?(installdir)
11
- File.copy(file, installdir, true)