8000 Test `warn` rather than ignoring it - fix various tests. · socketry/async@fe19601 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe19601

Browse files
committed
Test warn rather than ignoring it - fix various tests.
1 parent 7bb3193 commit fe19601

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

config/sus.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@
55

66
require "covered/sus"
77
include Covered::Sus
8-
9-
ENV["CONSOLE_LEVEL"] ||= "fatal"

test/async/task.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@
126126
reactor.run do
127127
expect do
128128
reactor.async do |task|
129+
expect(task).to receive(:warn).and_return(nil)
130+
129131
raise "boom"
130132
end.wait
131133
end.to raise_exception(RuntimeError, message: be =~ /boom/)
@@ -156,6 +158,8 @@
156158

157159
expect do
158160
task = reactor.async do |task|
161+
expect(task).to receive(:warn).and_return(nil)
162+
159163
raise "boom"
160164
end
161165
end.not.to raise_exception
@@ -624,6 +628,10 @@ def sleep_forever
624628

625629
it "contains useful backtrace" do
626630
task = Async do |task|
631+
expect(task).to receive(:warn).with_options(have_keys(
632+
exception: be_a(Async::TimeoutError),
633+
)).and_return(nil)
634+
627635
task.with_timeout(0.001) do
628636
sleep_forever
629637
end
@@ -686,6 +694,8 @@ def sleep_forever
686694

687695
reactor.run do
688696
error_task = reactor.async do |task|
697+
expect(task).to receive(:warn).and_return(nil)
698+
689699
raise RuntimeError, "brain not provided"
690700
end
691701

@@ -726,7 +736,9 @@ def sleep_forever
726736

727737
with "#result" do
728738
it "does not raise exception" do
729-
task = reactor.async do
739+
task = reactor.async do |task|
740+
expect(task).to receive(:warn).and_return(nil)
741+
730742
raise "The space time converter has failed."
731743
end
732744

@@ -746,7 +758,6 @@ def sleep_forever
746758

747759
expect(task.result).to be_nil
748760

749-
Console.debug(self) {"Stopping task..."}
750761
task.stop
751762

752763
expect(task.result).to be_nil

test/async/waiter.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
end
3636

3737
it "can wait for tasks even when exceptions occur" do
38-
waiter.async do
38+
waiter.async do |task|
39+
expect(task).to receive(:warn).with_options(have_keys(
40+
exception: be_a(RuntimeError),
41+
)).and_return(nil)
42+
3943
raise "Something went wrong"
4044
end
4145

test/async/wrapper.rb

Expand all lines: test/async/wrapper.rb
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,6 @@
5252
it "can wait to be writable" do
5353
expect(input.wait_writable).to be_truthy
5454
end
55-
56-
it "can be cancelled while waiting to be readable" do
57-
task = reactor.async do
58-
input.wait_readable
59-
end
60-
61-
output.close
62-
63-
expect do
64-
task.wait
65-
end.to raise_exception(IOError)
66-
end
6755
end
6856

6957
with "#wait_priority" do

0 commit comments

Comments
 (0)
0