Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove coverage_override and use primary test run for code coverage #2254

Merged
merged 13 commits into from
Feb 5, 2025
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,7 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
env:
PYTHON: ''
- name: Run tests without coverage
uses: julia-actions/julia-runtest@v1
with:
coverage: false
env:
PYTHON: ''
TRIXI_TEST: ${{ matrix.trixi_test }}
- name: Run tests with coverage
- name: Run tests
uses: julia-actions/julia-runtest@v1
with:
coverage: true
Expand Down
18 changes: 3 additions & 15 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,9 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3)
# cf. https://github.com/JuliaParallel/MPI.jl/pull/391
@test true

# There are spurious test failures of Trixi.jl with MPI on Windows, see
# https://github.com/trixi-framework/Trixi.jl/issues/901
# To reduce their impact, we do not test MPI with coverage on Windows.
# This reduces the chance to hit a spurious test failure by one half.
# In addition, it looks like the Linux GitHub runners run out of memory during the 3D tests
# with coverage, so we currently do not test MPI with coverage on Linux. For more details,
# see the discussion at https://github.com/trixi-framework/Trixi.jl/pull/1062#issuecomment-1035901020
cmd = string(Base.julia_cmd())
coverage = occursin("--code-coverage", cmd) &&
!occursin("--code-coverage=none", cmd)
if !(coverage && Sys.iswindows()) && !(coverage && Sys.isapple())
# We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing
mpiexec() do cmd
run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=0.5G $(abspath("test_mpi.jl"))`)
end
# We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing
mpiexec() do cmd
run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=0.5G $(abspath("test_mpi.jl"))`)
end
end

Expand Down
11 changes: 3 additions & 8 deletions test/test_mpi_p4est_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_2d_dgsem")
"elixir_advection_amr_solution_independent.jl"),
# Expected errors are exactly the same as with TreeMesh!
l2=[4.949660644033807e-5],
linf=[0.0004867846262313763],
coverage_override=(maxiters = 6,))
linf=[0.0004867846262313763],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -98,8 +97,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_2d_dgsem")
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_amr_unstructured_flag.jl"),
l2=[0.0012808538770535593],
linf=[0.01752690016659812],
coverage_override=(maxiters = 6,))
linf=[0.01752690016659812],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -114,10 +112,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_2d_dgsem")
@trixi_testset "elixir_advection_restart.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
l2=[4.507575525876275e-6],
linf=[6.21489667023134e-5],
# With the default `maxiters = 1` in coverage tests,
# there would be no time steps after the restart.
coverage_override=(maxiters = 100_000,))
linf=[6.21489667023134e-5],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand Down
28 changes: 6 additions & 22 deletions test/test_mpi_p4est_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem")
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
# Expected errors are exactly the same as with TreeMesh!
l2=[9.773852895157622e-6],
linf=[0.0005853874124926162],
# override values are different from the serial tests to ensure each process holds at least
# one element, otherwise OrdinaryDiffEq fails during initialization
coverage_override=(maxiters = 6,
initial_refinement_level = 2,
base_level = 2, med_level = 3,
max_level = 4))
linf=[0.0005853874124926162],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -71,11 +65,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem")
"elixir_advection_amr_unstructured_curved.jl"),
l2=[1.6163120948209677e-5],
linf=[0.0010572201890564834],
tspan=(0.0, 1.0),
coverage_override=(maxiters = 6,
initial_refinement_level = 0,
base_level = 0, med_level = 1,
max_level = 2))
tspan=(0.0, 1.0),)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -90,10 +80,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem")
@trixi_testset "elixir_advection_restart.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
l2=[0.002590388934758452],
linf=[0.01840757696885409],
# With the default `maxiters = 1` in coverage tests,
# there would be no time steps after the restart.
coverage_override=(maxiters = 100_000,))
linf=[0.01840757696885409],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand Down Expand Up @@ -195,8 +182,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem")
0.45574161423218573,
0.8099577682187109
],
tspan=(0.0, 0.2),
coverage_override=(polydeg = 3,)) # Prevent long compile time in CI
tspan=(0.0, 0.2),)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand Down Expand Up @@ -261,8 +247,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem")
0.005104176909383168,
9.738081186490818e-6
],
tspan=(0.0, 0.25),
coverage_override=(trees_per_dimension = (1, 1, 1),))
tspan=(0.0, 0.25),)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
Expand Down Expand Up @@ -299,8 +284,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem")
0.05701669133068068,
0.00024182906501186622
],
tspan=(0.0, 0.25), trees_per_dimension=(1, 1, 1),
coverage_override=(trees_per_dimension = (1, 1, 1),))
tspan=(0.0, 0.25), trees_per_dimension=(1, 1, 1),)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
Expand Down
11 changes: 3 additions & 8 deletions test/test_mpi_t8code_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_2d_dgsem")
"elixir_advection_amr_solution_independent.jl"),
# Expected errors are exactly the same as with TreeMesh!
l2=[4.949660644033807e-5],
linf=[0.0004867846262313763],
coverage_override=(maxiters = 6,), atol=1e-9)
linf=[0.0004867846262313763],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -99,8 +98,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_2d_dgsem")
"elixir_advection_amr_unstructured_flag.jl"),
l2=[0.002019623611753929],
linf=[0.03542375961299987],
dynamic_load_balancing=false,
coverage_override=(maxiters = 6,))
dynamic_load_balancing=false,)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -115,10 +113,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_2d_dgsem")
@trixi_testset "elixir_advection_restart.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
l2=[4.507575525876275e-6],
linf=[6.21489667023134e-5],
# With the default `maxiters = 1` in coverage tests,
# there would be no time steps after the restart.
coverage_override=(maxiters = 100_000,))
linf=[6.21489667023134e-5],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand Down
22 changes: 4 additions & 18 deletions test/test_mpi_t8code_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_dgsem")
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
# Expected errors are exactly the same as with TreeMesh!
l2=[1.1302812803902801e-5],
linf=[0.0007889950196294793],
# override values are different from the serial tests to ensure each process holds at least
# one element, otherwise OrdinaryDiffEq fails during initialization
coverage_override=(maxiters = 6,
initial_refinement_level = 2,
base_level = 2, med_level = 3,
max_level = 4))
linf=[0.0007889950196294793],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -71,11 +65,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_dgsem")
"elixir_advection_amr_unstructured_curved.jl"),
l2=[2.0535121347526814e-5],
linf=[0.0010586603797777504],
tspan=(0.0, 1.0),
coverage_override=(maxiters = 6,
initial_refinement_level = 0,
base_level = 0, med_level = 1,
max_level = 2))
tspan=(0.0, 1.0),)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -90,10 +80,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_dgsem")
@trixi_testset "elixir_advection_restart.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
l2=[0.002590388934758452],
linf=[0.01840757696885409],
# With the default `maxiters = 1` in coverage tests,
# there would be no time steps after the restart.
coverage_override=(maxiters = 100_000,))
linf=[0.01840757696885409],)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand Down Expand Up @@ -180,8 +167,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_dgsem")
0.45574161423218573,
0.8099577682187109
],
tspan=(0.0, 0.2),
coverage_override=(polydeg = 3,)) # Prevent long compile time in CI
tspan=(0.0, 0.2),)

# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand Down
20 changes: 6 additions & 14 deletions test/test_mpi_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
# Expected errors are exactly the same as in the serial test!
l2=[4.913300828257469e-5],
linf=[0.00045263895394385967],
coverage_override=(maxiters = 6,))
linf=[0.00045263895394385967],)
end

@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_amr_nonperiodic.jl"),
# Expected errors are exactly the same as in the serial test!
l2=[3.2207388565869075e-5],
linf=[0.0007508059772436404],
coverage_override=(maxiters = 6,))
linf=[0.0007508059772436404],)
end

@trixi_testset "elixir_advection_restart_amr.jl" begin
Expand All @@ -88,8 +86,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_amr_refine_twice.jl"),
l2=[0.00020547512522578292],
linf=[0.007831753383083506],
coverage_override=(maxiters = 6,))
linf=[0.007831753383083506],)
meshfiles = filter(file -> endswith(file, ".h5") && startswith(file, "mesh"),
readdir(outdir))
@test length(meshfiles) > 1
Expand All @@ -99,8 +96,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_amr_coarsen_twice.jl"),
l2=[0.0014321062757891826],
linf=[0.0253454486893413],
coverage_override=(maxiters = 6,))
linf=[0.0253454486893413],)
end

# Hyperbolic diffusion
Expand Down Expand Up @@ -205,10 +201,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
0.0002973166773747593,
0.0002973166773760916,
0.001154106793870291
],
# Let this test run until the end to cover the time-dependent lines
# of the indicator and the MPI-specific AMR code.
coverage_override=(maxiters = 10^5,))
],)
end
end

Expand Down Expand Up @@ -323,8 +316,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
0.03857193149447702,
0.031090457959835893,
0.12125130332971423
],
coverage_override=(maxiters = 6,))
],)
end

if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
Expand Down
Loading
Loading