diff --git a/src/core.jl b/src/core.jl index eb45c8e..cea3bf7 100644 --- a/src/core.jl +++ b/src/core.jl @@ -25,6 +25,10 @@ See also [`Run.test`](@ref) and [`Run.docs`](@ref). - `check_bounds::Union{Nothing, Bool} = nothing`: Control `--check-bounds` option. `nothing` means to inherit the option specified for the current Julia session. +- `depwarn::Union{Nothing, Bool, Symbol} = nothing`: Use `--depwarn` setting + of the current process if `nothing` (default). Set `--depwarn=yes` if `true` + or `--depwarn=no` if `false`. A symbol value is passed as `--depwarn` value. + So, passing `:error` sets `--depwarn=error`. - `xfail::bool = false`: If failure is expected. - `exitcodes::AbstractVector{<:Integer} = xfail ? [1] : [0]`: List of allowed exit codes. @@ -37,7 +41,7 @@ script Run `\$path/runtests.jl` after activating `\$path/Project.toml`. It simply calls [`Run.script`](@ref) with default keyword arguments -`code_coverage = true` and `check_bounds = true`. +`code_coverage = true`, `check_bounds = true`, and `depwarn = true`. `path` can also be a path to a script file. @@ -195,6 +199,7 @@ function _default_julia_options(; compiled_modules::Union{Bool, Nothing} = nothing, code_coverage::Bool = false, check_bounds::Union{Bool, Nothing} = nothing, + depwarn::Union{Bool, Symbol, Nothing} = nothing, kwargs... ) if julia_options !== nothing @@ -204,11 +209,14 @@ function _default_julia_options(; jlopt = `` # = julia_options addyn(cmd, ::Nothing) = jlopt addyn(cmd, yn::Bool) = `$jlopt $cmd=$(yesno(yn))` + addopt(cmd, yn::Union{Bool, Nothing}) = addyn(cmd, yn) + addopt(cmd, value::Symbol) = `$jlopt $cmd=$value` jlopt = addyn("--inline", inline) jlopt = addyn("--compiled-modules", compiled_modules) jlopt = addyn("--check-bounds", check_bounds) jlopt = code_coverage ? `$jlopt --code-coverage=user` : jlopt + jlopt = addopt("--depwarn", depwarn) jlopt = fast ? `$jlopt --compile=min` : jlopt return jlopt, kwargs @@ -295,6 +303,7 @@ test(path="test"; kwargs...) = script( existingscript(path, (path, joinpath(path, "runtests.jl"))); code_coverage = true, check_bounds = true, + depwarn = true, kwargs... ) docs(path="docs"; kwargs...) = script( diff --git a/test/depwarn-error/Manifest.toml b/test/depwarn-error/Manifest.toml new file mode 100644 index 0000000..e69de29 diff --git a/test/depwarn-error/Project.toml b/test/depwarn-error/Project.toml new file mode 100644 index 0000000..e69de29 diff --git a/test/depwarn-error/test.jl b/test/depwarn-error/test.jl new file mode 100644 index 0000000..d05e8b9 --- /dev/null +++ b/test/depwarn-error/test.jl @@ -0,0 +1 @@ +@assert Base.JLOptions().depwarn == 2 diff --git a/test/depwarn-no/Manifest.toml b/test/depwarn-no/Manifest.toml new file mode 100644 index 0000000..e69de29 diff --git a/test/depwarn-no/Project.toml b/test/depwarn-no/Project.toml new file mode 100644 index 0000000..e69de29 diff --git a/test/depwarn-no/test.jl b/test/depwarn-no/test.jl new file mode 100644 index 0000000..3102d36 --- /dev/null +++ b/test/depwarn-no/test.jl @@ -0,0 +1 @@ +@assert Base.JLOptions().depwarn == 0 diff --git a/test/depwarn-yes/Manifest.toml b/test/depwarn-yes/Manifest.toml new file mode 100644 index 0000000..e69de29 diff --git a/test/depwarn-yes/Project.toml b/test/depwarn-yes/Project.toml new file mode 100644 index 0000000..e69de29 diff --git a/test/depwarn-yes/test.jl b/test/depwarn-yes/test.jl new file mode 100644 index 0000000..b0d25bc --- /dev/null +++ b/test/depwarn-yes/test.jl @@ -0,0 +1 @@ +@assert Base.JLOptions().depwarn == 1 diff --git a/test/runtests.jl b/test/runtests.jl index 6cb5750..8f62315 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,6 +5,9 @@ using Test pass_script = joinpath(@__DIR__, "pass", "pass.jl") fail_script = joinpath(@__DIR__, "fail", "fail.jl") +depwarn_no_script = joinpath(@__DIR__, "depwarn-no", "test.jl") +depwarn_yes_script = joinpath(@__DIR__, "depwarn-yes", "test.jl") +depwarn_error_script = joinpath(@__DIR__, "depwarn-error", "test.jl") @testset "xfail" begin @testset "true pass" begin @@ -50,6 +53,13 @@ fail_script = joinpath(@__DIR__, "fail", "fail.jl") end end +@testset "depwarn" begin + @test Run.test(depwarn_yes_script).proc.exitcode == 0 + @test Run.test(depwarn_yes_script; depwarn = false, xfail = true).proc.exitcode == 1 + @test Run.test(depwarn_no_script; depwarn = false).proc.exitcode == 0 + @test Run.test(depwarn_error_script; depwarn = :error).proc.exitcode == 0 +end + @testset "smoke test" begin withenv("DOCUMENTER_KEY" => nothing) do @test Run.docs(joinpath(@__DIR__, "..", "docs")) isa Any