Skip to content

Commit

Permalink
add test for timeout while getting from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
emiltin committed Aug 9, 2023
1 parent 7773705 commit abb8330
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,22 @@ 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.gets }
rescue StandardError => e
error = e
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 abb8330

Please sign in to comment.