Skip to content

Commit 0574881

Browse files
committed
Merge pull request #423 from hfenton/fix_buggy_tests
Fix buggy tests
2 parents c65962c + 5b046c2 commit 0574881

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

spec/concurrent/agent_spec.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -691,36 +691,34 @@ def update(time, old_value, new_value)
691691
it 'removes all actions from the queue when :clear_actions is true' do
692692
latch = Concurrent::CountDownLatch.new
693693
subject = Agent.new(0, error_mode: :fail)
694+
end_latch = Concurrent::CountDownLatch.new
694695

695696
subject.send_via(executor){ latch.wait; raise StandardError }
696-
5.times{ subject.send_via(executor){ nil } }
697-
698-
queue = subject.instance_variable_get(:@queue)
699-
expect(queue.size).to be > 0
697+
subject.send_via(executor){ end_latch.count_down }
700698

701699
latch.count_down
702700
10.times{ break if subject.failed?; sleep(0.1) }
703701

704702
subject.restart(42, clear_actions: true)
705-
expect(queue).to be_empty
703+
result = end_latch.wait(0.1)
704+
expect(result).to be false
706705
end
707706

708-
it 'does not clear the action queue when :clear_actions is false', buggy: true do
707+
it 'does not clear the action queue when :clear_actions is false' do
709708
latch = Concurrent::CountDownLatch.new
709+
end_latch = Concurrent::CountDownLatch.new
710+
710711
subject = Agent.new(0, error_mode: :fail)
711712

712713
subject.send_via(executor){ latch.wait; raise StandardError }
713-
5.times{ subject.send_via(executor){ nil } }
714-
715-
queue = subject.instance_variable_get(:@queue)
716-
size = queue.size
717-
expect(size).to be > 0
714+
subject.send_via(executor){ end_latch.count_down }
718715

719716
latch.count_down
720717
10.times{ break if subject.failed?; sleep(0.1) }
721718

722719
subject.restart(42, clear_actions: false)
723-
expect(queue.size).to eq size-1
720+
result = end_latch.wait(3)
721+
expect(result).to be true
724722
end
725723

726724
it 'does not clear the action queue when :clear_actions is not given' do

spec/concurrent/future_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ def get_ivar_from_args(opts)
8585
Future.execute(executor: executor){ nil }
8686
end
8787

88-
it 'uses the global io executor by default', buggy: true do
89-
expect(Concurrent).to receive(:global_io_executor).and_return(executor)
88+
it 'uses the global io executor by default' do
89+
allow(Concurrent).to receive(:global_io_executor).and_return(executor)
90+
expect(executor).to receive(:post).and_call_original
9091
Future.execute{ nil }
9192
end
9293
end

0 commit comments

Comments
 (0)