|
1 | 1 | using SafeTestsets: @safetestset |
2 | | -using Suppressor: Suppressor |
3 | 2 |
|
4 | 3 | # check for filtered groups |
5 | 4 | # either via `--group=ALL` or through ENV["GROUP"] |
6 | 5 | const pat = r"(?:--group=)(\w+)" |
7 | 6 | arg_id = findfirst(contains(pat), ARGS) |
8 | | -const GROUP = uppercase( |
9 | | - if isnothing(arg_id) |
10 | | - get(ENV, "GROUP", "ALL") |
11 | | - else |
12 | | - only(match(pat, ARGS[arg_id]).captures) |
13 | | - end, |
14 | | -) |
| 7 | +const GROUP = uppercase(if isnothing(arg_id) |
| 8 | + get(ENV, "GROUP", "ALL") |
| 9 | + else |
| 10 | + only(match(pat, ARGS[arg_id]).captures) |
| 11 | + end) |
15 | 12 |
|
16 | 13 | "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") |
| 14 | +istestfile(fn) = endswith(fn, ".jl") && startswith(basename(fn), "test_") && |
| 15 | + !contains(fn, "setup") |
22 | 16 |
|
23 | 17 | @time begin |
24 | | - # tests in groups based on folder structure |
25 | | - for testgroup in filter(isdir, readdir(@__DIR__)) |
26 | | - if GROUP == "ALL" || GROUP == uppercase(testgroup) |
27 | | - groupdir = joinpath(@__DIR__, testgroup) |
28 | | - for file in filter(istestfile, readdir(groupdir)) |
29 | | - filename = joinpath(groupdir, file) |
30 | | - @eval @safetestset $file begin |
31 | | - include($filename) |
| 18 | + # tests in groups based on folder structure |
| 19 | + for testgroup in filter(isdir, readdir(@__DIR__)) |
| 20 | + if GROUP == "ALL" || GROUP == uppercase(testgroup) |
| 21 | + groupdir = joinpath(@__DIR__, testgroup) |
| 22 | + for file in filter(istestfile, readdir(groupdir)) |
| 23 | + filename = joinpath(groupdir, file) |
| 24 | + @eval @safetestset $file begin |
| 25 | + include($filename) |
| 26 | + end |
| 27 | + end |
32 | 28 | end |
33 | | - end |
34 | | - end |
35 | | - end |
36 | | - |
37 | | - # single files in top folder |
38 | | - for file in filter(istestfile, readdir(@__DIR__)) |
39 | | - (file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion |
40 | | - @eval @safetestset $file begin |
41 | | - include($file) |
42 | 29 | end |
43 | | - end |
44 | 30 |
|
45 | | - # test examples |
46 | | - examplepath = joinpath(@__DIR__, "..", "examples") |
47 | | - for (root, _, files) in walkdir(examplepath) |
48 | | - contains(chopprefix(root, @__DIR__), "setup") && continue |
49 | | - for file in filter(isexamplefile, files) |
50 | | - filename = joinpath(root, file) |
51 | | - @eval begin |
52 | | - @safetestset $file begin |
53 | | - $(Expr( |
54 | | - :macrocall, |
55 | | - GlobalRef(Suppressor, Symbol("@suppress")), |
56 | | - LineNumberNode(@__LINE__, @__FILE__), |
57 | | - :(include($filename)), |
58 | | - )) |
| 31 | + # single files in top folder |
| 32 | + for file in filter(istestfile, readdir(@__DIR__)) |
| 33 | + (file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion |
| 34 | + @eval @safetestset $file begin |
| 35 | + include($file) |
59 | 36 | end |
60 | | - end |
61 | 37 | end |
62 | | - end |
63 | 38 | end |
0 commit comments