Skip to content

Commit

Permalink
testfiles start with test_
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Dec 4, 2024
1 parent 5c3ab3f commit f13bc27
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
File renamed without changes.
15 changes: 11 additions & 4 deletions templates/test/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ const GROUP = uppercase(
end,
)

function istestfile(filename)
return isfile(filename) &&
endswith(filename, ".jl") &&
startswith(basename(filename), "test")
end

@time begin
# tests in groups based on folder structure
for testgroup in filter(isdir, readdir(@__DIR__))
if GROUP == "ALL" || GROUP == uppercase(testgroup)
for file in readdir(joinpath(@__DIR__, testgroup); join=true)
for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true))
@eval @safetestset $file begin
include($file)
end
Expand All @@ -26,7 +32,8 @@ const GROUP = uppercase(
end

# single files in top folder
for file in filter(isfile, readdir(@__DIR__))
for file in filter(istestfile, readdir(@__DIR__))
(file == basename(@__FILE__)) && continue
@eval @safetestset $file begin
include($file)
end
Expand All @@ -35,8 +42,8 @@ const GROUP = uppercase(
# test examples
examplepath = joinpath(@__DIR__, "..", "examples")
for file in filter(endswith(".jl"), readdir(examplepath; join=true))
@eval @safetestset $file begin
@suppress include($file)
@suppress @eval @safetestset $file begin
include($file)
end
end
end
10 changes: 8 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ const GROUP = uppercase(
end,
)

function istestfile(filename)
return isfile(filename) &&
endswith(filename, ".jl") &&
startswith(basename(filename), "test")
end

@time begin
# tests in groups based on folder structure
for testgroup in filter(isdir, readdir(@__DIR__))
if GROUP == "ALL" || GROUP == uppercase(testgroup)
for file in readdir(joinpath(@__DIR__, testgroup); join=true)
for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true))
@eval @safetestset $file begin
include($file)
end
Expand All @@ -26,7 +32,7 @@ const GROUP = uppercase(
end

# single files in top folder
for file in filter(isfile, readdir(@__DIR__))
for file in filter(istestfile, readdir(@__DIR__))
(file == basename(@__FILE__)) && continue
@eval @safetestset $file begin
include($file)
Expand Down

0 comments on commit f13bc27

Please sign in to comment.