summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShayon Mukherjee <dev@shayon.me>2017-12-24 12:24:16 -0800
committerSamuel Giddins <segiddins@segiddins.me>2018-01-15 15:56:19 -0800
commit05f214aef38d502a52cdae1faf445ec55f73f7f1 (patch)
treef4010de3ead31278e746c7e58b49c4a48ae1e71c
parentcc38f846d2731fd73a28379a93b5ddebaab09d30 (diff)
downloadbundler-05f214aef38d502a52cdae1faf445ec55f73f7f1.tar.gz
Add spec to make sure unexpected signals are not restored to DEFAULT
-rw-r--r--spec/commands/exec_spec.rb22
-rw-r--r--spec/support/helpers.rb8
2 files changed, 30 insertions, 0 deletions
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index 0bda2504de..c600ecb6df 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -726,6 +726,28 @@ __FILE__: #{path.to_s.inspect}
expect(out).to eq("foo")
end
end
+
+ 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
+
+ it "makes sure no unexpected signals are restored to DEFAULT" do
+ test_signals.each do |n|
+ Signal.trap(n, "IGNORE")
+ end
+
+ bundle("exec #{path}")
+
+ expect(out).to eq(test_signals.count.to_s)
+ end
+ end
end
context "nested bundle exec" do
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 6201631011..e22fce5d9d 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -217,6 +217,14 @@ 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)