Skip to content

Commit 4e340ed

Browse files
authored
Flaky test fix: allow ThreadPool to shutdown before asserting completed_task_count (#1098)
1 parent 4dc8de3 commit 4e340ed

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

spec/concurrent/executor/thread_pool_shared.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,15 @@
8686
it 'returns zero on creation' do
8787
expect(subject.completed_task_count).to eq 0
8888
end
89-
90-
unless Concurrent.on_jruby?
91-
92-
it 'returns the approximate number of tasks that have been completed thus far' do
93-
5.times{ subject.post{ raise StandardError } }
94-
5.times{ subject.post{ nil } }
95-
subject.post { latch.count_down }
96-
latch.wait(1)
97-
expect(subject.completed_task_count).to be > 0
98-
end
89+
90+
it 'returns the approximate number of tasks that have been completed thus far' do
91+
5.times{ subject.post{ raise StandardError } }
92+
5.times{ subject.post{ nil } }
93+
subject.post { latch.count_down }
94+
latch.wait(1)
95+
subject.shutdown
96+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
97+
expect(subject.completed_task_count).to be > 0
9998
end
10099
end
101100

0 commit comments

Comments
 (0)