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

ruby-changes:22058

From: akr <ko1@a...>
Date: Fri, 23 Dec 2011 10:15:47 +0900 (JST)
Subject: [ruby-changes:22058] akr:r34107 (trunk): * test/thread/test_queue.rb (test_thr_kill): show the number of loop

akr	2011-12-23 10:15:35 +0900 (Fri, 23 Dec 2011)

  New Revision: 34107

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

  Log:
    * test/thread/test_queue.rb (test_thr_kill): show the number of loop
      run when the test failed.

  Modified files:
    trunk/ChangeLog
    trunk/test/thread/test_queue.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34106)
+++ ChangeLog	(revision 34107)
@@ -1,3 +1,8 @@
+Fri Dec 23 10:14:47 2011  Tanaka Akira  <akr@f...>
+
+	* test/thread/test_queue.rb (test_thr_kill): show the number of loop
+	  run when the test failed.
+
 Fri Dec 23 09:23:48 2011  Tanaka Akira  <akr@f...>
 
 	* test/test_pty.rb (test_pty_check_default): call PTY.check until
Index: test/thread/test_queue.rb
===================================================================
--- test/thread/test_queue.rb	(revision 34106)
+++ test/thread/test_queue.rb	(revision 34107)
@@ -1,5 +1,6 @@
 require 'test/unit'
 require 'thread'
+require 'tmpdir'
 require_relative '../ruby/envutil'
 
 class TestQueue < Test::Unit::TestCase
@@ -57,18 +58,28 @@
 
   def test_thr_kill
     bug5343 = '[ruby-core:39634]'
-    assert_normal_exit(<<-'_eom', bug5343, {:timeout => 20})
-      require "thread"
-      2000.times do
-        queue = Queue.new
-        r, w = IO.pipe
-        th = Thread.start {
-          queue.push(nil)
-          r.read 1
-        }
-        queue.pop
-        th.kill.join
+    Dir.mktmpdir {|d|
+      timeout = 20
+      total_loop = 2000
+      begin
+        assert_normal_exit(<<-"_eom", bug5343, {:timeout => timeout, :chdir=>d})
+          require "thread"
+          #{total_loop}.times do |i|
+            open("test_thr_kill_count", "w") {|f| f.puts i }
+            queue = Queue.new
+            r, w = IO.pipe
+            th = Thread.start {
+              queue.push(nil)
+              r.read 1
+            }
+            queue.pop
+            th.kill.join
+          end
+        _eom
+      rescue Timeout::Error
+        count = File.read("#{d}/test_thr_kill_count").to_i
+        flunk "only #{count} times looped in #{timeout} seconds.  (should run #{total_loop} times)"
       end
-    _eom
+    }
   end
 end

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

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