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

ruby-changes:26882

From: nobu <ko1@a...>
Date: Fri, 25 Jan 2013 10:39:26 +0900 (JST)
Subject: [ruby-changes:26882] nobu:r38934 (trunk): test_process.rb: reduce command string size

nobu	2013-01-25 10:37:34 +0900 (Fri, 25 Jan 2013)

  New Revision: 38934

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

  Log:
    test_process.rb: reduce command string size
    
    * test/ruby/test_process.rb (test_spawn_too_long_path),
      (test_aspawn_too_long_path): reduce command string size until
      intended exception occurs.  [ruby-core:51592] [Bug #7721]

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

Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 38933)
+++ test/ruby/test_process.rb	(revision 38934)
@@ -1377,20 +1377,30 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1377
     end
   end if File.executable?("/bin/sh")
 
-  def test_too_long_path
+  def test_spawn_too_long_path
     bug4314 = '[ruby-core:34842]'
-    exs = [Errno::ENOENT]
-    exs << Errno::E2BIG if defined?(Errno::E2BIG)
-    EnvUtil.suppress_warning do
-      assert_raise(*exs, bug4314) {Process.spawn("a" * 10_000_000)}
-    end
+    assert_fail_too_long_path(bug4314)
   end
 
-  def test_too_long_path2
+  def test_aspawn_too_long_path
     bug4315 = '[ruby-core:34833]'
+    assert_fail_too_long_path(bug4315)
+  end
+
+  def assert_fail_too_long_path(cmd, mesg = nil)
+    size = 1_000_000 / cmd.size
     exs = [Errno::ENOENT]
     exs << Errno::E2BIG if defined?(Errno::E2BIG)
-    assert_raise(*exs, bug4315) {Process.spawn('"a"|'*10_000_000)}
+    EnvUtil.suppress_warning do
+      assert_raise(*exs, mesg) do
+        begin
+          Process.spawn(cmd * size)
+        rescue NoMemoryError
+          raise if (size /= 2) < 250
+          retry
+        end
+      end
+    end
   end
 
   def test_system_sigpipe

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

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