Skip to content

Commit

Permalink
fix freeze with toplevel for-testsets which fail
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Jul 28, 2021
1 parent 2288eab commit 2497492
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/testset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,13 @@ function testset_forloop(mod::Module, isfinal::Bool, pat::Pattern, id::Int64,
if !first_iteration
pop_testset()
push!(arr, finish(ts, $chan))
if ts.exception !== nothing
# ts.exception might be set in finish(...) above
# In this case, we currently don't want to continue with subsequent
# iterations, as is done in Test.
# See also https://github.com/JuliaLang/julia/pull/41715
break
end
# it's 1000 times faster to copy from tmprng rather than calling Random.seed!
copy!(RNG, tmprng)
end
Expand Down Expand Up @@ -604,7 +611,7 @@ function testset_forloop(mod::Module, isfinal::Bool, pat::Pattern, id::Int64,
end
finally
# Handle `return` in test body
if !first_iteration
if !first_iteration && ts.exception === nothing
pop_testset()
push!(arr, finish(ts, $chan))
end
Expand Down
42 changes: 42 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,48 @@ end # Failing
""")
end

module FailingLoops
# we test that toplevel testset-for don't make retest unresponsive

using ReTest

@testset "a$i" for i=1:3
@test i == 1
end

@testset "b$i" for i=1:3
@test i == 2
end

@testset "c$i" for i=1:3
@test i == 3
end

end # FailingLoops

@chapter FailingLoops begin
@test_throws Test.TestSetException retest(FailingLoops, "a")
# TODO: we check here the behaviour by looking at check marks, we could maybe do better
check(FailingLoops, "a", dry=true, marks=true, id=false, [], clear=true, output="""
a1 ✔
a2 ✘
a3
""")
@test_throws Test.TestSetException retest(FailingLoops, "b")
check(FailingLoops, "b", dry=true, marks=true, id=false, [], clear=true, output="""
b1 ✘
b2
b3
""")
@test_throws Test.TestSetException retest(FailingLoops, "c")
check(FailingLoops, "c", dry=true, marks=true, id=false, [], clear=true, output="""
c1 ✘
c2
c3
""")
end


# * Duplicate ................................................................

module Duplicate
Expand Down

0 comments on commit 2497492

Please sign in to comment.