Skip to content

Commit

Permalink
Show depwarn by default in Run.test (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed May 3, 2020
1 parent 51eb945 commit 757cecc
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core.jl
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Empty file.
Empty file added test/depwarn-error/Project.toml
Empty file.
1 change: 1 addition & 0 deletions test/depwarn-error/test.jl
@@ -0,0 +1 @@
@assert Base.JLOptions().depwarn == 2
Empty file added test/depwarn-no/Manifest.toml
Empty file.
Empty file added test/depwarn-no/Project.toml
Empty file.
1 change: 1 addition & 0 deletions test/depwarn-no/test.jl
@@ -0,0 +1 @@
@assert Base.JLOptions().depwarn == 0
Empty file added test/depwarn-yes/Manifest.toml
Empty file.
Empty file added test/depwarn-yes/Project.toml
Empty file.
1 change: 1 addition & 0 deletions test/depwarn-yes/test.jl
@@ -0,0 +1 @@
@assert Base.JLOptions().depwarn == 1
10 changes: 10 additions & 0 deletions test/runtests.jl
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 757cecc

Please sign in to comment.