ruby-changes:4740
From: ko1@a...
Date: Tue, 29 Apr 2008 11:24:58 +0900 (JST)
Subject: [ruby-changes:4740] akr - Ruby:r16234 (trunk): add tests.
akr 2008-04-29 11:24:26 +0900 (Tue, 29 Apr 2008) New Revision: 16234 Modified files: trunk/test/ruby/test_process.rb Log: add tests. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_process.rb?r1=16234&r2=16233&diff_format=u Index: test/ruby/test_process.rb =================================================================== --- test/ruby/test_process.rb (revision 16233) +++ test/ruby/test_process.rb (revision 16234) @@ -738,4 +738,45 @@ } 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/