Skip to content

Commit

Permalink
Test warn rather than ignoring it - fix various tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 8, 2024
1 parent 7bb3193 commit fe19601
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 0 additions & 2 deletions config/sus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@

require "covered/sus"
include Covered::Sus

ENV["CONSOLE_LEVEL"] ||= "fatal"
15 changes: 13 additions & 2 deletions test/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
reactor.run do
expect do
reactor.async do |task|
expect(task).to receive(:warn).and_return(nil)

raise "boom"
end.wait
end.to raise_exception(RuntimeError, message: be =~ /boom/)
Expand Down Expand Up @@ -156,6 +158,8 @@

expect do
task = reactor.async do |task|
expect(task).to receive(:warn).and_return(nil)

raise "boom"
end
end.not.to raise_exception
Expand Down Expand Up @@ -624,6 +628,10 @@ def sleep_forever

it "contains useful backtrace" do
task = Async do |task|
expect(task).to receive(:warn).with_options(have_keys(
exception: be_a(Async::TimeoutError),
)).and_return(nil)

task.with_timeout(0.001) do
sleep_forever
end
Expand Down Expand Up @@ -686,6 +694,8 @@ def sleep_forever

reactor.run do
error_task = reactor.async do |task|
expect(task).to receive(:warn).and_return(nil)

raise RuntimeError, "brain not provided"
end

Expand Down Expand Up @@ -726,7 +736,9 @@ def sleep_forever

with "#result" do
it "does not raise exception" do
task = reactor.async do
task = reactor.async do |task|
expect(task).to receive(:warn).and_return(nil)

raise "The space time converter has failed."
end

Expand All @@ -746,7 +758,6 @@ def sleep_forever

expect(task.result).to be_nil

Console.debug(self) {"Stopping task..."}
task.stop

expect(task.result).to be_nil
Expand Down
6 changes: 5 additions & 1 deletion test/async/waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
end

it "can wait for tasks even when exceptions occur" do
waiter.async do
waiter.async do |task|
expect(task).to receive(:warn).with_options(have_keys(
exception: be_a(RuntimeError),
)).and_return(nil)

raise "Something went wrong"
end

Expand Down
12 changes: 0 additions & 12 deletions test/async/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@
it "can wait to be writable" do
expect(input.wait_writable).to be_truthy
end

it "can be cancelled while waiting to be readable" do
task = reactor.async do
input.wait_readable
end

output.close

expect do
task.wait
end.to raise_exception(IOError)
end
end

with "#wait_priority" do
Expand Down

0 comments on commit fe19601

Please sign in to comment.