Skip to content

Commit

Permalink
Fix make test-Test (JuliaLang#38406)
Browse files Browse the repository at this point in the history
This testset would fail unless `--depwarn=yes` was set
(as it is in process 1). Just run it in its own process
that has the commandline flag set appropriately.
  • Loading branch information
Keno committed Nov 12, 2020
1 parent 93fb785 commit e0e3921
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
6 changes: 6 additions & 0 deletions stdlib/Test/test/nothrow_testset.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mutable struct NoThrowTestSet <: Test.AbstractTestSet
results::Vector
NoThrowTestSet(desc) = new([])
end
Test.record(ts::NoThrowTestSet, t::Test.Result) = (push!(ts.results, t); t)
Test.finish(ts::NoThrowTestSet) = ts.results
45 changes: 21 additions & 24 deletions stdlib/Test/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,8 @@ end
"Thrown: ErrorException")
end
# Test printing of Fail results
mutable struct NoThrowTestSet <: Test.AbstractTestSet
results::Vector
NoThrowTestSet(desc) = new([])
end
Test.record(ts::NoThrowTestSet, t::Test.Result) = (push!(ts.results, t); t)
Test.finish(ts::NoThrowTestSet) = ts.results
include("nothrow_testset.jl")

let fails = @testset NoThrowTestSet begin
# 1 - Fail - wrong exception
@test_throws OverflowError error()
Expand Down Expand Up @@ -797,29 +793,30 @@ end
@test startswith(fails[4].value, "ErrorException")
end

function newfunc()
42
end
@deprecate oldfunc newfunc
let code = quote
function newfunc()
42
end
@deprecate oldfunc newfunc

@testset "@test_deprecated" begin
@test_deprecated oldfunc()
@testset "@test_deprecated" begin
@test_deprecated oldfunc()
@test Base.JLOptions().depwarn == 1

# Expression passthrough
if Base.JLOptions().depwarn != 2
@test (@test_deprecated oldfunc()) == 42
@test (@test_deprecated oldfunc()) == 42

fails = @testset NoThrowTestSet "check that @test_deprecated detects bad input" begin
@test_deprecated newfunc()
@test_deprecated r"Not found in message" oldfunc()
fails = @testset NoThrowTestSet "check that @test_deprecated detects bad input" begin
@test_deprecated newfunc()
@test_deprecated r"Not found in message" oldfunc()
end
@test length(fails) == 2
@test fails[1] isa Test.LogTestFailure
@test fails[2] isa Test.LogTestFailure
end
@test length(fails) == 2
@test fails[1] isa Test.LogTestFailure
@test fails[2] isa Test.LogTestFailure
else
@warn """Omitting `@test_deprecated` tests which can't yet
be tested in --depwarn=error mode"""
end
incl = "include($(repr(joinpath(@__DIR__, "nothrow_testset.jl"))))"
cmd = `$(Base.julia_cmd()) --startup-file=no --depwarn=yes -e 'using Test' -e $incl -e $code`
@test success(pipeline(cmd))
end

@testset "@testset preserves GLOBAL_RNG's state, and re-seeds it" begin
Expand Down

0 comments on commit e0e3921

Please sign in to comment.