Skip to content

Commit

Permalink
setup file logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Dec 9, 2024
1 parent 95cddfa commit 4079bdb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,18 +36,17 @@ 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))
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")),
Expand Down

0 comments on commit 4079bdb

Please sign in to comment.