I don’t understand how to use @test_warn. MWE of my problem is below.
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.0.0 (2018-08-08)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Test
julia> function foo2(x)
@warn "you have been warned"
x
end
foo2 (generic function with 1 method)
julia> @test_warn "you have been warned" foo2(3)
┌ Warning: you have been warned
└ @ Main REPL[2]:2
Test Failed at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Test\src\Test.jl:609
Expression: contains_warn(read(fname, String), $(Expr(:escape, "you have been warned")))
ERROR: There was an error during testing
julia> @test_warn (x)->begin;println("got:",x,":");true;end foo2(3)
┌ Warning: you have been warned
└ @ Main REPL[2]:2
got::
3
why is then @test_warn not deprecated?
I’ve just run into the same problem:
julia> function foo(x)
@warn "you have been warned"
x
end
julia> @test_warn "you have been warned" foo(2)
┌ Warning: you have been warned
└ @ Main REPL[27]:2
Test Failed at /build/julia/src/julia/usr/share/julia/stdlib/v1.0/Test/src/Test.jl:609
Expression: contains_warn(read(fname, String), $(Expr(:escape, "you have been warned")))
ERROR: There was an error during testing
julia> @test_logs (:warn, "you have been warned") foo(2)
2