Skip to content

Commit bf1a4ee

Browse files
committed
Fix thunk tests
`unwrap_nested_exception()` now supports `DTaskFailedException` so we can match against the real exceptions thrown.
1 parent e1ccbfe commit bf1a4ee

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

test/thunk.jl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ end
6969
A = rand(4, 4)
7070
@test fetch(@spawn sum(A; dims=1)) sum(A; dims=1)
7171

72-
@test_throws_unwrap Dagger.DTaskFailedException fetch(@spawn sum(A; fakearg=2))
72+
@test_throws_unwrap MethodError fetch(@spawn sum(A; fakearg=2))
7373

7474
@test fetch(@spawn reduce(+, A; dims=1, init=2.0))
7575
reduce(+, A; dims=1, init=2.0)
@@ -194,7 +194,7 @@ end
194194
a = @spawn error("Test")
195195
wait(a)
196196
@test isready(a)
197-
@test_throws_unwrap Dagger.DTaskFailedException fetch(a)
197+
@test_throws_unwrap ErrorException fetch(a)
198198
b = @spawn 1+2
199199
@test fetch(b) == 3
200200
end
@@ -207,7 +207,6 @@ end
207207
catch err
208208
err
209209
end
210-
ex = Dagger.Sch.unwrap_nested_exception(ex)
211210
ex_str = sprint(io->Base.showerror(io,ex))
212211
@test occursin(r"^DTaskFailedException:", ex_str)
213212
@test occursin("Test", ex_str)
@@ -218,44 +217,43 @@ end
218217
catch err
219218
err
220219
end
221-
ex = Dagger.Sch.unwrap_nested_exception(ex)
222220
ex_str = sprint(io->Base.showerror(io,ex))
223221
@test occursin("Test", ex_str)
224222
@test occursin("Root Task", ex_str)
225223
end
226224
@testset "single dependent" begin
227225
a = @spawn error("Test")
228226
b = @spawn a+2
229-
@test_throws_unwrap Dagger.DTaskFailedException fetch(a)
227+
@test_throws_unwrap ErrorException fetch(a)
230228
end
231229
@testset "multi dependent" begin
232230
a = @spawn error("Test")
233231
b = @spawn a+2
234232
c = @spawn a*2
235-
@test_throws_unwrap Dagger.DTaskFailedException fetch(b)
236-
@test_throws_unwrap Dagger.DTaskFailedException fetch(c)
233+
@test_throws_unwrap ErrorException fetch(b)
234+
@test_throws_unwrap ErrorException fetch(c)
237235
end
238236
@testset "dependent chain" begin
239237
a = @spawn error("Test")
240-
@test_throws_unwrap Dagger.DTaskFailedException fetch(a)
238+
@test_throws_unwrap ErrorException fetch(a)
241239
b = @spawn a+1
242-
@test_throws_unwrap Dagger.DTaskFailedException fetch(b)
240+
@test_throws_unwrap ErrorException fetch(b)
243241
c = @spawn b+2
244-
@test_throws_unwrap Dagger.DTaskFailedException fetch(c)
242+
@test_throws_unwrap ErrorException fetch(c)
245243
end
246244
@testset "single input" begin
247245
a = @spawn 1+1
248246
b = @spawn (a->error("Test"))(a)
249247
@test fetch(a) == 2
250-
@test_throws_unwrap Dagger.DTaskFailedException fetch(b)
248+
@test_throws_unwrap ErrorException fetch(b)
251249
end
252250
@testset "multi input" begin
253251
a = @spawn 1+1
254252
b = @spawn 2*2
255253
c = @spawn ((a,b)->error("Test"))(a,b)
256254
@test fetch(a) == 2
257255
@test fetch(b) == 4
258-
@test_throws_unwrap Dagger.DTaskFailedException fetch(c)
256+
@test_throws_unwrap ErrorException fetch(c)
259257
end
260258
@testset "diamond" begin
261259
a = @spawn 1+1
@@ -265,9 +263,10 @@ end
265263
@test fetch(a) == 2
266264
@test fetch(b) == 3
267265
@test fetch(c) == 4
268-
@test_throws_unwrap Dagger.DTaskFailedException fetch(d)
266+
@test_throws_unwrap ErrorException fetch(d)
269267
end
270268
end
269+
271270
@testset "remote spawn" begin
272271
a = fetch(Distributed.@spawnat 2 Dagger.@spawn 1+2)
273272
@test Dagger.Sch.EAGER_INIT[]
@@ -283,7 +282,7 @@ end
283282
t1 = Dagger.@spawn 1+"fail"
284283
Dagger.@spawn t1+1
285284
end
286-
@test_throws_unwrap Dagger.DTaskFailedException fetch(t2)
285+
@test_throws_unwrap MethodError fetch(t2)
287286
end
288287
@testset "undefined function" begin
289288
# Issues #254, #255

0 commit comments

Comments
 (0)