Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@testset for: avoid calling finish twice when it errors #41715

Merged
merged 2 commits into from
May 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion stdlib/Test/src/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,10 @@ function testset_forloop(args, testloop, source)
# they can be handled properly by `finally` lowering.
if !first_iteration
pop_testset()
finish_errored = true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

Suggested change
finish_errored = true
finish_threw = true

is more precise?

push!(arr, finish(ts))
finish_errored = false

# it's 1000 times faster to copy from tmprng rather than calling Random.seed!
copy!(RNG, tmprng)

Expand All @@ -1447,6 +1450,7 @@ function testset_forloop(args, testloop, source)
local arr = Vector{Any}()
local first_iteration = true
local ts
local finish_errored = false
local RNG = default_rng()
local oldrng = copy(RNG)
local oldseed = Random.GLOBAL_SEED
Expand All @@ -1458,7 +1462,7 @@ function testset_forloop(args, testloop, source)
end
finally
# Handle `return` in test body
if !first_iteration
if !first_iteration && !finish_errored
pop_testset()
push!(arr, finish(ts))
end
Expand Down