aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_signal.rb
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-31 15:02:22 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-31 15:02:22 +0000
commita3e1b1ce7ed7e7ffac23015fc2fde56511b30681 (patch)
tree7b725552a9a4ded93849ca2faab1b257f7761790 /test/ruby/test_signal.rb
parent3e7566d8fb5138bb9cd647e5fdefc54fc9803509 (diff)
downloadruby-a3e1b1ce7ed7e7ffac23015fc2fde56511b30681.tar.gz
* Merge YARV
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_signal.rb')
-rw-r--r--test/ruby/test_signal.rb37
1 files changed, 18 insertions, 19 deletions
diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb
index 8daa1cfa21..27a0d5021d 100644
--- a/test/ruby/test_signal.rb
+++ b/test/ruby/test_signal.rb
@@ -4,32 +4,31 @@ require 'timeout'
class TestSignal < Test::Unit::TestCase
def have_fork?
begin
- fork{}
- true
+ Process.fork {}
+ return true
rescue NotImplementedError
- false
+ return false
end
end
def test_signal
- defined?(Process.kill) or return
+ return unless Process.method_defined?(:kill)
begin
- $x = 0
- oldtrap = trap "SIGINT", proc{|sig| $x = 2}
- Process.kill "SIGINT", $$
+ x = 0
+ oldtrap = Signal.trap(:INT) {|sig| x = 2 }
+ Process.kill :INT, Process.pid
sleep 0.1
- assert_equal(2, $x)
+ assert_equal 2, x
- trap "SIGINT", proc{raise "Interrupt"}
-
- x = assert_raises(RuntimeError) do
- Process.kill "SIGINT", $$
+ Signal.trap(:INT) { raise "Interrupt" }
+ ex = assert_raises(RuntimeError) {
+ Process.kill :INT, Process.pid
sleep 0.1
- end
- assert(x)
- assert_match(/Interrupt/, x.message)
+ }
+ assert_kind_of Exception, ex
+ assert_match(/Interrupt/, ex.message)
ensure
- trap "SIGINT", oldtrap
+ Signal.trap :INT, oldtrap if oldtrap
end
end
@@ -38,8 +37,8 @@ class TestSignal < Test::Unit::TestCase
begin
r, w = IO.pipe
r0, w0 = IO.pipe
- pid = fork {
- trap(:USR1, "EXIT")
+ pid = Process.fork {
+ Signal.trap(:USR1, "EXIT")
w0.close
w.syswrite("a")
Thread.start { Thread.pass }
@@ -50,7 +49,7 @@ class TestSignal < Test::Unit::TestCase
assert_nothing_raised("[ruby-dev:26128]") {
Process.kill(:USR1, pid)
begin
- Timeout.timeout(1) {
+ Timeout.timeout(3) {
Process.waitpid pid
}
rescue Timeout::Error