We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef973e7 commit 8f33e35Copy full SHA for 8f33e35
1 file changed
test/async/idler.rb
@@ -14,9 +14,16 @@
14
15
it "can schedule tasks up to the desired load" do
16
expect(Fiber.scheduler.load).to be < 0.1
17
+ slept = Async::Promise.new
18
+
19
+ mock(idler) do |mock|
20
+ mock.after(:sleep) do
21
+ slept.resolve(Fiber.scheduler.load)
22
+ end
23
24
25
# Generate the load:
- Async do
26
+ task = Async do
27
while true
28
idler.async do
29
@@ -26,12 +33,9 @@
33
end
34
35
- # This test must be longer than the idle calculation window (1s)...
30
- sleep 2.0
31
-
32
- # Verify that the load is within the desired range:
- # Allow generous tolerance for scheduling variations on slow CI
- expect(Fiber.scheduler.load).to be_within(0.35).of(0.5)
36
+ expect(slept.wait).to be >= 0.5
37
+ ensure
38
+ task.stop
39
40
41
it_behaves_like Async::ChainableAsync
0 commit comments