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 f1c5f99..216f665 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -43,17 +43,25 @@ 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_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...)`. + 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. + +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 @@ -69,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, :atol, :rtol))) + !(arg.args[1] in (:additional_ignore_content, :l2, :linf, + :RealT_for_test_tolerances, :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