Skip to content

Commit 145853c

Browse files
Use TrixiTest.jl (#113)
* use TrixiTest.jl * Update test/benchmarks.jl --------- Co-authored-by: Erik Faulhaber <[email protected]>
1 parent 6840c22 commit 145853c

File tree

5 files changed

+14
-53
lines changed

5 files changed

+14
-53
lines changed

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
44
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
55
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
66
TrixiParticles = "66699cd8-9c01-4e9d-a059-b96c86d16b3a"
7+
TrixiTest = "0a316866-cbd0-4425-8bcb-08103b2c1f26"
78

89
[compat]
910
BenchmarkTools = "1"
1011
Plots = "1"
1112
Test = "1"
1213
TrixiParticles = "0.3"
14+
TrixiTest = "0.1"

test/benchmarks.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77

88
@testset verbose=true "$(length(size))D" for size in [(50,), (10, 10), (5, 5, 5)]
99
@testset verbose=true "`benchmark_count_neighbors`" begin
10-
@test_nowarn_mod plot_benchmarks(benchmark_count_neighbors, size, 2)
10+
@trixi_test_nowarn plot_benchmarks(benchmark_count_neighbors, size, 2)
1111
end
1212

1313
@testset verbose=true "`benchmark_n_body`" begin
14-
@test_nowarn_mod plot_benchmarks(benchmark_n_body, size, 2)
14+
@trixi_test_nowarn plot_benchmarks(benchmark_n_body, size, 2)
1515
end
1616

1717
@testset verbose=true "`benchmark_wcsph`" begin
18-
@test_nowarn_mod plot_benchmarks(benchmark_wcsph, size, 2)
18+
@trixi_test_nowarn plot_benchmarks(benchmark_wcsph, size, 2)
1919
end
2020

2121
@testset verbose=true "`benchmark_wcsph_fp32`" begin
22-
@test_nowarn_mod plot_benchmarks(benchmark_wcsph_fp32, size, 2)
22+
@trixi_test_nowarn plot_benchmarks(benchmark_wcsph_fp32, size, 2)
2323
end
2424

2525
@testset verbose=true "`benchmark_tlsph`" begin
26-
@test_nowarn_mod plot_benchmarks(benchmark_tlsph, size, 2)
26+
@trixi_test_nowarn plot_benchmarks(benchmark_tlsph, size, 2)
2727
end
2828

2929
@testset verbose=true "`benchmark_initialize`" begin
30-
@test_nowarn_mod plot_benchmarks(benchmark_initialize, size, 2)
30+
@trixi_test_nowarn plot_benchmarks(benchmark_initialize, size, 2)
3131
end
3232

3333
@testset verbose=true "`benchmark_update_alternating`" begin
34-
@test_nowarn_mod plot_benchmarks(benchmark_update_alternating, size, 2)
34+
@trixi_test_nowarn plot_benchmarks(benchmark_update_alternating, size, 2)
3535
end
3636
end
3737
end;

test/cell_lists/full_grid.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
@test_throws error_string initialize!(nhs, y, y)
3030

3131
y[1, 7] = 0.0
32-
@test_nowarn_mod initialize!(nhs, y, y)
33-
@test_nowarn_mod update!(nhs, y, y)
32+
@trixi_test_nowarn initialize!(nhs, y, y)
33+
@trixi_test_nowarn update!(nhs, y, y)
3434

3535
y[1, 7] = 10.0
36-
@test_nowarn_mod update!(nhs, y, y)
36+
@trixi_test_nowarn update!(nhs, y, y)
3737

3838
y[1, 7] = NaN
3939
@test_throws error_string update!(nhs, y, y)

test/nhs_grid.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@test_throws "ParallelUpdate() $error_str" GridNeighborhoodSearch{2}(update_strategy = ParallelUpdate())
88

99
nhs = GridNeighborhoodSearch{3}(update_strategy = SerialUpdate())
10-
nhs2 = @test_nowarn_mod PointNeighbors.Adapt.adapt_structure(Array, nhs)
10+
nhs2 = @trixi_test_nowarn PointNeighbors.Adapt.adapt_structure(Array, nhs)
1111

1212
@test nhs2.update_strategy == nhs.update_strategy
1313
end

test/test_util.jl

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# All `using` calls are in this file, so that one can run any test file
22
# after running only this file.
33
using Test: @test, @testset, @test_throws
4+
using TrixiTest: @trixi_test_nowarn
45
using PointNeighbors
56

67
"""
@@ -33,46 +34,4 @@ macro trixi_testset(name, expr)
3334
end
3435
end
3536

36-
"""
37-
@test_nowarn_mod expr
38-
39-
Modified version of `@test_nowarn expr` that prints the content of `stderr` when
40-
it is not empty and ignores some common info statements printed in Trixi.jl
41-
uses.
42-
"""
43-
macro test_nowarn_mod(expr, additional_ignore_content = String[])
44-
quote
45-
let fname = tempname()
46-
try
47-
ret = open(fname, "w") do f
48-
redirect_stderr(f) do
49-
$(esc(expr))
50-
end
51-
end
52-
stderr_content = read(fname, String)
53-
if !isempty(stderr_content)
54-
println("Content of `stderr`:\n", stderr_content)
55-
end
56-
57-
# Patterns matching the following ones will be ignored. Additional patterns
58-
# passed as arguments can also be regular expressions, so we just use the
59-
# type `Any` for `ignore_content`.
60-
ignore_content = Any["[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n"]
61-
append!(ignore_content, $additional_ignore_content)
62-
for pattern in ignore_content
63-
stderr_content = replace(stderr_content, pattern => "")
64-
end
65-
66-
# We also ignore simple module redefinitions for convenience. Thus, we
67-
# check whether every line of `stderr_content` is of the form of a
68-
# module replacement warning.
69-
@test occursin(r"^(WARNING: replacing module .+\.\n)*$", stderr_content)
70-
ret
71-
finally
72-
rm(fname, force = true)
73-
end
74-
end
75-
end
76-
end
77-
7837
include("point_cloud.jl")

0 commit comments

Comments
 (0)