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

Fix a bug with break/continue/return in at-testset begin end #36046

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
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: 4 additions & 2 deletions stdlib/Test/src/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ function testset_beginend(args, tests, source)
# action (such as reporting the results)
ex = quote
_check_testset($testsettype, $(QuoteNode(testsettype.args[1])))
local ret
local ts = $(testsettype)($desc; $options...)
push_testset(ts)
# we reproduce the logic of guardseed, but this function
Expand All @@ -1120,9 +1121,10 @@ function testset_beginend(args, tests, source)
record(ts, Error(:nontest_error, Expr(:tuple), err, Base.catch_stack(), $(QuoteNode(source))))
finally
copy!(RNG, oldrng)
pop_testset()
ret = finish(ts)
end
pop_testset()
finish(ts)
ret
end
# preserve outer location if possible
if tests isa Expr && tests.head === :block && !isempty(tests.args) && tests.args[1] isa LineNumberNode
Expand Down
11 changes: 11 additions & 0 deletions stdlib/Test/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -919,3 +919,14 @@ end
# Issue 20620
@test @inferred(.![true, false]) == [false, true]
@test @inferred([3, 4] .- [1, 2] .+ [-2, -2]) == [0, 0]

@testset "push/pop_testset invariance (Issue 32937)" begin
io = IOBuffer()
path = joinpath(@__DIR__(), "test_pop_testset_exec.jl")
cmd = `$(Base.julia_cmd()) $path`
ok = !success(pipeline(cmd; stdout = io, stderr = io))
if !ok
@error "push/pop_testset invariance test failed" cmd Text(String(take!(io)))
end
@test ok
end
6 changes: 6 additions & 0 deletions stdlib/Test/test/test_pop_testset_exec.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Test

@testset begin
@test false
return
end