Skip to content

Commit 0479a61

Browse files
authored
Merge pull request #184 from WIAS-PDELib/jf/retest
Use ReTest in tests
2 parents dcec0ad + f7fa057 commit 0479a61

File tree

5 files changed

+118
-102
lines changed

5 files changed

+118
-102
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ function make(;
3737
"misc.md",
3838
"internal.md",
3939
"allindex.md",
40-
"devel.md",
4140
"extensions.md",
41+
"devel.md",
4242
],
4343
]
4444

docs/src/devel.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
# Development hints
2-
Here, a bit of development hints are given which mainly concern tests and documentation generation.
2+
Here, some development hints are given which mainly concern tests and documentation generation.
3+
4+
## ReTest
5+
[ReTest.jl](https://github.com/JuliaTesting/ReTest.jl) allows to run tests from a subset of testsets specified by regular expression. For the gemeral workflow, see the [quick start](https://juliatesting.github.io/ReTest.jl/stable/#Quick-start) documentation.
6+
7+
Testing the package code can be done just by calling `test/runtests.jl`. This file is also invoked by the CI, and it just includes `test/alltests.jl`.
8+
9+
Alternatively, test code can be run via ReTest. For this purpose, the module `test/VoronoiFVMReTest.jl` can be loaded in an environment with `VoronoiFVM.jl` (developed), test dependencies (see `test/Project.toml`), `ReTest.jl` and `Revise.jl`. A shared environment (e.g. via `julia --project=@VoronoiFVM`) is a convenient way to maintain such an environment locally.
10+
11+
After loading `VoronoiFVM` via `ReTest` as follows
12+
```
13+
julia> using ReTest
14+
julia> ReTest.load("test/VoronoiFVMReTest.jl")
15+
```
16+
e.g.
17+
```
18+
julia> retest("Aqua")
19+
```
20+
runs just the "Aqua" testset. Via
21+
```
22+
julia> retest(dry=true)
23+
```
24+
one obtains a list of all possible testsets.
25+
326

427
## Pluto notebooks
528
The pluto notebooks in this package are "triple use":
629
- As typical Pluto notebooks, they are self-contained in the senses that they contain their own Project and Manifest files. So users can just download and execute them.
730
- If they run with the environment variable `PLUTO_PROJECT` set to some julia environment, this environment will activated at the start of the notebook. In particular, they use `Revise.jl` so they can be run during development of VoronoiFVM.jl. See also https://github.com/fonsp/Pluto.jl/issues/1788 .
8-
- During CI tests, they are run as scripts. For this purpose they are wrapped into temporary modules, and @test macros can be used in the notebooks.
31+
- During CI tests (including ReTest), they are run as scripts. For this purpose they are wrapped into temporary modules, and @test macros can be used in the notebooks.

test/VoronoiFVMReTest.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# See https://wias-pdelib.github.io/VoronoiFVM.jl/stable/devel/#ReTest
2+
3+
module VoronoiFVMReTest
4+
using ReTest
5+
include("alltests.jl")
6+
end

test/alltests.jl

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using ExplicitImports, Aqua
2+
using ExampleJuggler: ExampleJuggler, cleanexamples, @testmodules, @testscripts
3+
using VoronoiFVM: VoronoiFVM
4+
5+
ExampleJuggler.verbose!(true)
6+
#
7+
# Include all Julia files in `testdir` whose name starts with `prefix`,
8+
# Each file `prefixModName.jl` must contain a module named
9+
# `prefixModName` which has a method test() returning true
10+
# or false depending on success.
11+
#
12+
function run_tests_from_directory(testdir, prefix)
13+
@info "Directory $(testdir):"
14+
examples = filter(ex -> length(ex) >= length(prefix) && ex[1:length(prefix)] == prefix, basename.(readdir(testdir)))
15+
@info examples
16+
@testmodules(testdir, examples)
17+
return nothing
18+
end
19+
20+
@testset "basictest" begin
21+
run_tests_from_directory(@__DIR__, "test_")
22+
end
23+
24+
@testset "Development Examples" begin
25+
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example0")
26+
end
27+
@testset "MultiD Examples" begin
28+
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example5")
29+
end
30+
@testset "1D Examples" begin
31+
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example1")
32+
end
33+
@testset "2D Examples" begin
34+
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example2")
35+
end
36+
37+
@testset "3D Examples" begin
38+
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example3")
39+
end
40+
41+
@testset "Misc Examples" begin
42+
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example4")
43+
end
44+
45+
# Run the notebooks as scripts in the test environment.
46+
notebooks = [
47+
"nbproto.jl",
48+
"api-update.jl",
49+
"ode-diffusion1d.jl",
50+
"ode-wave1d.jl",
51+
"ode-nlstorage1d.jl",
52+
"ode-brusselator.jl",
53+
"outflow.jl",
54+
"flux-reconstruction.jl",
55+
"interfaces1d.jl",
56+
"problemcase.jl",
57+
"nonlinear-solvers.jl",
58+
"heterogeneous-catalysis.jl",
59+
]
60+
@testset "Notebooks" begin
61+
@testscripts(joinpath(@__DIR__, "..", "pluto-examples"), notebooks)
62+
end
63+
64+
@testset "ExplicitImports" begin
65+
@test ExplicitImports.check_no_implicit_imports(VoronoiFVM) === nothing
66+
@test ExplicitImports.check_no_stale_explicit_imports(VoronoiFVM) === nothing
67+
end
68+
69+
@testset "Aqua" begin
70+
Aqua.test_ambiguities(VoronoiFVM, broken = true)
71+
Aqua.test_unbound_args(VoronoiFVM)
72+
Aqua.test_undefined_exports(VoronoiFVM)
73+
Aqua.test_project_extras(VoronoiFVM)
74+
Aqua.test_stale_deps(VoronoiFVM)
75+
Aqua.test_deps_compat(VoronoiFVM)
76+
Aqua.test_piracies(VoronoiFVM, broken = true)
77+
Aqua.test_persistent_tasks(VoronoiFVM)
78+
end
79+
80+
@testset "UndocumentedNames" begin
81+
if isdefined(Docs, :undocumented_names) # >=1.11
82+
@test isempty(Docs.undocumented_names(VoronoiFVM))
83+
end
84+
end

test/runtests.jl

Lines changed: 2 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,2 @@
1-
using Test, ExplicitImports, Aqua
2-
using ExampleJuggler: ExampleJuggler, cleanexamples, @testmodules, @testscripts
3-
using VoronoiFVM: VoronoiFVM
4-
5-
ExampleJuggler.verbose!(true)
6-
#
7-
# Include all Julia files in `testdir` whose name starts with `prefix`,
8-
# Each file `prefixModName.jl` must contain a module named
9-
# `prefixModName` which has a method test() returning true
10-
# or false depending on success.
11-
#
12-
function run_tests_from_directory(testdir, prefix)
13-
@info "Directory $(testdir):"
14-
examples = filter(ex -> length(ex) >= length(prefix) && ex[1:length(prefix)] == prefix, basename.(readdir(testdir)))
15-
@info examples
16-
@testmodules(testdir, examples)
17-
return nothing
18-
end
19-
20-
function run_all_tests(; run_notebooks = false, notebooksonly = false)
21-
if !notebooksonly
22-
@testset "basictest" begin
23-
run_tests_from_directory(@__DIR__, "test_")
24-
end
25-
26-
@testset "Development Examples" begin
27-
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example0")
28-
end
29-
@testset "MultiD Examples" begin
30-
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example5")
31-
end
32-
@testset "1D Examples" begin
33-
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example1")
34-
end
35-
@testset "2D Examples" begin
36-
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example2")
37-
end
38-
39-
@testset "3D Examples" begin
40-
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example3")
41-
end
42-
43-
@testset "Misc Examples" begin
44-
run_tests_from_directory(joinpath(@__DIR__, "..", "examples"), "Example4")
45-
end
46-
end
47-
48-
if run_notebooks
49-
# Run the notebooks as scripts in the test environment.
50-
notebooks = [
51-
"nbproto.jl",
52-
"api-update.jl",
53-
"ode-diffusion1d.jl",
54-
"ode-wave1d.jl",
55-
"ode-nlstorage1d.jl",
56-
"ode-brusselator.jl",
57-
"outflow.jl",
58-
"flux-reconstruction.jl",
59-
"interfaces1d.jl",
60-
"problemcase.jl",
61-
"nonlinear-solvers.jl",
62-
"heterogeneous-catalysis.jl",
63-
]
64-
@testset "Notebooks" begin
65-
@testscripts(joinpath(@__DIR__, "..", "pluto-examples"), notebooks)
66-
end
67-
end
68-
69-
@testset "ExplicitImports" begin
70-
@test ExplicitImports.check_no_implicit_imports(VoronoiFVM) === nothing
71-
@test ExplicitImports.check_no_stale_explicit_imports(VoronoiFVM) === nothing
72-
end
73-
74-
@testset "Aqua" begin
75-
Aqua.test_ambiguities(VoronoiFVM, broken = true)
76-
Aqua.test_unbound_args(VoronoiFVM)
77-
Aqua.test_undefined_exports(VoronoiFVM)
78-
Aqua.test_project_extras(VoronoiFVM)
79-
Aqua.test_stale_deps(VoronoiFVM)
80-
Aqua.test_deps_compat(VoronoiFVM)
81-
Aqua.test_piracies(VoronoiFVM, broken = true)
82-
Aqua.test_persistent_tasks(VoronoiFVM)
83-
end
84-
85-
if isdefined(Docs, :undocumented_names) # >=1.11
86-
@testset "UndocumentedNames" begin
87-
@test isempty(Docs.undocumented_names(VoronoiFVM))
88-
end
89-
end
90-
return nothing
91-
end
92-
93-
if haskey(ENV, "EXAMPLES_ONLY")
94-
run_all_tests(; run_notebooks = false, notebooksonly = false)
95-
elseif haskey(ENV, "NOTEBOOKS_ONLY")
96-
run_all_tests(; run_notebooks = true, notebooksonly = true)
97-
else
98-
run_all_tests(; run_notebooks = true, notebooksonly = false)
99-
end
1+
using Test
2+
include("alltests.jl")

0 commit comments

Comments
 (0)