[前][次][番号順一覧][スレッド一覧]

ruby-changes:20751

From: usa <ko1@a...>
Date: Mon, 1 Aug 2011 20:23:57 +0900 (JST)
Subject: [ruby-changes:20751] usa:r32799 (trunk): * test/ruby/test_process.rb (TestProcess#windows?): new method.

usa	2011-08-01 20:23:44 +0900 (Mon, 01 Aug 2011)

  New Revision: 32799

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32799

  Log:
    * 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:
    trunk/ChangeLog
    trunk/test/ruby/test_process.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32798)
+++ ChangeLog	(revision 32799)
@@ -1,3 +1,12 @@
+Mon Aug  1 20:12:03 2011  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.
+
 Mon Aug 01 15:45:23 2011  Eric Hodel  <drbrain@s...>
 
 	* test/rake/test_rake_functional.rb:  Don't assume the binary name of
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 32798)
+++ test/ruby/test_process.rb	(revision 32799)
@@ -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)
@@ -603,9 +601,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
@@ -647,9 +643,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)
@@ -853,7 +847,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=#{$$}"
@@ -882,7 +876,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'")
@@ -914,7 +908,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'")
@@ -952,7 +946,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}
@@ -1256,7 +1250,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/

[前][次][番号順一覧][スレッド一覧]