From 7d320993d9bf03a588dda5834246363e477b9449 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 24 Mar 2023 11:45:23 -0400 Subject: [PATCH] Quieter tests (#49093) --- test/ambiguous.jl | 9 +++++---- test/core.jl | 4 ++-- test/deprecation_exec.jl | 4 ++-- test/syntax.jl | 2 +- test/threads_exec.jl | 8 ++++++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/test/ambiguous.jl b/test/ambiguous.jl index 4ab779d76e6f0..67fb16d3b7458 100644 --- a/test/ambiguous.jl +++ b/test/ambiguous.jl @@ -46,8 +46,8 @@ let err = try @test occursin("Possible fix, define\n ambig(::Integer, ::Integer)", errstr) end -ambig_with_bounds(x, ::Int, ::T) where {T<:Integer,S} = 0 -ambig_with_bounds(::Int, x, ::T) where {T<:Integer,S} = 1 +@test_warn "declares type variable S but does not use it" @eval ambig_with_bounds(x, ::Int, ::T) where {T<:Integer,S} = 0 +@test_warn "declares type variable S but does not use it" @eval ambig_with_bounds(::Int, x, ::T) where {T<:Integer,S} = 1 let err = try ambig_with_bounds(1, 2, 3) catch _e_ @@ -385,7 +385,7 @@ f11407(::Dict{K,V}, ::Dict{Any,V}) where {K,V} = 1 f11407(::Dict{K,V}, ::Dict{K,Any}) where {K,V} = 2 @test_throws MethodError f11407(Dict{Any,Any}(), Dict{Any,Any}()) # ambiguous @test f11407(Dict{Any,Int}(), Dict{Any,Int}()) == 1 -f11407(::Dict{Any,Any}, ::Dict{Any,Any}) where {K,V} = 3 +@test_warn "declares type variable V but does not use it" @eval f11407(::Dict{Any,Any}, ::Dict{Any,Any}) where {K,V} = 3 @test f11407(Dict{Any,Any}(), Dict{Any,Any}()) == 3 # issue #12814 @@ -399,8 +399,9 @@ end # issue #43040 module M43040 + using Test struct C end - stripType(::Type{C}) where {T} = C # where {T} is intentionally incorrect + @test_warn "declares type variable T but does not use it" @eval M43040 stripType(::Type{C}) where {T} = C # where {T} is intentionally incorrect end @test isempty(detect_ambiguities(M43040; recursive=true)) diff --git a/test/core.jl b/test/core.jl index 8f8b8c1a28bcd..7b989cfd0759d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -5268,10 +5268,10 @@ end GC.enable(true) # issue #18710 -bad_tvars() where {T} = 1 +@test_warn "declares type variable T but does not use it" @eval bad_tvars() where {T} = 1 @test isa(which(bad_tvars, ()), Method) @test bad_tvars() === 1 -bad_tvars2() where {T} = T +@test_warn "declares type variable T but does not use it" @eval bad_tvars2() where {T} = T @test_throws UndefVarError(:T) bad_tvars2() missing_tvar(::T...) where {T} = T @test_throws UndefVarError(:T) missing_tvar() diff --git a/test/deprecation_exec.jl b/test/deprecation_exec.jl index 4f19f9415ba29..5b465e05f0a12 100644 --- a/test/deprecation_exec.jl +++ b/test/deprecation_exec.jl @@ -116,8 +116,8 @@ begin # @deprecate # test that positional and keyword arguments are forwarded when # there is no explicit type annotation - @test DeprecationTests.old_return_args(1, 2, 3) == ((1, 2, 3),(;)) - @test DeprecationTests.old_return_args(1, 2, 3; a = 4, b = 5) == ((1, 2, 3), (a = 4, b = 5)) + @test_logs (:warn,) @test DeprecationTests.old_return_args(1, 2, 3) == ((1, 2, 3),(;)) + @test_logs (:warn,) @test DeprecationTests.old_return_args(1, 2, 3; a = 4, b = 5) == ((1, 2, 3), (a = 4, b = 5)) end f24658() = depwarn24658() diff --git a/test/syntax.jl b/test/syntax.jl index e60bbd81a04ab..fac3479315c03 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2007,7 +2007,7 @@ end @test Meta.parse("import Base.Foo.:(==).bar") == :(import Base.Foo.==.bar) # issue #33135 -function f33135(x::T) where {C1, T} +@test_warn "declares type variable C1 but does not use it" @eval function f33135(x::T) where {C1, T} let C1 = 1, C2 = 2 C1 end diff --git a/test/threads_exec.jl b/test/threads_exec.jl index 68ba9377cf955..e8a81f7fc2683 100644 --- a/test/threads_exec.jl +++ b/test/threads_exec.jl @@ -27,6 +27,8 @@ end # (expected test duration is about 18-180 seconds) Timer(t -> killjob("KILLING BY THREAD TEST WATCHDOG\n"), 1200) +@testset """threads_exec.jl with JULIA_NUM_THREADS == $(ENV["JULIA_NUM_THREADS"])""" begin + @test Threads.threadid() == 1 @test 1 <= threadpoolsize() <= Threads.maxthreadid() @@ -232,7 +234,7 @@ end # Make sure that eval'ing in a different module doesn't mess up other threads orig_curmodule14726 = @__MODULE__ main_var14726 = 1 -module M14726 +@eval Main module M14726 module_var14726 = 1 end @@ -252,7 +254,7 @@ end @test @__MODULE__() == orig_curmodule14726 end -module M14726_2 +@eval Main module M14726_2 using Test using Base.Threads @threads for i in 1:100 @@ -1067,3 +1069,5 @@ end popfirst!(LOAD_PATH) end end + +end # main testset