From 01e712d78685d17654cbf87d9aefeff75de87e4f Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 29 Apr 2008 02:24:26 +0000 Subject: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_process.rb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test') diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index cd1ae8ac62..16340f9c3f 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -738,4 +738,45 @@ class TestProcess < Test::Unit::TestCase } end + def test_argv0 + assert_equal(false, system([RUBY, "asdfg"], "-e", "exit false")) + assert_equal(true, system([RUBY, "zxcvb"], "-e", "exit true")) + + Process.wait spawn([RUBY, "poiu"], "-e", "exit 4") + assert_equal(4, $?.exitstatus) + + assert_equal("1", IO.popen([[RUBY, "qwerty"], "-e", "print 1"]).read) + + pid = fork { + exec([RUBY, "lkjh"], "-e", "exit 5") + } + Process.wait pid + assert_equal(5, $?.exitstatus) + end + + def test_argv0_noarg + with_tmpchdir {|d| + open("t", "w") {|f| f.print "exit true" } + open("f", "w") {|f| f.print "exit false" } + + assert_equal(true, system([RUBY, "qaz"], STDIN=>"t")) + assert_equal(false, system([RUBY, "wsx"], STDIN=>"f")) + + Process.wait spawn([RUBY, "edc"], STDIN=>"t") + assert($?.success?) + Process.wait spawn([RUBY, "rfv"], STDIN=>"f") + assert(!$?.success?) + + IO.popen([[RUBY, "tgb"], STDIN=>"t"]) {|io| assert_equal("", io.read) } + assert($?.success?) + IO.popen([[RUBY, "yhn"], STDIN=>"f"]) {|io| assert_equal("", io.read) } + assert(!$?.success?) + + Process.wait fork { exec([RUBY, "ujm"], STDIN=>"t") } + assert($?.success?) + Process.wait fork { exec([RUBY, "ik,"], STDIN=>"f") } + assert(!$?.success?) + } + end + end -- cgit v1.2.3