childprocess 0.8.0 → 2.0.0
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 +42 -36
- data/CHANGELOG.md +67 -44
- data/Gemfile +18 -15
- data/LICENSE +20 -20
- data/README.md +216 -192
- data/Rakefile +61 -61
- data/appveyor.yml +42 -43
- data/childprocess.gemspec +32 -30
- data/ext/mkrf_conf.rb +24 -0
- data/lib/childprocess/abstract_io.rb +36 -36
- data/lib/childprocess/abstract_process.rb +192 -192
- data/lib/childprocess/errors.rb +37 -26
- data/lib/childprocess/jruby/io.rb +16 -16
- data/lib/childprocess/jruby/process.rb +184 -159
- data/lib/childprocess/jruby/pump.rb +53 -53
- data/lib/childprocess/jruby.rb +56 -56
- data/lib/childprocess/tools/generator.rb +145 -145
- data/lib/childprocess/unix/fork_exec_process.rb +78 -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 +90 -89
- data/lib/childprocess/unix.rb +9 -9
- data/lib/childprocess/version.rb +3 -3
- 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 -175
- data/lib/childprocess/windows/structs.rb +148 -148
- data/lib/childprocess/windows.rb +33 -33
- data/lib/childprocess.rb +210 -205
- data/spec/abstract_io_spec.rb +12 -12
- data/spec/childprocess_spec.rb +447 -391
- data/spec/get_env.ps1 +13 -0
- 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 -261
- data/spec/unix_spec.rb +57 -57
- data/spec/windows_spec.rb +23 -23
- metadata +18 -33
@@ -1,86 +1,86 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
# Q: Should platform detection concern be extracted from ChildProcess?
|
4
|
-
describe ChildProcess do
|
5
|
-
|
6
|
-
describe ".arch" do
|
7
|
-
subject { described_class.arch }
|
8
|
-
|
9
|
-
before(:each) { described_class.instance_variable_set(:@arch, nil) }
|
10
|
-
|
11
|
-
after(:each) { described_class.instance_variable_set(:@arch, nil) }
|
12
|
-
|
13
|
-
shared_examples 'expected_arch_for_host_cpu' do |host_cpu, expected_arch|
|
14
|
-
context "when host_cpu is '#{host_cpu}'" do
|
15
|
-
before :each do
|
16
|
-
allow(RbConfig::CONFIG).
|
17
|
-
to receive(:[]).
|
18
|
-
with('host_cpu').
|
19
|
-
and_return(expected_arch)
|
20
|
-
end
|
21
|
-
|
22
|
-
it { is_expected.to eq expected_arch }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Normal cases: not macosx - depends only on host_cpu
|
27
|
-
context "when os is *not* 'macosx'" do
|
28
|
-
before :each do
|
29
|
-
allow(described_class).to receive(:os).and_return(:not_macosx)
|
30
|
-
end
|
31
|
-
|
32
|
-
[
|
33
|
-
{ host_cpu: 'i386', expected_arch: 'i386' },
|
34
|
-
{ host_cpu: 'i486', expected_arch: 'i386' },
|
35
|
-
{ host_cpu: 'i586', expected_arch: 'i386' },
|
36
|
-
{ host_cpu: 'i686', expected_arch: 'i386' },
|
37
|
-
{ host_cpu: 'amd64', expected_arch: 'x86_64' },
|
38
|
-
{ host_cpu: 'x86_64', expected_arch: 'x86_64' },
|
39
|
-
{ host_cpu: 'ppc', expected_arch: 'powerpc' },
|
40
|
-
{ host_cpu: 'powerpc', expected_arch: 'powerpc' },
|
41
|
-
{ host_cpu: 'unknown', expected_arch: 'unknown' },
|
42
|
-
].each do |args|
|
43
|
-
include_context 'expected_arch_for_host_cpu', args.values
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Special cases: macosx - when host_cpu is i686, have to re-check
|
48
|
-
context "when os is 'macosx'" do
|
49
|
-
before :each do
|
50
|
-
allow(described_class).to receive(:os).and_return(:macosx)
|
51
|
-
end
|
52
|
-
|
53
|
-
context "when host_cpu is 'i686' " do
|
54
|
-
shared_examples 'expected_arch_on_macosx_i686' do |is_64, expected_arch|
|
55
|
-
context "when Ruby is #{is_64 ? 64 : 32}-bit" do
|
56
|
-
before :each do
|
57
|
-
allow(described_class).
|
58
|
-
to receive(:is_64_bit?).
|
59
|
-
and_return(is_64)
|
60
|
-
end
|
61
|
-
|
62
|
-
include_context 'expected_arch_for_host_cpu', 'i686', expected_arch
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
[
|
67
|
-
{ is_64: true, expected_arch: 'x86_64' },
|
68
|
-
{ is_64: false, expected_arch: 'i386' }
|
69
|
-
].each do |args|
|
70
|
-
include_context 'expected_arch_on_macosx_i686', args.values
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
[
|
75
|
-
{ host_cpu: 'amd64', expected_arch: 'x86_64' },
|
76
|
-
{ host_cpu: 'x86_64', expected_arch: 'x86_64' },
|
77
|
-
{ host_cpu: 'ppc', expected_arch: 'powerpc' },
|
78
|
-
{ host_cpu: 'powerpc', expected_arch: 'powerpc' },
|
79
|
-
{ host_cpu: 'unknown', expected_arch: 'unknown' },
|
80
|
-
].each do |args|
|
81
|
-
include_context 'expected_arch_for_host_cpu', args.values
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
# Q: Should platform detection concern be extracted from ChildProcess?
|
4
|
+
describe ChildProcess do
|
5
|
+
|
6
|
+
describe ".arch" do
|
7
|
+
subject { described_class.arch }
|
8
|
+
|
9
|
+
before(:each) { described_class.instance_variable_set(:@arch, nil) }
|
10
|
+
|
11
|
+
after(:each) { described_class.instance_variable_set(:@arch, nil) }
|
12
|
+
|
13
|
+
shared_examples 'expected_arch_for_host_cpu' do |host_cpu, expected_arch|
|
14
|
+
context "when host_cpu is '#{host_cpu}'" do
|
15
|
+
before :each do
|
16
|
+
allow(RbConfig::CONFIG).
|
17
|
+
to receive(:[]).
|
18
|
+
with('host_cpu').
|
19
|
+
and_return(expected_arch)
|
20
|
+
end
|
21
|
+
|
22
|
+
it { is_expected.to eq expected_arch }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Normal cases: not macosx - depends only on host_cpu
|
27
|
+
context "when os is *not* 'macosx'" do
|
28
|
+
before :each do
|
29
|
+
allow(described_class).to receive(:os).and_return(:not_macosx)
|
30
|
+
end
|
31
|
+
|
32
|
+
[
|
33
|
+
{ host_cpu: 'i386', expected_arch: 'i386' },
|
34
|
+
{ host_cpu: 'i486', expected_arch: 'i386' },
|
35
|
+
{ host_cpu: 'i586', expected_arch: 'i386' },
|
36
|
+
{ host_cpu: 'i686', expected_arch: 'i386' },
|
37
|
+
{ host_cpu: 'amd64', expected_arch: 'x86_64' },
|
38
|
+
{ host_cpu: 'x86_64', expected_arch: 'x86_64' },
|
39
|
+
{ host_cpu: 'ppc', expected_arch: 'powerpc' },
|
40
|
+
{ host_cpu: 'powerpc', expected_arch: 'powerpc' },
|
41
|
+
{ host_cpu: 'unknown', expected_arch: 'unknown' },
|
42
|
+
].each do |args|
|
43
|
+
include_context 'expected_arch_for_host_cpu', args.values
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Special cases: macosx - when host_cpu is i686, have to re-check
|
48
|
+
context "when os is 'macosx'" do
|
49
|
+
before :each do
|
50
|
+
allow(described_class).to receive(:os).and_return(:macosx)
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when host_cpu is 'i686' " do
|
54
|
+
shared_examples 'expected_arch_on_macosx_i686' do |is_64, expected_arch|
|
55
|
+
context "when Ruby is #{is_64 ? 64 : 32}-bit" do
|
56
|
+
before :each do
|
57
|
+
allow(described_class).
|
58
|
+
to receive(:is_64_bit?).
|
59
|
+
and_return(is_64)
|
60
|
+
end
|
61
|
+
|
62
|
+
include_context 'expected_arch_for_host_cpu', 'i686', expected_arch
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
[
|
67
|
+
{ is_64: true, expected_arch: 'x86_64' },
|
68
|
+
{ is_64: false, expected_arch: 'i386' }
|
69
|
+
].each do |args|
|
70
|
+
include_context 'expected_arch_on_macosx_i686', args.values
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
[
|
75
|
+
{ host_cpu: 'amd64', expected_arch: 'x86_64' },
|
76
|
+
{ host_cpu: 'x86_64', expected_arch: 'x86_64' },
|
77
|
+
{ host_cpu: 'ppc', expected_arch: 'powerpc' },
|
78
|
+
{ host_cpu: 'powerpc', expected_arch: 'powerpc' },
|
79
|
+
{ host_cpu: 'unknown', expected_arch: 'unknown' },
|
80
|
+
].each do |args|
|
81
|
+
include_context 'expected_arch_for_host_cpu', args.values
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|