Skip to content

Commit

Permalink
Add test for timeout behaviour.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 25, 2023
1 parent 5311391 commit f4bab19
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,23 @@ def after
expect(state).to be == :timeout
end

it "will timeout while getting from stdin" do
error = nil

reactor.async do |task|
begin
task.with_timeout(0.1) {STDIN.read(1)}
rescue Async::TimeoutError => error
puts "Error: #{error}"
# Ignore.
end
end

reactor.run

expect(error).to be_a(Async::TimeoutError)
end

it "won't timeout if execution completes in time" do
state = nil

Expand Down

0 comments on commit f4bab19

Please sign in to comment.