1
1
using SafeTestsets: @safetestset
2
- using Suppressor: @suppress
2
+ using Suppressor: Suppressor
3
3
4
4
# check for filtered groups
5
5
# either via `--group=ALL` or through ENV["GROUP"]
@@ -13,11 +13,12 @@ const GROUP = uppercase(
13
13
end ,
14
14
)
15
15
16
- function istestfile (filename)
17
- return isfile (filename) &&
18
- endswith (filename, " .jl" ) &&
19
- startswith (basename (filename), " test" )
20
- end
16
+ " match files of the form `test_*.jl`, but exclude `*setup*.jl`"
17
+ istestfile (fn) =
18
+ endswith (fn, " .jl" ) && startswith (basename (fn), " test_" ) && ! contains (fn, " setup" )
19
+ " match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
20
+ isexamplefile (fn) =
21
+ endswith (fn, " .jl" ) && ! endswith (fn, " _notest.jl" ) && ! contains (fn, " setup" )
21
22
22
23
@time begin
23
24
# tests in groups based on folder structure
33
34
34
35
# single files in top folder
35
36
for file in filter (istestfile, readdir (@__DIR__ ))
36
- (file == basename (@__FILE__ )) && continue
37
+ (file == basename (@__FILE__ )) && continue # exclude this file to avoid infinite recursion
37
38
@eval @safetestset $ file begin
38
39
include ($ file)
39
40
end
40
41
end
41
42
42
43
# test examples
43
44
examplepath = joinpath (@__DIR__ , " .." , " examples" )
44
- for file in filter (endswith (" .jl" ), readdir (examplepath; join= true ))
45
- @suppress @eval @safetestset $ file begin
46
- include ($ file)
45
+ for (root, _, files) in walkdir (examplepath)
46
+ contains (chopprefix (root, @__DIR__ ), " setup" ) && continue
47
+ for file in filter (isexamplefile, files)
48
+ filename = joinpath (root, file)
49
+ @eval begin
50
+ @safetestset $ file begin
51
+ $ (Expr (
52
+ :macrocall ,
53
+ GlobalRef (Suppressor, Symbol (" @suppress" )),
54
+ LineNumberNode (@__LINE__ , @__FILE__ ),
55
+ :(include ($ filename)),
56
+ ))
57
+ end
58
+ end
47
59
end
48
60
end
49
61
end
0 commit comments