Skip to content

Commit 483fc31

Browse files
committed
Addressed more intermittently failing specs.
1 parent 420440b commit 483fc31

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

spec/concurrent/executor/global_thread_pool_shared.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
latch = Concurrent::CountDownLatch.new(1)
1919
expected = nil
2020
subject.post(1, 2, 3) do |a, b, c|
21-
expected = [a, b, a]
21+
expected = [a, b, c]
2222
latch.count_down
2323
end
2424
latch.wait(0.2)

spec/concurrent/executor/thread_pool_shared.rb

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,12 @@
1212

1313
context '#post' do
1414

15-
it 'raises an exception if no block is given' do
16-
lambda {
17-
subject.post
18-
}.should raise_error(ArgumentError)
19-
end
20-
21-
it 'returns true when the block is added to the queue' do
22-
subject.post{ nil }.should be_true
23-
end
24-
25-
it 'calls the block with the given arguments' do
26-
@expected = nil
27-
subject.post(1, 2, 3) do |a, b, c|
28-
@expected = a + b + c
29-
end
30-
sleep(0.1)
31-
@expected.should eq 6
32-
end
33-
3415
it 'rejects the block while shutting down' do
16+
latch = Concurrent::CountDownLatch.new(1)
3517
subject.post{ sleep(1) }
3618
subject.shutdown
37-
@expected = nil
38-
subject.post(1, 2, 3) do |a, b, c|
39-
@expected = a + b + c
40-
end
41-
@expected.should be_nil
19+
subject.post{ latch.count_down }
20+
latch.wait(0.1).should be_false
4221
end
4322

4423
it 'returns false while shutting down' do
@@ -49,11 +28,10 @@
4928

5029
it 'rejects the block once shutdown' do
5130
subject.shutdown
52-
@expected = nil
53-
subject.post(1, 2, 3) do |a, b, c|
54-
@expected = a + b + c
55-
end
56-
@expected.should be_nil
31+
latch = Concurrent::CountDownLatch.new(1)
32+
subject.post{ sleep(1) }
33+
subject.post{ latch.count_down }
34+
latch.wait(0.1).should be_false
5735
end
5836

5937
it 'returns false once shutdown' do
@@ -62,13 +40,6 @@
6240
sleep(0.1)
6341
subject.post{ nil }.should be_false
6442
end
65-
66-
it 'aliases #<<' do
67-
@expected = false
68-
subject << proc { @expected = true }
69-
sleep(0.1)
70-
@expected.should be_true
71-
end
7243
end
7344

7445
context '#running?' do

0 commit comments

Comments
 (0)