Skip to content

Commit

Permalink
remove other mentions of coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Feb 1, 2025
1 parent e3551f8 commit 6c3f6da
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 154 deletions.
57 changes: 24 additions & 33 deletions test/test_p4est_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,14 @@ end
17.750333649853616
],
tspan=(0.0, 0.0001),
rtol=1.0e-7,
skip_coverage=true)
if @isdefined sol # Skipped in coverage run
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
rtol=1.0e-7,)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end

Expand All @@ -467,17 +464,14 @@ end
24.241610279839758,
561.0630401858057
],
tspan=(0.0, 0.0001),
skip_coverage=true)
if @isdefined sol # Skipped in coverage run
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
tspan=(0.0, 0.0001),)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end

Expand All @@ -495,17 +489,14 @@ end
6.857777546171545,
31.749285097390576
],
tspan=(0.0, 0.001),
skip_coverage=true)
if @isdefined sol # Skipped in coverage run
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
tspan=(0.0, 0.001),)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end

Expand Down
143 changes: 58 additions & 85 deletions test/test_special_elixirs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,101 +14,74 @@ isdir(outdir) && rm(outdir, recursive = true)

const EXAMPLES_DIR = pkgdir(Trixi, "examples")

cmd = string(Base.julia_cmd())
coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd)

@testset "Special elixirs" begin
#! format: noindent

@testset "Convergence test" begin
if !coverage
@timed_testset "tree_2d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_advection_extended.jl"),
3, initial_refinement_level = 2)
@test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05)
end
@timed_testset "tree_2d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_advection_extended.jl"),
3, initial_refinement_level = 2)
@test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05)
end

@timed_testset "structured_2d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"structured_2d_dgsem",
"elixir_advection_extended.jl"),
3, cells_per_dimension = (5, 9))
@test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05)
end
@timed_testset "structured_2d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"structured_2d_dgsem",
"elixir_advection_extended.jl"),
3, cells_per_dimension = (5, 9))
@test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05)
end

@timed_testset "structured_2d_dgsem coupled" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"structured_2d_dgsem",
"elixir_advection_coupled.jl"),
3)
@test isapprox(mean_convergence[1][:l2], [4.0], rtol = 0.05)
@test isapprox(mean_convergence[2][:l2], [4.0], rtol = 0.05)
end
@timed_testset "structured_2d_dgsem coupled" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"structured_2d_dgsem",
"elixir_advection_coupled.jl"),
3)
@test isapprox(mean_convergence[1][:l2], [4.0], rtol = 0.05)
@test isapprox(mean_convergence[2][:l2], [4.0], rtol = 0.05)
end

@timed_testset "p4est_2d_dgsem" begin
# Run convergence test on unrefined mesh
no_refine = @cfunction((p4est, which_tree, quadrant)->Cint(0), Cint,
(Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t},
Ptr{Trixi.p4est_quadrant_t}))
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
"elixir_euler_source_terms_nonconforming_unstructured_flag.jl"),
2, refine_fn_c = no_refine)
@test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol = 0.05)
end
@timed_testset "p4est_2d_dgsem" begin
# Run convergence test on unrefined mesh
no_refine = @cfunction((p4est, which_tree, quadrant)->Cint(0), Cint,
(Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t},
Ptr{Trixi.p4est_quadrant_t}))
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
"elixir_euler_source_terms_nonconforming_unstructured_flag.jl"),
2, refine_fn_c = no_refine)
@test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol = 0.05)
end

@timed_testset "structured_3d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"structured_3d_dgsem",
"elixir_advection_basic.jl"),
2, cells_per_dimension = (7, 4, 5))
@test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05)
end
@timed_testset "structured_3d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"structured_3d_dgsem",
"elixir_advection_basic.jl"),
2, cells_per_dimension = (7, 4, 5))
@test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05)
end

@timed_testset "p4est_3d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "p4est_3d_dgsem",
"elixir_advection_unstructured_curved.jl"),
2, initial_refinement_level = 0)
@test isapprox(mean_convergence[:l2], [2.7], rtol = 0.05)
end
@timed_testset "p4est_3d_dgsem" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "p4est_3d_dgsem",
"elixir_advection_unstructured_curved.jl"),
2, initial_refinement_level = 0)
@test isapprox(mean_convergence[:l2], [2.7], rtol = 0.05)
end

