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

ruby-changes:27365

From: nobu <ko1@a...>
Date: Sat, 23 Feb 2013 12:34:16 +0900 (JST)
Subject: [ruby-changes:27365] nobu:r39417 (trunk): test_process.rb: fix test

nobu	2013-02-23 12:34:04 +0900 (Sat, 23 Feb 2013)

  New Revision: 39417

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

  Log:
    test_process.rb: fix test
    
    * test/ruby/test_process.rb (assert_fail_too_long_path): get rid of
      syntax error on sh, increase command line size until it exceeds the
      limit.  [Bug #7904]

  Modified files:
    trunk/test/ruby/test_process.rb

Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 39416)
+++ test/ruby/test_process.rb	(revision 39417)
@@ -1380,24 +1380,34 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1380
 
   def test_spawn_too_long_path
     bug4314 = '[ruby-core:34842]'
-    assert_fail_too_long_path("a", bug4314)
+    assert_fail_too_long_path(%w"echo", bug4314)
   end
 
   def test_aspawn_too_long_path
     bug4315 = '[ruby-core:34833]'
-    assert_fail_too_long_path("a|", bug4315)
+    assert_fail_too_long_path(%w"echo |", bug4315)
   end
 
-  def assert_fail_too_long_path(cmd, mesg)
-    size = 1_000_000 / cmd.size
+  def assert_fail_too_long_path((cmd, sep), mesg)
+    sep ||= ""
+    min = 1_000 / (cmd.size + sep.size)
+    cmds = Array.new(min, cmd)
     exs = [Errno::ENOENT]
     exs << Errno::E2BIG if defined?(Errno::E2BIG)
     EnvUtil.suppress_warning do
       assert_raise(*exs, mesg) do
         begin
-          Process.spawn(cmd * size)
+          loop do
+            Process.spawn(cmds.join(sep), [STDOUT, STDERR]=>:close)
+            min = [cmds.size, min].max
+            cmds *= 100
+          end
         rescue NoMemoryError
-          raise if (size /= 2) < 250
+          size = cmds.size
+          raise if min >= size - 1
+          min = [min, size /= 2].max
+          cmds[size..-1] = []
+          raise if size < 250
           retry
         end
       end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

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