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

ruby-changes:23881

From: naruse <ko1@a...>
Date: Wed, 6 Jun 2012 05:11:01 +0900 (JST)
Subject: [ruby-changes:23881] naruse:r35932 (trunk): Split one big test to seven tests.

naruse	2012-06-06 05:10:50 +0900 (Wed, 06 Jun 2012)

  New Revision: 35932

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

  Log:
    Split one big test to seven tests.

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

Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 35931)
+++ test/ruby/test_io.rb	(revision 35932)
@@ -534,10 +534,8 @@
     end
   end
 
-  def test_copy_stream_socket
-    return unless defined? UNIXSocket
+  def test_copy_stream_socket1
     mkcdtmpdir {
-
       content = "foobar"
       File.open("src", "w") {|f| f << content }
 
@@ -547,7 +545,11 @@
         s1.close
         assert_equal(content, s2.read)
       }
+    }
+  end if defined? UNIXSocket
 
+  def test_copy_stream_socket2
+    mkcdtmpdir {
       bigcontent = "abc" * 123456
       File.open("bigsrc", "w") {|f| f << bigcontent }
 
@@ -559,7 +561,14 @@
         result = t.value
         assert_equal(bigcontent, result)
       }
+    }
+  end if defined? UNIXSocket
 
+  def test_copy_stream_socket3
+    mkcdtmpdir {
+      bigcontent = "abc" * 123456
+      File.open("bigsrc", "w") {|f| f << bigcontent }
+
       with_socketpair {|s1, s2|
         t = Thread.new { s2.read }
         ret = IO.copy_stream("bigsrc", s1, 10000)
@@ -568,7 +577,14 @@
         result = t.value
         assert_equal(bigcontent[0,10000], result)
       }
+    }
+  end if defined? UNIXSocket
 
+  def test_copy_stream_socket4
+    mkcdtmpdir {
+      bigcontent = "abc" * 123456
+      File.open("bigsrc", "w") {|f| f << bigcontent }
+
       File.open("bigsrc") {|f|
         assert_equal(0, f.pos)
         with_socketpair {|s1, s2|
@@ -581,7 +597,14 @@
           assert_equal(bigcontent[100..-1], result)
         }
       }
+    }
+  end if defined? UNIXSocket
 
+  def test_copy_stream_socket5
+    mkcdtmpdir {
+      bigcontent = "abc" * 123456
+      File.open("bigsrc", "w") {|f| f << bigcontent }
+
       File.open("bigsrc") {|f|
         assert_equal(bigcontent[0,100], f.read(100))
         assert_equal(100, f.pos)
@@ -595,54 +618,64 @@
           assert_equal(bigcontent[100..-1], result)
         }
       }
+    }
+  end if defined? UNIXSocket
 
+  def test_copy_stream_socket6
+    mkcdtmpdir {
       megacontent = "abc" * 1234567
       File.open("megasrc", "w") {|f| f << megacontent }
 
-      if have_nonblock?
-        with_socketpair {|s1, s2|
+      with_socketpair {|s1, s2|
+        begin
+          s1.nonblock = true
+        rescue Errno::EBADF
+          skip "nonblocking IO for pipe is not implemented"
+        end
+        t = Thread.new { s2.read }
+        ret = IO.copy_stream("megasrc", s1)
+        assert_equal(megacontent.bytesize, ret)
+        s1.close
+        result = t.value
+        assert_equal(megacontent, result)
+      }
+    }
+  end if defined? UNIXSocket
+
+  def test_copy_stream_socket7
+    mkcdtmpdir {
+      megacontent = "abc" * 1234567
+      File.open("megasrc", "w") {|f| f << megacontent }
+
+      with_socketpair {|s1, s2|
+        begin
+          s1.nonblock = true
+        rescue Errno::EBADF
+          skip "nonblocking IO for pipe is not implemented"
+        end
+        trapping_usr1 do
+          nr = 30
           begin
-            s1.nonblock = true
-          rescue Errno::EBADF
-            skip "nonblocking IO for pipe is not implemented"
-          end
-          t = Thread.new { s2.read }
-          ret = IO.copy_stream("megasrc", s1)
-          assert_equal(megacontent.bytesize, ret)
-          s1.close
-          result = t.value
-          assert_equal(megacontent, result)
-        }
-        with_socketpair {|s1, s2|
-          begin
-            s1.nonblock = true
-          rescue Errno::EBADF
-            skip "nonblocking IO for pipe is not implemented"
-          end
-          trapping_usr1 do
-            nr = 30
-            begin
-              pid = fork do
-                s1.close
-                IO.select([s2])
-                Process.kill(:USR1, Process.ppid)
-                s2.read
-              end
-              s2.close
-              nr.times do
-                assert_equal megacontent.bytesize, IO.copy_stream("megasrc", s1)
-              end
-              assert_equal(1, @usr1_rcvd)
-            ensure
+            pid = fork do
               s1.close
-              _, status = Process.waitpid2(pid) if pid
+              IO.select([s2])
+              Process.kill(:USR1, Process.ppid)
+              s2.read
             end
-            assert status.success?, status.inspect
+            s2.close
+            nr.times do
+              assert_equal megacontent.bytesize, IO.copy_stream("megasrc", s1)
+            end
+            assert_equal(1, @usr1_rcvd)
+          ensure
+            s1.close
+            _, status = Process.waitpid2(pid) if pid
           end
-        }
-      end
+          assert status.success?, status.inspect
+        end
+      }
     }
-  end
+  end if defined? UNIXSocket and IO.method_defined?("nonblock=")
 
   def test_copy_stream_strio
     src = StringIO.new("abcd")

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

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