Skip to content

Commit 75de71d

Browse files
Use TrixiTest.jl (#100)
* use TrixiTest.jl * simplify test_nowarn_mod * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent a2d5afc commit 75de71d

File tree

2 files changed

+12
-45
lines changed

2 files changed

+12
-45
lines changed

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
55
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
66
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
77
Trixi = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
8+
TrixiTest = "0a316866-cbd0-4425-8bcb-08103b2c1f26"
89

910
[compat]
1011
OrdinaryDiffEqLowStorageRK = "1.3"
@@ -13,3 +14,4 @@ Printf = "1"
1314
Roots = "2.1.6"
1415
Test = "1"
1516
Trixi = "0.11.10"
17+
TrixiTest = "0.1"

test/test_trixi.jl

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Test: @test
2+
using TrixiTest: @trixi_test_nowarn
23
import Trixi
34

45
# Use a macro to avoid world age issues when defining new initial conditions etc.
@@ -122,52 +123,16 @@ function expr_to_named_tuple(expr)
122123
return result
123124
end
124125

125-
# Modified version of `@test_nowarn` that prints the content of `stderr` when
126-
# it is not empty and ignores module replacements.
127-
macro test_nowarn_mod(expr, additional_ignore_content = String[])
126+
macro test_nowarn_mod(expr, additional_ignore_content = [])
128127
quote
129-
let fname = tempname()
130-
try
131-
ret = open(fname, "w") do f
132-
redirect_stderr(f) do
133-
$(esc(expr))
134-
end
135-
end
136-
stderr_content = read(fname, String)
137-
if !isempty(stderr_content)
138-
println("Content of `stderr`:\n", stderr_content)
139-
end
140-
141-
# Patterns matching the following ones will be ignored. Additional patterns
142-
# passed as arguments can also be regular expressions, so we just use the
143-
# type `Any` for `ignore_content`.
144-
ignore_content = Any[
145-
# We need to ignore steady state information reported by our callbacks
146-
r"┌ Info: Steady state tolerance reached\n│ steady_state_callback .+\n└ t = .+\n",
147-
# We also ignore our own compilation messages
148-
"[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n",
149-
# TODO: Upstream (PlotUtils). This should be removed again once the
150-
# deprecated stuff is fixed upstream.
151-
"WARNING: importing deprecated binding Colors.RGB1 into Plots.\n",
152-
"WARNING: importing deprecated binding Colors.RGB4 into Plots.\n",
153-
r"┌ Warning: Keyword argument letter not supported with Plots.+\n└ @ Plots.+\n",
154-
r"┌ Warning: `parse\(::Type, ::Coloarant\)` is deprecated.+\n│.+\n│.+\n└ @ Plots.+\n",
155-
# TODO: Silence warning introduced by Flux v0.13.13. Should be properly fixed.
156-
r"┌ Warning: Layer with Float32 parameters got Float64 input.+\n│.+\n│.+\n│.+\n└ @ Flux.+\n"]
157-
append!(ignore_content, $additional_ignore_content)
158-
for pattern in ignore_content
159-
stderr_content = replace(stderr_content, pattern => "")
160-
end
161-
162-
# We also ignore simple module redefinitions for convenience. Thus, we
163-
# check whether every line of `stderr_content` is of the form of a
164-
# module replacement warning.
165-
@test occursin(r"^(WARNING: replacing module .+\.\n)*$", stderr_content)
166-
ret
167-
finally
168-
rm(fname, force = true)
169-
end
170-
end
128+
add_to_additional_ignore_content = [
129+
# We need to ignore steady state information reported by our callbacks
130+
r"┌ Info: Steady state tolerance reached\n│ steady_state_callback .+\n└ t = .+\n",
131+
# NOTE: These warnings arose from Julia 1.10 onwards
132+
r"WARNING: Method definition .* in module .* at .* overwritten .*.\n"
133+
]
134+
append!($additional_ignore_content, add_to_additional_ignore_content)
135+
@trixi_test_nowarn $(esc(expr)) $additional_ignore_content
171136
end
172137
end
173138

0 commit comments

Comments
 (0)