Skip to content

Commit 2497492

Browse files
committed
fix freeze with toplevel for-testsets which fail
1 parent 2288eab commit 2497492

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

src/testset.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,13 @@ function testset_forloop(mod::Module, isfinal::Bool, pat::Pattern, id::Int64,
562562
if !first_iteration
563563
pop_testset()
564564
push!(arr, finish(ts, $chan))
565+
if ts.exception !== nothing
566+
# ts.exception might be set in finish(...) above
567+
# In this case, we currently don't want to continue with subsequent
568+
# iterations, as is done in Test.
569+
# See also https://github.com/JuliaLang/julia/pull/41715
570+
break
571+
end
565572
# it's 1000 times faster to copy from tmprng rather than calling Random.seed!
566573
copy!(RNG, tmprng)
567574
end
@@ -604,7 +611,7 @@ function testset_forloop(mod::Module, isfinal::Bool, pat::Pattern, id::Int64,
604611
end
605612
finally
606613
# Handle `return` in test body
607-
if !first_iteration
614+
if !first_iteration && ts.exception === nothing
608615
pop_testset()
609616
push!(arr, finish(ts, $chan))
610617
end

test/runtests.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,48 @@ end # Failing
12641264
""")
12651265
end
12661266

1267+
module FailingLoops
1268+
# we test that toplevel testset-for don't make retest unresponsive
1269+
1270+
using ReTest
1271+
1272+
@testset "a$i" for i=1:3
1273+
@test i == 1
1274+
end
1275+
1276+
@testset "b$i" for i=1:3
1277+
@test i == 2
1278+
end
1279+
1280+
@testset "c$i" for i=1:3
1281+
@test i == 3
1282+
end
1283+
1284+
end # FailingLoops
1285+
1286+
@chapter FailingLoops begin
1287+
@test_throws Test.TestSetException retest(FailingLoops, "a")
1288+
# TODO: we check here the behaviour by looking at check marks, we could maybe do better
1289+
check(FailingLoops, "a", dry=true, marks=true, id=false, [], clear=true, output="""
1290+
a1 ✔
1291+
a2 ✘
1292+
a3
1293+
""")
1294+
@test_throws Test.TestSetException retest(FailingLoops, "b")
1295+
check(FailingLoops, "b", dry=true, marks=true, id=false, [], clear=true, output="""
1296+
b1 ✘
1297+
b2
1298+
b3
1299+
""")
1300+
@test_throws Test.TestSetException retest(FailingLoops, "c")
1301+
check(FailingLoops, "c", dry=true, marks=true, id=false, [], clear=true, output="""
1302+
c1 ✘
1303+
c2
1304+
c3
1305+
""")
1306+
end
1307+
1308+
12671309
# * Duplicate ................................................................
12681310

12691311
module Duplicate

0 commit comments

Comments
 (0)