childprocess 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.document +6 -6
- data/.gitignore +28 -28
- data/.rspec +1 -1
- data/.travis.yml +51 -52
- data/CHANGELOG.md +61 -56
- data/Gemfile +18 -18
- data/LICENSE +20 -20
- data/README.md +212 -200
- data/Rakefile +61 -61
- data/appveyor.yml +54 -60
- data/childprocess.gemspec +30 -29
- data/ext/mkrf_conf.rb +24 -24
- data/lib/childprocess.rb +210 -210
- data/lib/childprocess/abstract_io.rb +36 -36
- data/lib/childprocess/abstract_process.rb +192 -192
- data/lib/childprocess/errors.rb +37 -37
- data/lib/childprocess/jruby.rb +56 -56
- data/lib/childprocess/jruby/io.rb +16 -16
- data/lib/childprocess/jruby/process.rb +184 -184
- data/lib/childprocess/jruby/pump.rb +53 -53
- data/lib/childprocess/tools/generator.rb +145 -145
- data/lib/childprocess/unix.rb +9 -9
- data/lib/childprocess/unix/fork_exec_process.rb +70 -70
- data/lib/childprocess/unix/io.rb +21 -21
- data/lib/childprocess/unix/lib.rb +186 -186
- data/lib/childprocess/unix/platform/i386-linux.rb +12 -12
- data/lib/childprocess/unix/platform/i386-solaris.rb +11 -11
- data/lib/childprocess/unix/platform/x86_64-linux.rb +12 -12
- data/lib/childprocess/unix/platform/x86_64-macosx.rb +11 -11
- data/lib/childprocess/unix/posix_spawn_process.rb +134 -134
- data/lib/childprocess/unix/process.rb +89 -89
- data/lib/childprocess/version.rb +3 -3
- data/lib/childprocess/windows.rb +33 -33
- data/lib/childprocess/windows/handle.rb +91 -91
- data/lib/childprocess/windows/io.rb +25 -25
- data/lib/childprocess/windows/lib.rb +416 -416
- data/lib/childprocess/windows/process.rb +130 -130
- data/lib/childprocess/windows/process_builder.rb +178 -178
- data/lib/childprocess/windows/structs.rb +148 -148
- data/spec/abstract_io_spec.rb +12 -12
- data/spec/childprocess_spec.rb +447 -447
- data/spec/io_spec.rb +228 -228
- data/spec/jruby_spec.rb +24 -24
- data/spec/pid_behavior.rb +12 -12
- data/spec/platform_detection_spec.rb +86 -86
- data/spec/spec_helper.rb +270 -270
- data/spec/unix_spec.rb +57 -57
- data/spec/windows_spec.rb +23 -23
- metadata +12 -10
data/spec/unix_spec.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
require "pid_behavior"
|
3
|
-
|
4
|
-
if ChildProcess.unix? && !ChildProcess.jruby? && !ChildProcess.posix_spawn?
|
5
|
-
|
6
|
-
describe ChildProcess::Unix::Process do
|
7
|
-
it_behaves_like "a platform that provides the child's pid"
|
8
|
-
|
9
|
-
it "handles ECHILD race condition where process dies between timeout and KILL" do
|
10
|
-
process = sleeping_ruby
|
11
|
-
|
12
|
-
allow(process).to receive(:fork).and_return('fakepid')
|
13
|
-
allow(process).to receive(:send_term)
|
14
|
-
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
15
|
-
allow(process).to receive(:send_kill).and_raise(Errno::ECHILD.new)
|
16
|
-
|
17
|
-
process.start
|
18
|
-
expect { process.stop }.not_to raise_error
|
19
|
-
|
20
|
-
allow(process).to receive(:alive?).and_return(false)
|
21
|
-
|
22
|
-
process.send(:send_signal, 'TERM')
|
23
|
-
end
|
24
|
-
|
25
|
-
it "handles ESRCH race condition where process dies between timeout and KILL" do
|
26
|
-
process = sleeping_ruby
|
27
|
-
|
28
|
-
allow(process).to receive(:fork).and_return('fakepid')
|
29
|
-
allow(process).to receive(:send_term)
|
30
|
-
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
31
|
-
allow(process).to receive(:send_kill).and_raise(Errno::ESRCH.new)
|
32
|
-
|
33
|
-
process.start
|
34
|
-
expect { process.stop }.not_to raise_error
|
35
|
-
|
36
|
-
allow(process).to receive(:alive?).and_return(false)
|
37
|
-
|
38
|
-
process.send(:send_signal, 'TERM')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ChildProcess::Unix::IO do
|
43
|
-
let(:io) { ChildProcess::Unix::IO.new }
|
44
|
-
|
45
|
-
it "raises an ArgumentError if given IO does not respond to :to_io" do
|
46
|
-
expect { io.stdout = nil }.to raise_error(ArgumentError, /to respond to :to_io/)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "raises a TypeError if #to_io does not return an IO" do
|
50
|
-
fake_io = Object.new
|
51
|
-
def fake_io.to_io() StringIO.new end
|
52
|
-
|
53
|
-
expect { io.stdout = fake_io }.to raise_error(TypeError, /expected IO, got/)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require "pid_behavior"
|
3
|
+
|
4
|
+
if ChildProcess.unix? && !ChildProcess.jruby? && !ChildProcess.posix_spawn?
|
5
|
+
|
6
|
+
describe ChildProcess::Unix::Process do
|
7
|
+
it_behaves_like "a platform that provides the child's pid"
|
8
|
+
|
9
|
+
it "handles ECHILD race condition where process dies between timeout and KILL" do
|
10
|
+
process = sleeping_ruby
|
11
|
+
|
12
|
+
allow(process).to receive(:fork).and_return('fakepid')
|
13
|
+
allow(process).to receive(:send_term)
|
14
|
+
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
15
|
+
allow(process).to receive(:send_kill).and_raise(Errno::ECHILD.new)
|
16
|
+
|
17
|
+
process.start
|
18
|
+
expect { process.stop }.not_to raise_error
|
19
|
+
|
20
|
+
allow(process).to receive(:alive?).and_return(false)
|
21
|
+
|
22
|
+
process.send(:send_signal, 'TERM')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "handles ESRCH race condition where process dies between timeout and KILL" do
|
26
|
+
process = sleeping_ruby
|
27
|
+
|
28
|
+
allow(process).to receive(:fork).and_return('fakepid')
|
29
|
+
allow(process).to receive(:send_term)
|
30
|
+
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
31
|
+
allow(process).to receive(:send_kill).and_raise(Errno::ESRCH.new)
|
32
|
+
|
33
|
+
process.start
|
34
|
+
expect { process.stop }.not_to raise_error
|
35
|
+
|
36
|
+
allow(process).to receive(:alive?).and_return(false)
|
37
|
+
|
38
|
+
process.send(:send_signal, 'TERM')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ChildProcess::Unix::IO do
|
43
|
+
let(:io) { ChildProcess::Unix::IO.new }
|
44
|
+
|
45
|
+
it "raises an ArgumentError if given IO does not respond to :to_io" do
|
46
|
+
expect { io.stdout = nil }.to raise_error(ArgumentError, /to respond to :to_io/)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "raises a TypeError if #to_io does not return an IO" do
|
50
|
+
fake_io = Object.new
|
51
|
+
def fake_io.to_io() StringIO.new end
|
52
|
+
|
53
|
+
expect { io.stdout = fake_io }.to raise_error(TypeError, /expected IO, got/)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/spec/windows_spec.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
require "pid_behavior"
|
3
|
-
|
4
|
-
if ChildProcess.windows?
|
5
|
-
describe ChildProcess::Windows::Process do
|
6
|
-
it_behaves_like "a platform that provides the child's pid"
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ChildProcess::Windows::IO do
|
10
|
-
let(:io) { ChildProcess::Windows::IO.new }
|
11
|
-
|
12
|
-
it "raises an ArgumentError if given IO does not respond to :fileno" do
|
13
|
-
expect { io.stdout = nil }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "raises an ArgumentError if the #to_io does not return an IO " do
|
17
|
-
fake_io = Object.new
|
18
|
-
def fake_io.to_io() StringIO.new end
|
19
|
-
|
20
|
-
expect { io.stdout = fake_io }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require "pid_behavior"
|
3
|
+
|
4
|
+
if ChildProcess.windows?
|
5
|
+
describe ChildProcess::Windows::Process do
|
6
|
+
it_behaves_like "a platform that provides the child's pid"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ChildProcess::Windows::IO do
|
10
|
+
let(:io) { ChildProcess::Windows::IO.new }
|
11
|
+
|
12
|
+
it "raises an ArgumentError if given IO does not respond to :fileno" do
|
13
|
+
expect { io.stdout = nil }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "raises an ArgumentError if the #to_io does not return an IO " do
|
17
|
+
fake_io = Object.new
|
18
|
+
def fake_io.to_io() StringIO.new end
|
19
|
+
|
20
|
+
expect { io.stdout = fake_io }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: childprocess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
- Eric Kessler
|
9
|
+
- Shane da Silva
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2019-
|
13
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
@@ -40,37 +41,38 @@ dependencies:
|
|
40
41
|
- !ruby/object:Gem::Version
|
41
42
|
version: '0.0'
|
42
43
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
44
|
+
name: coveralls
|
44
45
|
requirement: !ruby/object:Gem::Requirement
|
45
46
|
requirements:
|
46
47
|
- - "<"
|
47
48
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
49
|
+
version: '1.0'
|
49
50
|
type: :development
|
50
51
|
prerelease: false
|
51
52
|
version_requirements: !ruby/object:Gem::Requirement
|
52
53
|
requirements:
|
53
54
|
- - "<"
|
54
55
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
56
|
+
version: '1.0'
|
56
57
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
58
|
+
name: rake
|
58
59
|
requirement: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
61
|
- - "<"
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
63
|
-
type: :
|
63
|
+
version: '13.0'
|
64
|
+
type: :runtime
|
64
65
|
prerelease: false
|
65
66
|
version_requirements: !ruby/object:Gem::Requirement
|
66
67
|
requirements:
|
67
68
|
- - "<"
|
68
69
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
70
|
+
version: '13.0'
|
70
71
|
description: This gem aims at being a simple and reliable solution for controlling
|
71
72
|
external programs running in the background on any Ruby / OS combination.
|
72
73
|
email:
|
73
74
|
- morrow748@gmail.com
|
75
|
+
- shane@dasilva.io
|
74
76
|
executables: []
|
75
77
|
extensions:
|
76
78
|
- ext/mkrf_conf.rb
|
@@ -145,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
147
|
version: '0'
|
146
148
|
requirements: []
|
147
149
|
rubyforge_project: childprocess
|
148
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.5.2.3
|
149
151
|
signing_key:
|
150
152
|
specification_version: 4
|
151
153
|
summary: A simple and reliable solution for controlling external programs running
|