summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-29 02:24:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-29 02:24:26 +0000
commit01e712d78685d17654cbf87d9aefeff75de87e4f (patch)
tree16507364a5c17a63c83a110da7ee148a105178b6 /test
parenta851d05175b0a181d7bb5bd94d5197d148e59382 (diff)
add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_process.rb41
1 files changed, 41 insertions, 0 deletions
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