From ad1715f0b9802ddf23e83232661c7b67d2a0a7d6 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 27 Jan 2013 04:04:23 +0000 Subject: test_system.rb: fix test * test/ruby/test_system.rb (TestSystem#test_system_redirect_win): fix meaningless test. [Bug #7482] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_system.rb | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'test/ruby/test_system.rb') diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index 13266d9d37..d66f9018c1 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -119,11 +119,31 @@ class TestSystem < Test::Unit::TestCase return end - cmd = "%WINDIR%/system32/ping.exe \"BFI3CHL671\" > out.txt 2>NUL" - assert_equal(false, system(cmd), '[ruby-talk:258939]'); - - cmd = "\"%WINDIR%/system32/ping.exe BFI3CHL671\" > out.txt 2>NUL" - assert_equal(false, system(cmd), '[ruby-talk:258939]'); + Dir.mktmpdir("ruby_script_tmp") do |tmpdir| + cmd = nil + message = proc do + [ + '[ruby-talk:258939]', + "out.txt:", + *File.readlines("out.txt").map{|s|" "+s.inspect}, + "err.txt:", + *File.readlines("err.txt").map{|s|" "+s.inspect}, + "system(#{cmd.inspect})" + ].join("\n") + end + class << message + alias to_s call + end + Dir.chdir(tmpdir) do + open("input.txt", "w") {|f| f.puts "BFI3CHL671"} + cmd = "%WINDIR%/system32/find.exe \"BFI3CHL671\" input.txt > out.txt 2>err.txt" + assert_equal(true, system(cmd), message) + cmd = "\"%WINDIR%/system32/find.exe\" \"BFI3CHL671\" input.txt > out.txt 2>err.txt" + assert_equal(true, system(cmd), message) + cmd = "\"%WINDIR%/system32/find.exe BFI3CHL671\" input.txt > out.txt 2>err.txt" + assert_equal(true, system(cmd), message) + end + end end def test_empty_evstr -- cgit v1.2.3