1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_beginendblock.rb (test_should_propagate_signaled):

get rid of invoking shell.  [ruby-dev:30942]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-06-10 04:46:17 +00:00
parent d4d7164a9b
commit 7d8743d5c5
2 changed files with 14 additions and 10 deletions

View file

@ -1,3 +1,8 @@
Sun Jun 10 13:47:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
get rid of invoking shell. [ruby-dev:30942]
Sun Jun 10 12:56:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Jun 10 12:56:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby: moved public headers. * include/ruby: moved public headers.

View file

@ -13,7 +13,7 @@ class TestBeginEndBlock < Test::Unit::TestCase
def test_beginendblock def test_beginendblock
ruby = EnvUtil.rubybin ruby = EnvUtil.rubybin
target = File.join(DIR, 'beginmainend.rb') target = File.join(DIR, 'beginmainend.rb')
result = IO.popen("#{q(ruby)} #{q(target)}"){|io|io.read} result = IO.popen([ruby, target]){|io|io.read}
assert_equal(%w(b1 b2-1 b2 main b3-1 b3 b4 e1 e4 e3 e2 e4-2 e4-1 e1-1 e4-1-1), result.split) assert_equal(%w(b1 b2-1 b2 main b3-1 b3 b4 e1 e4 e3 e2 e4-2 e4-1 e1-1 e4-1-1), result.split)
end end
@ -38,14 +38,13 @@ errout = ARGV.shift
STDERR.reopen(File.open(errout, "w")) STDERR.reopen(File.open(errout, "w"))
STDERR.sync = true STDERR.sync = true
Dir.chdir(#{q(DIR)}) Dir.chdir(#{q(DIR)})
cmd = "\\"#{ruby}\\" \\"endblockwarn.rb\\"" system("#{ruby}", "endblockwarn.rb")
system(cmd)
EOF EOF
launcher.close launcher.close
launcherpath = launcher.path launcherpath = launcher.path
errout.close errout.close
erroutpath = errout.path erroutpath = errout.path
system("#{q(ruby)} #{q(launcherpath)} #{q(erroutpath)}") system(ruby, launcherpath, erroutpath)
expected = <<EOW expected = <<EOW
endblockwarn.rb:2: warning: END in method; use at_exit endblockwarn.rb:2: warning: END in method; use at_exit
(eval):2: warning: END in method; use at_exit (eval):2: warning: END in method; use at_exit
@ -57,9 +56,9 @@ EOW
def test_raise_in_at_exit def test_raise_in_at_exit
# [ruby-core:09675] # [ruby-core:09675]
ruby = EnvUtil.rubybin ruby = EnvUtil.rubybin
out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \ out = IO.popen([ruby, '-e', 'STDERR.reopen(STDOUT)',
"at_exit{raise %[SomethingBad]};" \ '-e', 'at_exit{raise %[SomethingBad]}'
"raise %[SomethingElse]'") {|f| '-e', 'raise %[SomethingElse]') {|f|
f.read f.read
} }
assert_match /SomethingBad/, out assert_match /SomethingBad/, out
@ -68,15 +67,15 @@ EOW
def test_should_propagate_exit_code def test_should_propagate_exit_code
ruby = EnvUtil.rubybin ruby = EnvUtil.rubybin
assert_equal false, system("#{q(ruby)} -e 'at_exit{exit 2}'") assert_equal false, system(ruby, '-e', 'at_exit{exit 2}')
assert_equal 2, $?.exitstatus assert_equal 2, $?.exitstatus
assert_nil $?.termsig assert_nil $?.termsig
end end
def test_should_propagate_signaled def test_should_propagate_signaled
ruby = EnvUtil.rubybin ruby = EnvUtil.rubybin
out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \ out = IO.popen([ruby, '-e', 'STDERR.reopen(STDOUT)',
"at_exit{Process.kill(:INT, $$)}'"){|f| '-e', 'at_exit{Process.kill(:INT, $$)}']) {|f|
f.read f.read
} }
assert_match /Interrupt$/, out assert_match /Interrupt$/, out