Skip to content

Commit

Permalink
Dealing with test race conditions while traces are emitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 6, 2024
1 parent 8f120e0 commit 3a97355
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions test/async/reactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright, 2017, by Devin Christensen.

require "async"
require "async/variable"
require "sus/fixtures/async"
require "benchmark/ips"

Expand Down Expand Up @@ -229,14 +230,14 @@
start_time = Time.now

subject.run do |task|
condition = Async::Condition.new
variable = Async::Variable.new

task.with_timeout(duration) do
task.async do
condition.wait
variable.wait
end

condition.signal
variable.resolve

task.yield

Expand Down
6 changes: 3 additions & 3 deletions test/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@
it "can yield back to scheduler" do
state = nil

reactor.async do |task|
reactor.run do |task|
child = task.async do
state = :yielding
Async::Task.yield
state = :yielded
end

# Async::Task.

Fiber.scheduler.resume(child.fiber)
end

reactor.run

expect(state).to be == :yielded
end
end
Expand Down

0 comments on commit 3a97355

Please sign in to comment.