mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aeeaadaad0
commit
b53cf149ad
246 changed files with 9108 additions and 548 deletions
|
@ -115,6 +115,49 @@ platform_is_not :windows do
|
|||
end
|
||||
|
||||
describe "Signal.trap" do
|
||||
cannot_be_trapped = %w[KILL STOP] # See man 2 signal
|
||||
reserved_signals = %w[VTALRM]
|
||||
|
||||
if PlatformGuard.implementation?(:ruby)
|
||||
reserved_signals += %w[SEGV ILL FPE BUS]
|
||||
end
|
||||
|
||||
if PlatformGuard.implementation?(:truffleruby)
|
||||
if !TruffleRuby.native?
|
||||
reserved_signals += %w[SEGV ILL FPE USR1 QUIT]
|
||||
end
|
||||
end
|
||||
|
||||
if PlatformGuard.implementation?(:jruby)
|
||||
reserved_signals += %w[SEGV ILL FPE BUS USR1 QUIT]
|
||||
end
|
||||
|
||||
cannot_be_trapped.each do |signal|
|
||||
it "raises ArgumentError or Errno::EINVAL for SIG#{signal}" do
|
||||
-> {
|
||||
trap(signal, -> {})
|
||||
}.should raise_error(StandardError) { |e|
|
||||
[ArgumentError, Errno::EINVAL].should include(e.class)
|
||||
e.message.should =~ /Invalid argument|Signal already used by VM or OS/
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
reserved_signals.each do |signal|
|
||||
it "raises ArgumentError for reserved signal SIG#{signal}" do
|
||||
-> {
|
||||
trap(signal, -> {})
|
||||
}.should raise_error(ArgumentError, /can't trap reserved signal|Signal already used by VM or OS/)
|
||||
end
|
||||
end
|
||||
|
||||
it "allows to register a handler for all known signals, except reserved signals" do
|
||||
excluded = cannot_be_trapped + reserved_signals
|
||||
out = ruby_exe(fixture(__FILE__, "trap_all.rb"), args: [*excluded, "2>&1"])
|
||||
out.should == "OK\n"
|
||||
$?.exitstatus.should == 0
|
||||
end
|
||||
|
||||
it "returns SYSTEM_DEFAULT if passed DEFAULT and no handler was ever set" do
|
||||
Signal.trap("PROF", "DEFAULT").should == "SYSTEM_DEFAULT"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue