childprocess 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'tmpdir'
3
4
 
4
5
  begin
5
6
  require 'jeweler'
@@ -46,3 +47,20 @@ rescue LoadError
46
47
  abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
47
48
  end
48
49
  end
50
+
51
+ task :clean do
52
+ rm_rf "pkg"
53
+ rm_rf "childprocess.jar"
54
+ end
55
+
56
+ desc 'Create jar to bundle in selenium-webdriver'
57
+ task :jar => [:clean, :build] do
58
+ tmpdir = Dir.mktmpdir("childprocess-jar")
59
+ gem_to_package = Dir['pkg/*.gem'].first
60
+ gem_name = File.basename(gem_to_package, ".gem")
61
+ p :gem_to_package => gem_to_package, :gem_name => gem_name
62
+
63
+ sh "gem install -i #{tmpdir} #{gem_to_package} --ignore-dependencies --no-rdoc --no-ri"
64
+ sh "jar cf childprocess.jar -C #{tmpdir}/gems/#{gem_name}/lib ."
65
+ sh "jar tf childprocess.jar"
66
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{childprocess}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jari Bakken"]
@@ -42,7 +42,8 @@ Gem::Specification.new do |s|
42
42
  "lib/childprocess/windows/structs.rb",
43
43
  "spec/childprocess_spec.rb",
44
44
  "spec/spec.opts",
45
- "spec/spec_helper.rb"
45
+ "spec/spec_helper.rb",
46
+ "spec/unix_process_spec.rb"
46
47
  ]
47
48
  s.homepage = %q{http://github.com/jarib/childprocess}
48
49
  s.rdoc_options = ["--charset=UTF-8"]
@@ -51,7 +52,8 @@ Gem::Specification.new do |s|
51
52
  s.summary = %q{Cross-platform ruby library for managing child processes.}
52
53
  s.test_files = [
53
54
  "spec/childprocess_spec.rb",
54
- "spec/spec_helper.rb"
55
+ "spec/spec_helper.rb",
56
+ "spec/unix_process_spec.rb"
55
57
  ]
56
58
 
57
59
  if s.respond_to? :specification_version then
@@ -27,6 +27,8 @@ module ChildProcess
27
27
  :ironruby
28
28
  elsif RUBY_PLATFORM =~ /mswin|msys|mingw32/
29
29
  :windows
30
+ else
31
+ :unix
30
32
  end
31
33
  end
32
34
 
@@ -14,8 +14,9 @@ module ChildProcess
14
14
 
15
15
  send_kill
16
16
  wait
17
- rescue Errno::ECHILD
18
- # that'll do
17
+ rescue Errno::ECHILD, Errno::ESRCH
18
+ # handle rase condition where process dies between timeout
19
+ # and send_kill
19
20
  true
20
21
  end
21
22
 
@@ -57,4 +57,5 @@ describe ChildProcess do
57
57
  end
58
58
  end
59
59
 
60
+ it_should_behave_like "unix process" if ChildProcess.platform == :unix
60
61
  end
@@ -88,3 +88,5 @@ Spec::Runner.configure do |config|
88
88
  @process && @process.alive? && @process.stop
89
89
  }
90
90
  end
91
+
92
+ require "unix_process_spec"
@@ -0,0 +1,29 @@
1
+ shared_examples_for "unix process" do
2
+ it "handles ECHILD race condition where process dies between timeout and KILL" do
3
+ process = sleeping_ruby
4
+
5
+ process.stub!(:fork).and_return('fakepid')
6
+ process.stub!(:send_term)
7
+ process.stub!(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
8
+ process.stub!(:send_kill).and_raise(Errno::ECHILD)
9
+
10
+ process.start
11
+ lambda { process.stop }.should_not raise_error
12
+
13
+ process.stub(:alive?).and_return(false)
14
+ end
15
+
16
+ it "handles ESRCH race condition where process dies between timeout and KILL" do
17
+ process = sleeping_ruby
18
+
19
+ process.stub!(:fork).and_return('fakepid')
20
+ process.stub!(:send_term)
21
+ process.stub!(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
22
+ process.stub!(:send_kill).and_raise(Errno::ESRCH)
23
+
24
+ process.start
25
+ lambda { process.stop }.should_not raise_error
26
+
27
+ process.stub(:alive?).and_return(false)
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: childprocess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -78,6 +78,7 @@ files:
78
78
  - spec/childprocess_spec.rb
79
79
  - spec/spec.opts
80
80
  - spec/spec_helper.rb
81
+ - spec/unix_process_spec.rb
81
82
  has_rdoc: true
82
83
  homepage: http://github.com/jarib/childprocess
83
84
  licenses: []
@@ -109,3 +110,4 @@ summary: Cross-platform ruby library for managing child processes.
109
110
  test_files:
110
111
  - spec/childprocess_spec.rb
111
112
  - spec/spec_helper.rb
113
+ - spec/unix_process_spec.rb