Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* test/ruby/test_process.rb (TestProcess#windows?): new method.

* test/ruby/test_process.rb (TestProcess#*): use above method.

* test/ruby/test_process.rb (TestProcess#test_execopts_redirect):
  windows doesn't support FD_CLOEXEC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit b8d546db6445742f511110f09cf3f33dc87d310e 1 parent f209dc7
@unak unak authored
Showing with 33 additions and 30 deletions.
  1. +9 −0 ChangeLog
  2. +24 −30 test/ruby/test_process.rb
View
9 ChangeLog
@@ -1,3 +1,12 @@
+Mon Aug 1 20:12:03 2011 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * test/ruby/test_process.rb (TestProcess#windows?): new method.
+
+ * test/ruby/test_process.rb (TestProcess#*): use above method.
+
+ * test/ruby/test_process.rb (TestProcess#test_execopts_redirect):
+ windows doesn't support FD_CLOEXEC.
+
Mon Aug 01 15:45:23 2011 Eric Hodel <drbrain@segment7.net>
* test/rake/test_rake_functional.rb: Don't assume the binary name of
View
54 test/ruby/test_process.rb
@@ -16,6 +16,10 @@ def teardown
Process.waitall
end
+ def windows?
+ return /mswin|mingw|bccwin/ =~ RUBY_PLATFORM
+ end
+
def write_file(filename, content)
File.open(filename, "w") {|f|
f << content
@@ -154,7 +158,7 @@ def test_execopts_opts
end
def test_execopts_pgroup
- skip "system(:pgroup) is not supported" if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
+ skip "system(:pgroup) is not supported" if windows?
assert_nothing_raised { system(*TRUECOMMAND, :pgroup=>false) }
io = IO.popen([RUBY, "-e", "print Process.getpgrp"])
@@ -326,7 +330,7 @@ def test_execopts_chdir
UMASK = [RUBY, '-e', 'printf "%04o\n", File.umask']
def test_execopts_umask
- skip "umask is not supported" if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
+ skip "umask is not supported" if windows?
IO.popen([*UMASK, :umask => 0]) {|io|
assert_equal("0000", io.read.chomp)
}
@@ -368,7 +372,7 @@ def test_execopts_redirect
with_tmpchdir {|d|
Process.wait Process.spawn(*ECHO["a"], STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644])
assert_equal("a", File.read("out").chomp)
- if /mswin|mingw/ =~ RUBY_PLATFORM
+ if windows?
# currently telling to child the file modes is not supported.
open("out", "a") {|f| f.write "0\n"}
else
@@ -391,18 +395,14 @@ def test_execopts_redirect
assert_equal("d", File.read("out").chomp)
}
opts = {STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]}
- if /mswin|mingw/ !~ RUBY_PLATFORM
- opts.merge(3=>STDOUT, 4=>STDOUT, 5=>STDOUT, 6=>STDOUT, 7=>STDOUT)
- end
+ opts.merge(3=>STDOUT, 4=>STDOUT, 5=>STDOUT, 6=>STDOUT, 7=>STDOUT) unless windows?
Process.wait Process.spawn(*ECHO["e"], opts)
assert_equal("e", File.read("out").chomp)
opts = {STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]}
- if /mswin|mingw/ !~ RUBY_PLATFORM
- opts.merge(3=>0, 4=>:in, 5=>STDIN, 6=>1, 7=>:out, 8=>STDOUT, 9=>2, 10=>:err, 11=>STDERR)
- end
+ opts.merge(3=>0, 4=>:in, 5=>STDIN, 6=>1, 7=>:out, 8=>STDOUT, 9=>2, 10=>:err, 11=>STDERR) unless windows?
Process.wait Process.spawn(*ECHO["ee"], opts)
assert_equal("ee", File.read("out").chomp)
- if /mswin|mingw/ !~ RUBY_PLATFORM
+ unless windows?
# passing non-stdio fds is not supported on Windows
File.open("out", "w") {|f|
h = {STDOUT=>f, f=>STDOUT}
@@ -428,7 +428,7 @@ def test_execopts_redirect
Process.wait Process.spawn(*SORT, STDIN=>"out", STDOUT=>"out2")
assert_equal("ggg\nhhh\n", File.read("out2"))
- if /mswin|mingw/ !~ RUBY_PLATFORM
+ unless windows?
# passing non-stdio fds is not supported on Windows
assert_raise(Errno::ENOENT) {
Process.wait Process.spawn("non-existing-command", (3..60).to_a=>["err", File::WRONLY|File::CREAT])
@@ -443,7 +443,9 @@ def test_execopts_redirect
with_pipe {|r1, w1|
with_pipe {|r2, w2|
- pid = spawn(*SORT, STDIN=>r1, STDOUT=>w2, w1=>:close, r2=>:close)
+ opts = {STDIN=>r1, STDOUT=>w2}
+ opts.merge(w1=>:close, r2=>:close) unless windows?
+ pid = spawn(*SORT, opts)
r1.close
w2.close
w1.puts "c"
@@ -456,7 +458,7 @@ def test_execopts_redirect
}
}
- if /mswin|mingw/ !~ RUBY_PLATFORM
+ unless windows?
# passing non-stdio fds is not supported on Windows
with_pipes(5) {|pipes|
ios = pipes.flatten
@@ -528,9 +530,7 @@ def test_execopts_redirect_dup2_child
STDERR=>"out", STDOUT=>[:child, STDERR])
assert_equal("errout", File.read("out"))
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
- skip "inheritance of fd other than stdin,stdout and stderr is not supported"
- end
+ skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
Process.wait spawn(RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'",
STDOUT=>"out",
STDERR=>[:child, 3],
@@ -573,9 +573,7 @@ def test_execopts_popen
assert_raise(ArgumentError) {
IO.popen([*ECHO["fuga"], STDOUT=>"out"]) {|io| }
}
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
- skip "inheritance of fd other than stdin,stdout and stderr is not supported"
- end
+ skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
with_pipe {|r, w|
IO.popen([RUBY, '-e', 'IO.new(3, "w").puts("a"); puts "b"', 3=>w]) {|io|
assert_equal("b\n", io.read)
@@ -603,9 +601,7 @@ def test_popen_fork
end
def test_fd_inheritance
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
- skip "inheritance of fd other than stdin,stdout and stderr is not supported"
- end
+ skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
with_pipe {|r, w|
system(RUBY, '-e', 'IO.new(ARGV[0].to_i, "w").puts(:ba)', w.fileno.to_s)
w.close
@@ -647,9 +643,7 @@ def test_fd_inheritance
end
def test_execopts_close_others
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
- skip "inheritance of fd other than stdin,stdout and stderr is not supported"
- end
+ skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
with_tmpchdir {|d|
with_pipe {|r, w|
system(RUBY, '-e', 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i, "w").puts("ma")', w.fileno.to_s, :close_others=>true)
@@ -853,7 +847,7 @@ def test_exec_wordsplit
assert_equal(pid, status.pid)
assert(status.exited?)
assert_equal(6, status.exitstatus)
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
+ if windows?
expected = "hehe ppid=#{status.pid}"
else
expected = "hehe pid=#{status.pid} ppid=#{$$}"
@@ -882,7 +876,7 @@ def test_system_shell
assert_match(/\Ataki pid=\d+ ppid=\d+\z/, result2)
assert_not_equal(result1[/\d+/].to_i, status.pid)
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
+ if windows?
Dir.mkdir(path = "path with space")
write_file(bat = path + "/bat test.bat", "@echo %1>out")
system(bat, "foo 'bar'")
@@ -914,7 +908,7 @@ def test_spawn_shell
assert_match(/\Atake pid=\d+ ppid=\d+\z/, result2)
assert_not_equal(result1[/\d+/].to_i, status.pid)
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
+ if windows?
Dir.mkdir(path = "path with space")
write_file(bat = path + "/bat test.bat", "@echo %1>out")
pid = spawn(bat, "foo 'bar'")
@@ -952,7 +946,7 @@ def test_popen_shell
assert_match(/\Atako pid=\d+ ppid=\d+\ntika pid=\d+ ppid=\d+\n\z/, result)
assert_not_equal(result[/\d+/].to_i, status.pid)
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
+ if windows?
Dir.mkdir(path = "path with space")
write_file(bat = path + "/bat test.bat", "@echo %1")
r = IO.popen([bat, "foo 'bar'"]) {|f| f.read}
@@ -1256,7 +1250,7 @@ def test_too_long_path2
end
def test_system_sigpipe
- return if /mswin|mingw/ =~ RUBY_PLATFORM
+ return if windows?
pid = 0
Please sign in to comment.
Something went wrong with that request. Please try again.