From 90a9f37da4bfae48175f19d6ccef979697a2acf1 Mon Sep 17 00:00:00 2001 From: Marc Siegel Date: Thu, 26 Dec 2013 13:51:03 -0500 Subject: [PATCH] Disable test on 1.8.7, since workaround is to allow blocking on that version --- spec/process_shared/semaphore_spec.rb | 50 ++++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/spec/process_shared/semaphore_spec.rb b/spec/process_shared/semaphore_spec.rb index 8f12f01..a0a844c 100644 --- a/spec/process_shared/semaphore_spec.rb +++ b/spec/process_shared/semaphore_spec.rb @@ -158,35 +158,37 @@ module ProcessShared end end - it 'allows other threads in a process to continue while waiting' do - start = Time.now.to_f - sem = Semaphore.new - was_set = false - t2 = nil + unless RUBY_VERSION == '1.8.7' + it 'allows other threads in a process to continue while waiting' do + start = Time.now.to_f + sem = Semaphore.new + was_set = false + t2 = nil - sem.synchronize do - t1 = Thread.new do - # give t2 a chance to wait on the lock, then set the flag - sleep 0.01 - was_set = true - end - - t2 = Thread.new do - begin - sem.try_wait(10.0) - rescue Errno::ETIMEDOUT - # success + sem.synchronize do + t1 = Thread.new do + # give t2 a chance to wait on the lock, then set the flag + sleep 0.01 + was_set = true end + + t2 = Thread.new do + begin + sem.try_wait(10.0) + rescue Errno::ETIMEDOUT + # success + end + end + + # t1 should set the flag and die while t2 is still waiting on the lock + t1.join end - # t1 should set the flag and die while t2 is still waiting on the lock - t1.join + was_set.must_equal true + (Time.now.to_f - start).must be_lt(0.1) + + t2.join end - - was_set.must_equal true - (Time.now.to_f - start).must be_lt(0.1) - - t2.join end end end