ruby-changes:23283
From: naruse <ko1@a...>
Date: Sun, 15 Apr 2012 14:54:51 +0900 (JST)
Subject: [ruby-changes:23283] naruse:r35334 (ruby_1_9_3): merge revision(s) 32799:
naruse 2012-04-15 14:54:40 +0900 (Sun, 15 Apr 2012) New Revision: 35334 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35334 Log: merge revision(s) 32799: * 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. Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/test/ruby/test_process.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 35333) +++ ruby_1_9_3/ChangeLog (revision 35334) @@ -1,3 +1,12 @@ +Sun Apr 15 14:54:16 2012 NAKAMURA Usaku <usa@r...> + + * 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. + Sun Apr 15 06:40:28 2012 Hiroshi Shirosaki <h.shirosaki@g...> * include/ruby/win32.h (rb_w32_aspawn_flags): add the declaration of Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 35333) +++ ruby_1_9_3/version.h (revision 35334) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 182 +#define RUBY_PATCHLEVEL 183 #define RUBY_RELEASE_DATE "2012-04-15" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/test/ruby/test_process.rb =================================================================== --- ruby_1_9_3/test/ruby/test_process.rb (revision 35333) +++ ruby_1_9_3/test/ruby/test_process.rb (revision 35334) @@ -16,6 +16,10 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } - 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 @@ 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 @@ 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) @@ -604,9 +602,7 @@ 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 @@ -648,9 +644,7 @@ 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) @@ -854,7 +848,7 @@ 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=#{$$}" @@ -883,7 +877,7 @@ 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'") @@ -915,7 +909,7 @@ 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'") @@ -953,7 +947,7 @@ 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} @@ -1258,7 +1252,7 @@ end def test_system_sigpipe - return if /mswin|mingw/ =~ RUBY_PLATFORM + return if windows? pid = 0 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/