Skip to content

Commit 4783cd5

Browse files
use TrixiTest.jl (#93)
1 parent 4db2ff5 commit 4783cd5

File tree

2 files changed

+12
-48
lines changed

2 files changed

+12
-48
lines changed

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ OrdinaryDiffEqLowStorageRK = "b0944070-b475-4768-8dec-fb6eb410534d"
55
OrdinaryDiffEqSSPRK = "669c94d9-1f4b-4b64-b377-1aa079aa2388"
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
NLsolve = "4.5.1"
@@ -13,3 +14,4 @@ OrdinaryDiffEqLowStorageRK = "1.2"
1314
OrdinaryDiffEqSSPRK = "1.2"
1415
Test = "1"
1516
Trixi = "0.9.9, 0.10, 0.11"
17+
TrixiTest = "0.1"

test/test_trixiatmo.jl

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

@@ -125,55 +126,16 @@ end
125126

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

0 commit comments

Comments
 (0)