ruby-changes:56288
From: Nobuyoshi <ko1@a...>
Date: Sun, 30 Jun 2019 18:53:50 +0900 (JST)
Subject: [ruby-changes:56288] Nobuyoshi Nakada: b43d6e5709 (trunk): Fixed non-working test
https://git.ruby-lang.org/ruby.git/commit/?id=b43d6e5709 From b43d6e570980a4f5d6f4c20de29024dc5df93472 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 30 Jun 2019 09:46:21 +0900 Subject: Fixed non-working test diff --git a/test/ruby/test_thread_queue.rb b/test/ruby/test_thread_queue.rb index ccd51b7..b5ee70d 100644 --- a/test/ruby/test_thread_queue.rb +++ b/test/ruby/test_thread_queue.rb @@ -346,21 +346,25 @@ class TestThreadQueue < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread_queue.rb#L346 # make sure that shutdown state is handled properly by empty? for the non-blocking case def test_empty_non_blocking - return q = SizedQueue.new 3 3.times{|i| q << i} # these all block cos the queue is full - prod_threads = 4.times.map{|i| Thread.new{q << 3+i}} - sleep 0.01 until prod_threads.all?{|thr| thr.status == 'sleep'} - q.close + prod_threads = 4.times.map {|i| + Thread.new { + Thread.current.report_on_exception = false + q << 3+i + } + } + sleep 0.01 until prod_threads.all?{|thr| thr.stop?} items = [] # sometimes empty? is false but pop will raise ThreadError('empty'), # meaning a value is not immediately available but will be soon. - until q.empty? - items << q.pop(non_block=true) rescue nil + until q.empty? and !prod_threads.any?(&:alive?) + items << q.pop(true) rescue nil end + assert_join_threads(prod_threads) items.compact! assert_equal 7.times.to_a, items.sort -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/