summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-23 01:15:35 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-23 01:15:35 +0000
commite89bebdab448f20555a322d84ef42eea531c51cc (patch)
tree8f44668abd801ec895440e218af259f12a7be06e /test
parent8beb0d358782c08d8b529c7ba655b196573328f4 (diff)
* test/thread/test_queue.rb (test_thr_kill): show the number of loop
run when the test failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/thread/test_queue.rb35
1 files changed, 23 insertions, 12 deletions
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index e54decdafc..4f3eff00a0 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -1,5 +1,6 @@
require 'test/unit'
require 'thread'
+require 'tmpdir'
require_relative '../ruby/envutil'
class TestQueue < Test::Unit::TestCase
@@ -57,18 +58,28 @@ class TestQueue < Test::Unit::TestCase
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