@timed_testset "paper_self_gravitating_gas_dynamics" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"paper_self_gravitating_gas_dynamics",
"elixir_eulergravity_convergence.jl"),
2, tspan = (0.0, 0.25),
initial_refinement_level = 1)
@test isapprox(mean_convergence[:l2], 4 * ones(4), atol = 0.4)
end
else
# Without coverage, just run simple convergence tests to cover
# the convergence test logic
@test_nowarn_mod convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_advection_basic.jl"), 2)
@test_nowarn_mod convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
"elixir_advection_extended.jl"), 2,
initial_refinement_level = 0,
tspan = (0.0, 0.1))
@test_nowarn_mod convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "structured_2d_dgsem",
"elixir_advection_basic.jl"), 2)
@test_nowarn_mod convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "structured_2d_dgsem",
"elixir_advection_coupled.jl"), 2)
@test_nowarn_mod convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR, "structured_2d_dgsem",
"elixir_advection_extended.jl"), 2,
cells_per_dimension = (1, 1),
tspan = (0.0, 0.1))
@timed_testset "paper_self_gravitating_gas_dynamics" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"paper_self_gravitating_gas_dynamics",
"elixir_eulergravity_convergence.jl"),
2, tspan = (0.0, 0.25),
initial_refinement_level = 1)
@test isapprox(mean_convergence[:l2], 4 * ones(4), atol = 0.4)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_structured_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ end
0.19313636558790004,
0.707563913727584
],
tspan=(0.0, 0.25),) # Prevent long compile time in CI
tspan=(0.0, 0.25),)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
Expand Down
2 changes: 1 addition & 1 deletion test/test_t8code_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ mkdir(outdir)
],
tspan=(0.0, 1e2),
# Decrease tolerance of adaptive time stepping to get similar results across different systems
abstol=1.0e-9, reltol=1.0e-9,) # Prevent long compile time in CI
abstol=1.0e-9, reltol=1.0e-9,)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
Expand Down
4 changes: 2 additions & 2 deletions test/test_tree_2d_euler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ end
save_errors=true)
lines = readlines(joinpath("out", "deviations.txt"))
@test lines[1] == "# iter, simu_time, rho_min, pressure_min"
# Run without (with) coverage takes 745 (7) time steps
@test startswith(lines[end], "7")
# Run takes 745 time steps
@test startswith(lines[end], "745")
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
Expand Down
4 changes: 2 additions & 2 deletions test/test_tree_2d_eulermulti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem")
save_errors=true)
lines = readlines(joinpath("out", "deviations.txt"))
@test lines[1] == "# iter, simu_time, rho1_min, rho2_min"
# Runs with and without coverage take 1 and 15 time steps.
@test startswith(lines[end], "1")
# Runs 15 time steps.
@test startswith(lines[end], "15")
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
Expand Down
19 changes: 8 additions & 11 deletions test/test_tree_2d_kpp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem")
max_refinement_level=6,
tspan=(0.0, 0.01),
atol=1e-6,
rtol=1e-6,
skip_coverage=true)
if @isdefined sol # Skipped in coverage run
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
rtol=1e-6,)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end
Expand Down
21 changes: 2 additions & 19 deletions test/test_trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,15 @@ macro test_trixi_include(elixir, args...)
end
local atol = get_kwarg(args, :atol, atol_default)
local rtol = get_kwarg(args, :rtol, rtol_default)
local skip_coverage = get_kwarg(args, :skip_coverage, false)

local cmd = string(Base.julia_cmd())
local coverage = occursin("--code-coverage", cmd) &&
!occursin("--code-coverage=none", cmd)

local kwargs = Pair{Symbol, Any}[]
for arg in args
if (arg.head == :(=) &&
!(arg.args[1] in (:l2, :linf, :RealT, :atol, :rtol,
:skip_coverage)))
!(arg.args[1] in (:l2, :linf, :RealT, :atol, :rtol,)))
push!(kwargs, Pair(arg.args...))
end
end

if coverage && skip_coverage
return quote
if Trixi.mpi_isroot()
println(""^100)
println("Skipping coverage test of ", $elixir)
println(""^100)
println("\n\n")
end
end
end

quote
Trixi.mpi_isroot() && println(""^100)
Trixi.mpi_isroot() && println($elixir)
Expand All @@ -78,7 +61,7 @@ macro test_trixi_include(elixir, args...)
@test_nowarn_mod trixi_include(@__MODULE__, $elixir; $kwargs...) additional_ignore_content

# if present, compare l2 and linf errors against reference values
if !$coverage && (!isnothing($l2) || !isnothing($linf))
if !isnothing($l2) || !isnothing($linf)
l2_measured, linf_measured = analysis_callback(sol)

if Trixi.mpi_isroot() && !isnothing($l2)
Expand Down

0 comments on commit 6c3f6da

Please sign in to comment.