|
1 | 1 | using Test: @test |
| 2 | +using TrixiTest: @trixi_test_nowarn |
2 | 3 | import Trixi |
3 | 4 |
|
4 | 5 | # Use a macro to avoid world age issues when defining new initial conditions etc. |
@@ -122,52 +123,16 @@ function expr_to_named_tuple(expr) |
122 | 123 | return result |
123 | 124 | end |
124 | 125 |
|
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 = []) |
128 | 127 | 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 |
171 | 136 | end |
172 | 137 | end |
173 | 138 |
|
|
0 commit comments