* test/ruby/test_process.rb: skip some tests on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2010-05-13 06:32:21 +00:00
parent 4afa9ed041
commit 266a9ea5f3

View File

@ -349,8 +349,13 @@ class TestProcess < Test::Unit::TestCase
with_tmpchdir {|d| with_tmpchdir {|d|
Process.wait Process.spawn(*ECHO["a"], STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]) Process.wait Process.spawn(*ECHO["a"], STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644])
assert_equal("a", File.read("out").chomp) assert_equal("a", File.read("out").chomp)
if /mswin|mingw/ =~ RUBY_PLATFORM
# currently telling to child the file modes is not supported.
open("out", "a") {|f| f.write "0\n"}
else
Process.wait Process.spawn(*ECHO["0"], STDOUT=>["out", File::WRONLY|File::CREAT|File::APPEND, 0644]) Process.wait Process.spawn(*ECHO["0"], STDOUT=>["out", File::WRONLY|File::CREAT|File::APPEND, 0644])
assert_equal("a\n0\n", File.read("out")) assert_equal("a\n0\n", File.read("out"))
end
Process.wait Process.spawn(*SORT, STDIN=>["out", File::RDONLY, 0644], Process.wait Process.spawn(*SORT, STDIN=>["out", File::RDONLY, 0644],
STDOUT=>["out2", File::WRONLY|File::CREAT|File::TRUNC, 0644]) STDOUT=>["out2", File::WRONLY|File::CREAT|File::TRUNC, 0644])
assert_equal("0\na\n", File.read("out2")) assert_equal("0\na\n", File.read("out2"))
@ -374,12 +379,15 @@ class TestProcess < Test::Unit::TestCase
6=>1, 7=>:out, 8=>STDOUT, 6=>1, 7=>:out, 8=>STDOUT,
9=>2, 10=>:err, 11=>STDERR) 9=>2, 10=>:err, 11=>STDERR)
assert_equal("ee", File.read("out").chomp) assert_equal("ee", File.read("out").chomp)
if /mswin|mingw/ !~ RUBY_PLATFORM
# passing non-stdio fds is not supported on Windows
File.open("out", "w") {|f| File.open("out", "w") {|f|
h = {STDOUT=>f, f=>STDOUT} h = {STDOUT=>f, f=>STDOUT}
3.upto(30) {|i| h[i] = STDOUT if f.fileno != i } 3.upto(30) {|i| h[i] = STDOUT if f.fileno != i }
Process.wait Process.spawn(*ECHO["f"], h) Process.wait Process.spawn(*ECHO["f"], h)
assert_equal("f", File.read("out").chomp) assert_equal("f", File.read("out").chomp)
} }
end
assert_raise(ArgumentError) { assert_raise(ArgumentError) {
Process.wait Process.spawn(*ECHO["f"], 1=>Process) Process.wait Process.spawn(*ECHO["f"], 1=>Process)
} }
@ -397,10 +405,13 @@ class TestProcess < Test::Unit::TestCase
Process.wait Process.spawn(*SORT, STDIN=>"out", STDOUT=>"out2") Process.wait Process.spawn(*SORT, STDIN=>"out", STDOUT=>"out2")
assert_equal("ggg\nhhh\n", File.read("out2")) assert_equal("ggg\nhhh\n", File.read("out2"))
if /mswin|mingw/ !~ RUBY_PLATFORM
# passing non-stdio fds is not supported on Windows
assert_raise(Errno::ENOENT) { assert_raise(Errno::ENOENT) {
Process.wait Process.spawn("non-existing-command", (3..60).to_a=>["err", File::WRONLY|File::CREAT]) Process.wait Process.spawn("non-existing-command", (3..60).to_a=>["err", File::WRONLY|File::CREAT])
} }
assert_equal("", File.read("err")) assert_equal("", File.read("err"))
end
system(*ECHO["bb\naa\n"], STDOUT=>["out", "w"]) system(*ECHO["bb\naa\n"], STDOUT=>["out", "w"])
assert_equal("bb\naa\n", File.read("out")) assert_equal("bb\naa\n", File.read("out"))
@ -417,10 +428,13 @@ class TestProcess < Test::Unit::TestCase
w1.puts "b" w1.puts "b"
w1.close w1.close
assert_equal("a\nb\nc\n", r2.read) assert_equal("a\nb\nc\n", r2.read)
r2.close
Process.wait(pid) Process.wait(pid)
} }
} }
if /mswin|mingw/ !~ RUBY_PLATFORM
# passing non-stdio fds is not supported on Windows
with_pipes(5) {|pipes| with_pipes(5) {|pipes|
ios = pipes.flatten ios = pipes.flatten
h = {} h = {}
@ -450,8 +464,9 @@ class TestProcess < Test::Unit::TestCase
pipes.each {|r, w| pipes.each {|r, w|
assert_equal("#{h2[w].fileno}\n", r.gets) assert_equal("#{h2[w].fileno}\n", r.gets)
} }
Process.wait pid; Process.wait pid
} }
end
closed_fd = nil closed_fd = nil
with_pipes(5) {|pipes| with_pipes(5) {|pipes|
@ -461,11 +476,13 @@ class TestProcess < Test::Unit::TestCase
assert_raise(Errno::EBADF) { Process.wait spawn(*TRUECOMMAND, closed_fd=>closed_fd) } assert_raise(Errno::EBADF) { Process.wait spawn(*TRUECOMMAND, closed_fd=>closed_fd) }
with_pipe {|r, w| with_pipe {|r, w|
if w.respond_to?(:"close_on_exec=")
w.close_on_exec = true w.close_on_exec = true
pid = spawn(RUBY, "-e", "IO.new(#{w.fileno}, 'w').print 'a'", w=>w) pid = spawn(RUBY, "-e", "IO.new(#{w.fileno}, 'w').print 'a'", w=>w)
w.close w.close
assert_equal("a", r.read) assert_equal("a", r.read)
Process.wait pid Process.wait pid
end
} }
system(*ECHO["funya"], :out=>"out") system(*ECHO["funya"], :out=>"out")