Skip to content

Commit

Permalink
Skeleton updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Dec 12, 2024
1 parent 3b5f416 commit c99a04a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
32 changes: 22 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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
Expand All @@ -33,17 +34,28 @@ 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
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

0 comments on commit c99a04a

Please sign in to comment.