Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Add spec to make sure unexpected signals are not restored to DEFAULT
Browse files Browse the repository at this point in the history
  • Loading branch information
Shayon Mukherjee committed Dec 25, 2017
1 parent 854e177 commit 27382f2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/commands/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,24 @@ def bin_path(a,b,c)
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(', ')
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
bundle("exec #{path}")

expect(out).to eq(test_signals.count.to_s)
end
end
end

context "nested bundle exec" do
Expand Down
11 changes: 11 additions & 0 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,21 @@ def gem_command(command, args = "", options = {})
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)

Open3.popen3(cmd.to_s) do |stdin, stdout, stderr, wait_thr|
test_signals.each do |n|
Signal.trap(n, "IGNORE")
end
yield stdin, stdout, wait_thr if block_given?
stdin.close

Expand Down

0 comments on commit 27382f2

Please sign in to comment.