summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2018-01-15 18:31:37 -0800
committerSamuel Giddins <segiddins@segiddins.me>2018-01-15 18:31:37 -0800
commit3f304f73bba9a810fa46f7d5074df1710a272013 (patch)
treecfb9705a2e4e1a63f77678580a23799accb0b026 /spec
parent05f214aef38d502a52cdae1faf445ec55f73f7f1 (diff)
downloadbundler-3f304f73bba9a810fa46f7d5074df1710a272013.tar.gz
Clean up signal handler test
Diffstat (limited to 'spec')
-rw-r--r--spec/commands/exec_spec.rb82
-rw-r--r--spec/support/helpers.rb8
2 files changed, 45 insertions, 45 deletions
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index c600ecb6df..59da8c4b50 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -700,52 +700,60 @@ __FILE__: #{path.to_s.inspect}
end
end
- context "signals being trapped by bundler" do
- let(:executable) { strip_whitespace <<-RUBY }
- #{shebang}
- begin
- Thread.new do
- puts 'Started' # For process sync
- STDOUT.flush
- sleep 1 # ignore quality_spec
- raise "Didn't receive INT at all"
- end.join
- rescue Interrupt
- puts "foo"
- end
- RUBY
+ context "signal handling" do
+ let(:test_signals) do
+ open3_reserved_signals = %w[CHLD CLD PIPE]
+ reserved_signals = %w[SEGV BUS ILL FPE VTALRM KILL STOP EXIT]
+ bundler_signals = %w[INT]
+
+ Signal.list.keys - (bundler_signals + reserved_signals + open3_reserved_signals)
+ end
+
+ context "signals being trapped by bundler" do
+ let(:executable) { strip_whitespace <<-RUBY }
+ #{shebang}
+ begin
+ Thread.new do
+ puts 'Started' # For process sync
+ STDOUT.flush
+ sleep 1 # ignore quality_spec
+ raise "Didn't receive INT at all"
+ end.join
+ rescue Interrupt
+ puts "foo"
+ end
+ RUBY
- it "receives the signal" do
- skip "popen3 doesn't provide a way to get pid " unless RUBY_VERSION >= "1.9.3"
+ it "receives the signal", :ruby => ">= 1.9.3" do
+ bundle!("exec #{path}") do |_, o, thr|
+ o.gets # Consumes 'Started' and ensures that thread has started
+ Process.kill("INT", thr.pid)
+ end
- bundle("exec #{path}") do |_, o, thr|
- o.gets # Consumes 'Started' and ensures that thread has started
- Process.kill("INT", thr.pid)
+ expect(out).to eq("foo")
end
-
- expect(out).to eq("foo")
end
- end
- context "signals not being trapped by bunder" do
- let(:executable) { strip_whitespace <<-RUBY }
- #{shebang}
+ context "signals not being trapped by bunder" do
+ let(:executable) { strip_whitespace <<-RUBY }
+ #{shebang}
- signals = "#{test_signals.join(", ")}".split(", ") # ruby 1.8.7 doesn't preserve array in string interpolation, hence the join/split.
- result = signals.map do |sig|
- Signal.trap(sig, "IGNORE")
- end
- puts result.select { |ret| ret == "IGNORE" }.count
- RUBY
+ signals = #{test_signals.inspect}
+ result = signals.map do |sig|
+ Signal.trap(sig, "IGNORE")
+ end
+ puts result.select { |ret| ret == "IGNORE" }.count
+ RUBY
- it "makes sure no unexpected signals are restored to DEFAULT" do
- test_signals.each do |n|
- Signal.trap(n, "IGNORE")
- end
+ it "makes sure no unexpected signals are restored to DEFAULT" do
+ test_signals.each do |n|
+ Signal.trap(n, "IGNORE")
+ end
- bundle("exec #{path}")
+ bundle!("exec #{path}")
- expect(out).to eq(test_signals.count.to_s)
+ expect(out).to eq(test_signals.count.to_s)
+ end
end
end
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index e22fce5d9d..6201631011 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -217,14 +217,6 @@ module Spec
end
bang :gem_command
- def test_signals
- open3_reserved_signals = %w[CHLD CLD PIPE]
- reserved_signals = %w[SEGV BUS ILL FPE VTALRM KILL STOP EXIT]
- bundler_signals = %w[INT]
-
- Signal.list.keys - (bundler_signals + reserved_signals + open3_reserved_signals)
- end
-
def sys_exec(cmd)
command_execution = CommandExecution.new(cmd.to_s, Dir.pwd)