Skip to content

Commit 8f22661

Browse files
committed
Simpler show
1 parent 9ceeb97 commit 8f22661

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

DifferentiationInterface/test/Back/Enzyme/hints.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ using Test
88
x -> sum(copyto!(cache, x))
99
end
1010

11-
msg = try
11+
e = nothing
12+
try
1213
gradient(f, AutoEnzyme(), [1.0])
1314
catch e
14-
buf = IOBuffer()
15-
showerror(buf, e)
16-
String(take!(buf))
1715
end
16+
msg = sprint(showerror, e)
1817
@test occursin("AutoEnzyme", msg)
1918
@test occursin("function_annotation", msg)
2019
@test occursin("ADTypes", msg)
@@ -34,7 +33,8 @@ end
3433
return [g(active_var, constant_var, cond), g(active_var, constant_var, cond)]
3534
end
3635

37-
msg = try
36+
e = nothing
37+
try
3838
pushforward(
3939
h,
4040
AutoEnzyme(; mode=Enzyme.Forward),
@@ -44,10 +44,8 @@ end
4444
Constant(true),
4545
)
4646
catch e
47-
buf = IOBuffer()
48-
showerror(buf, e)
49-
String(take!(buf))
5047
end
48+
msg = sprint(showerror, e)
5149
@test occursin("AutoEnzyme", msg)
5250
@test occursin("mode", msg)
5351
@test occursin("set_runtime_activity", msg)

DifferentiationInterface/test/Core/Internals/hints.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import DifferentiationInterface as DI
44
using Test
55

66
@testset "Missing backend" begin
7-
msg = try
7+
e = nothing
8+
try
89
gradient(sum, AutoZygote(), [1.0])
910
catch e
10-
buf = IOBuffer()
11-
showerror(buf, e)
12-
String(take!(buf))
1311
end
12+
msg = sprint(showerror, e)
1413
@test occursin("import Zygote", msg)
1514
end

0 commit comments

Comments
 (0)