mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a851d05175
commit
01e712d786
1 changed files with 41 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue