From c99a04a1e58013abefa1aedcfd1f299992b2987a Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 11 Dec 2024 20:03:22 -0500 Subject: [PATCH] Skeleton updates --- .pre-commit-config.yaml | 7 ++++--- test/runtests.jl | 32 ++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bff1fb7..6599365 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,8 @@ repos: - id: check-yaml - id: end-of-file-fixer exclude_types: [markdown] # incompatible with Literate.jl -- repo: https://github.com/qiaojunfeng/pre-commit-julia-format - rev: v0.2.0 + +- repo: "https://github.com/domluna/JuliaFormatter.jl" + rev: v1.0.62 hooks: - - id: julia-format + - id: "julia-formatter" diff --git a/test/runtests.jl b/test/runtests.jl index bb62115..bd97441 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,5 @@ using SafeTestsets: @safetestset -using Suppressor: @suppress +using Suppressor: Suppressor # check for filtered groups # either via `--group=ALL` or through ENV["GROUP"] @@ -13,11 +13,12 @@ const GROUP = uppercase( end, ) -function istestfile(filename) - return isfile(filename) && - endswith(filename, ".jl") && - startswith(basename(filename), "test") -end +"match files of the form `test_*.jl`, but exclude `*setup*.jl`" +istestfile(fn) = + endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup") +"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`" +isexamplefile(fn) = + endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup") @time begin # tests in groups based on folder structure @@ -33,7 +34,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,9 +42,20 @@ end # test examples examplepath = joinpath(@__DIR__, "..", "examples") - for file in filter(endswith(".jl"), readdir(examplepath; join=true)) - @suppress @eval @safetestset $file begin - include($file) + for (root, _, files) in walkdir(examplepath) + contains(chopprefix(root, @__DIR__), "setup") && continue + for file in filter(isexamplefile, files) + filename = joinpath(root, file) + @eval begin + @safetestset $file begin + $(Expr( + :macrocall, + GlobalRef(Suppressor, Symbol("@suppress")), + LineNumberNode(@__LINE__, @__FILE__), + :(include($filename)), + )) + end + end end end end