From af60f8802e095a1334048a1c63184852e7bd577d Mon Sep 17 00:00:00 2001 From: Benedict <135045760+benegee@users.noreply.github.com> Date: Tue, 2 Dec 2025 12:47:52 +0100 Subject: [PATCH 1/4] Do not filter out `RealT` (#17) * do not filter out but foward RealT to trixi_include * add test for RealT keyword * update docstring of at-test_trixdi_include --------- Co-authored-by: Hendrik Ranocha --- src/macros.jl | 13 +++++++++--- test/test_test_trixi_include.jl | 35 ++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/macros.jl b/src/macros.jl index f1c5f99..4547009 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -43,17 +43,24 @@ end """ @test_trixi_include_base(elixir; additional_ignore_content = Any[], - l2=nothing, linf=nothing, RealT=Float64, - atol=500*eps(RealT), rtol=sqrt(eps(RealT)), + l2 = nothing, linf = nothing, + RealT = Float64, + atol = 500 * eps(RealT), rtol = sqrt(eps(RealT)), parameters...) Test an `elixir` file by calling `trixi_include(elixir; parameters...)`. + The `additional_ignore_content` argument is passed to [`@trixi_test_nowarn`](@ref) and can be used to ignore additional patterns in the `stderr` output. By default, only the absence of error output is checked. + If `l2` or `linf` are specified, in addition the resulting L2/Linf errors are compared approximately against these reference values, using `atol, rtol` as absolute/relative tolerance. + +While the arguments `additional_ignore_content`, `l2`, `linf`, `atol`, and `rtol` +are not passed to `trixi_include(elixir; parameters...)`, the keyword argument +`RealT` (if specified explicitly) is passed to `trixi_include` as well. """ macro test_trixi_include_base(elixir, args...) # Note: The variables below are just Symbols, not actual errors/types @@ -69,7 +76,7 @@ macro test_trixi_include_base(elixir, args...) local kwargs = Pair{Symbol, Any}[] for arg in args if (arg.head == :(=) && - !(arg.args[1] in (:additional_ignore_content, :l2, :linf, :RealT, :atol, :rtol))) + !(arg.args[1] in (:additional_ignore_content, :l2, :linf, :atol, :rtol))) push!(kwargs, Pair(arg.args...)) end end diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index 313eddd..1418077 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -94,7 +94,7 @@ end @test x == 5 end - # overwrite included variable by another included variables + # overwrite included variable by another included variable @test_trixi_include_base(path, x=seed) if VERSION >= v"1.12" mod = @__MODULE__ @@ -207,4 +207,37 @@ end @test_trixi_include(path, maxiters=iters) end end + + # RealT is used internally to compute error tolerances when l2 or linf are used + # However, it should also be forwarded as a keyword argument to trixi_include + @trixi_testset "RealT" begin + example = """ + RealT = Float64 + """ + + mktemp() do path, io + write(io, example) + close(io) + + @test_trixi_include_base(path, RealT=Float32) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :RealT) + @test (@invokelatest mod.RealT) == Float32 + else + @test @isdefined RealT + @test RealT == Float32 + end + + @test_trixi_include(path, RealT=Float32) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :RealT) + @test (@invokelatest mod.RealT) == Float32 + else + @test @isdefined RealT + @test RealT == Float32 + end + end + end end From 08cbd5073014dea1ba2f6d4c9c9c72555f473c1f Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Tue, 2 Dec 2025 17:43:28 +0100 Subject: [PATCH 2/4] rename RealT to RealT_for_test_tolerances --- NEWS.md | 12 ++++++++++++ Project.toml | 2 +- src/macros.jl | 11 ++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 NEWS.md diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..b4bdaf5 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,12 @@ +# Changelog + +TrixiTest.jl follows the interpretation of +[semantic versioning (semver)](https://julialang.github.io/Pkg.jl/dev/compatibility/#Version-specifier-format-1) +used in the Julia ecosystem. Notable changes will be documented in this file +for human readability. + +## Breaking changes from v0.1.x to v0.2 + +- The keyword argument `RealT` in the macro `@test_trixi_include_base` + has been renamed to `RealT_for_test_tolerances` to avoid name clashes + when passing a keyword argument `RealT`. diff --git a/Project.toml b/Project.toml index b6b9664..8d4b02f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TrixiTest" uuid = "0a316866-cbd0-4425-8bcb-08103b2c1f26" authors = ["Joshua Lampert "] -version = "0.1.8-DEV" +version = "0.2.0" [deps] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/macros.jl b/src/macros.jl index 4547009..55cc212 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -44,8 +44,9 @@ end """ @test_trixi_include_base(elixir; additional_ignore_content = Any[], l2 = nothing, linf = nothing, - RealT = Float64, - atol = 500 * eps(RealT), rtol = sqrt(eps(RealT)), + RealT_for_test_tolerances = Float64, + atol = 500 * eps(RealT_for_test_tolerances), + rtol = sqrt(eps(RealT_for_test_tolerances)), parameters...) Test an `elixir` file by calling `trixi_include(elixir; parameters...)`. @@ -58,9 +59,9 @@ If `l2` or `linf` are specified, in addition the resulting L2/Linf errors are compared approximately against these reference values, using `atol, rtol` as absolute/relative tolerance. -While the arguments `additional_ignore_content`, `l2`, `linf`, `atol`, and `rtol` -are not passed to `trixi_include(elixir; parameters...)`, the keyword argument -`RealT` (if specified explicitly) is passed to `trixi_include` as well. +The keyword arguments `additional_ignore_content`, `l2`, `linf`, +`RealT_for_test_tolerances`, `atol`, and `rtol` are not passed to +`trixi_include(elixir; parameters...)`. """ macro test_trixi_include_base(elixir, args...) # Note: The variables below are just Symbols, not actual errors/types From 0322572b2e9873f0b5cd638f42363097cce009fc Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Tue, 2 Dec 2025 17:46:06 +0100 Subject: [PATCH 3/4] Add RealT_for_test_tolerances to ignored arguments --- src/macros.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/macros.jl b/src/macros.jl index 55cc212..d39821d 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -77,7 +77,7 @@ macro test_trixi_include_base(elixir, args...) local kwargs = Pair{Symbol, Any}[] for arg in args if (arg.head == :(=) && - !(arg.args[1] in (:additional_ignore_content, :l2, :linf, :atol, :rtol))) + !(arg.args[1] in (:additional_ignore_content, :l2, :linf, :RealT_for_test_tolerances, :atol, :rtol))) push!(kwargs, Pair(arg.args...)) end end From 9c99a7c438518eec55aa6fa4d5ec8571cd50885c Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Tue, 2 Dec 2025 17:50:48 +0100 Subject: [PATCH 4/4] format --- src/macros.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/macros.jl b/src/macros.jl index d39821d..216f665 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -77,7 +77,8 @@ macro test_trixi_include_base(elixir, args...) local kwargs = Pair{Symbol, Any}[] for arg in args if (arg.head == :(=) && - !(arg.args[1] in (:additional_ignore_content, :l2, :linf, :RealT_for_test_tolerances, :atol, :rtol))) + !(arg.args[1] in (:additional_ignore_content, :l2, :linf, + :RealT_for_test_tolerances, :atol, :rtol))) push!(kwargs, Pair(arg.args...)) end end