diff --git a/test/runtests.jl b/test/runtests.jl index 1140eea..49028f8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,11 +13,14 @@ const GROUP = uppercase( end, ) -function istestfile(filename) - return isfile(filename) && - endswith(filename, ".jl") && - startswith(basename(filename), "test") -end +isjlfile(fn) = isfile(fn) && endswith(fn, ".jl") +issetupfile(fn) = any(contains("setup"), splitpath(fn)) + +"match files of the form `**/test_*.jl`, but exclude `**/*setup*/*.jl` and `**/*setup*.jl`" +istestfile(fn) = isjlfile(fn) && startswith(basename(fn), "test_") && !issetupfile(fn) + +"match files of the form `**/*.jl`, but exclude `**/*_notest.jl`, `**/*setup*/*.jl` and `**/*setup*.jl`" +isexamplefile(fn) = isjlfile(fn) && !endswith(fn, "_notest.jl") && !issetupfile(fn) @time begin # tests in groups based on folder structure @@ -33,7 +36,7 @@ end # single files in top folder for file in filter(istestfile, readdir(@__DIR__)) - (file == basename(@__FILE__)) && continue + (file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion @eval @safetestset $file begin include($file) end @@ -41,10 +44,9 @@ end # test examples examplepath = joinpath(@__DIR__, "..", "examples") - for file in filter(endswith(".jl"), readdir(examplepath; join=true)) - filename = basename(file) + for file in filter(isexamplefile, readdir(examplepath; join=true)) @eval begin - @safetestset $filename begin + @safetestset $(basename(file)) begin $(Expr( :macrocall, GlobalRef(Suppressor, Symbol("@suppress")),