From e10c2b65f8fd4f53e815fd17f03a84a78a92270f Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Wed, 11 Nov 2020 23:13:26 -0500 Subject: [PATCH] Fix `make test-Test` 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. --- stdlib/Test/test/nothrow_testset.jl | 6 ++++ stdlib/Test/test/runtests.jl | 45 ++++++++++++++--------------- 2 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 stdlib/Test/test/nothrow_testset.jl diff --git a/stdlib/Test/test/nothrow_testset.jl b/stdlib/Test/test/nothrow_testset.jl new file mode 100644 index 0000000000000..73811b9702346 --- /dev/null +++ b/stdlib/Test/test/nothrow_testset.jl @@ -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 diff --git a/stdlib/Test/test/runtests.jl b/stdlib/Test/test/runtests.jl index e4c0c77380ca4..bb58168599519 100644 --- a/stdlib/Test/test/runtests.jl +++ b/stdlib/Test/test/runtests.jl @@ -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() @@ -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