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

ruby-changes:40294

From: naruse <ko1@a...>
Date: Fri, 30 Oct 2015 10:58:08 +0900 (JST)
Subject: [ruby-changes:40294] naruse:r52375 (trunk): use spawn's option to shorten the code

naruse	2015-10-30 10:57:57 +0900 (Fri, 30 Oct 2015)

  New Revision: 52375

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

  Log:
    use spawn's option to shorten the code

  Modified files:
    trunk/test/ruby/test_io.rb
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 52374)
+++ test/ruby/test_io.rb	(revision 52375)
@@ -1136,11 +1136,9 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1136
   end
 
   def test_dup_many
-    assert_separately([], <<-'End')
-      if defined?(Process::RLIMIT_NOFILE)
-        lim = Process.getrlimit(Process::RLIMIT_NOFILE)[0]
-        Process.setrlimit(Process::RLIMIT_NOFILE, [lim, 1024].min)
-      end
+    opts = {}
+    opts[:rlimit_nofile] = 1024 if defined?(Process::RLIMIT_NOFILE)
+    assert_separately([], <<-'End', opts)
       a = []
       assert_raise(Errno::EMFILE, Errno::ENFILE, Errno::ENOMEM) do
         loop {a << IO.pipe}
@@ -3066,25 +3064,17 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L3064
     assert_normal_exit %q{
       require "tempfile"
 
-      # try to raise RLIM_NOFILE to >FD_SETSIZE
-      # Unfortunately, ruby export FD_SETSIZE. then we assume it's 1024.
+      # Unfortunately, ruby doesn't export FD_SETSIZE. then we assume it's 1024.
       fd_setsize = 1024
 
-      begin
-        Process.setrlimit(Process::RLIMIT_NOFILE, fd_setsize+10)
-      rescue =>e
-        # Process::RLIMIT_NOFILE couldn't be raised. skip the test
-        exit 0
-      end
-
       tempfiles = []
       (0..fd_setsize+1).map {|i|
         tempfiles << Tempfile.open("test_io_select_with_many_files")
       }
 
       IO.select(tempfiles)
-    }, bug8080, timeout: 30
-  end
+    }, bug8080, timeout: 30, rlimit_nofile: 1024+10
+  end if defined?(Process::RLIMIT_NOFILE)
 
   def test_read_32bit_boundary
     bug8431 = '[ruby-core:55098] [Bug #8431]'

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

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