diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-29 02:24:26 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-29 02:24:26 +0000 |
commit | d45d994615098a0a1359c2947a3d52728f1a9d02 (patch) | |
tree | 16507364a5c17a63c83a110da7ee148a105178b6 /test/ruby/test_process.rb | |
parent | 075736647fc911dc6570da294f39e3c3d44cc9ac (diff) | |
download | ruby-d45d994615098a0a1359c2947a3d52728f1a9d02.tar.gz ruby-d45d994615098a0a1359c2947a3d52728f1a9d02.tar.xz ruby-d45d994615098a0a1359c2947a3d52728f1a9d02.zip |
add tests.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_process.rb')
-rw-r--r-- | test/ruby/test_process.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index cd1ae8ac6..16340f9c3 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 |