-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split tests into groups + SafeTestsets (#30)
- Loading branch information
Showing
12 changed files
with
98 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
templates/test/test/test_basics.jl → templates/test/test/basics/test_basics.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
@eval module $(gensym()) | ||
using {PKGNAME}: {PKGNAME} | ||
using Test: @test, @testset | ||
|
||
@testset "{PKGNAME}" begin | ||
# Tests go here. | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,49 @@ | ||
@eval module $(gensym()) | ||
using Test: @testset | ||
using SafeTestsets: @safetestset | ||
using Suppressor: @suppress | ||
|
||
@testset "{PKGNAME}.jl" begin | ||
filenames = filter(readdir(@__DIR__)) do f | ||
startswith("test_")(f) && endswith(".jl")(f) | ||
# check for filtered groups | ||
# either via `--group=ALL` or through ENV["GROUP"] | ||
const pat = r"(?:--group=)(\w+)" | ||
arg_id = findfirst(contains(pat), ARGS) | ||
const GROUP = uppercase( | ||
if isnothing(arg_id) | ||
get(ENV, "GROUP", "ALL") | ||
else | ||
only(match(pat, ARGS[arg_id]).captures) | ||
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 filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true)) | ||
@eval @safetestset $file begin | ||
include($file) | ||
end | ||
end | ||
end | ||
end | ||
@testset "Test $filename" for filename in filenames | ||
include(filename) | ||
|
||
# single files in top folder | ||
for file in filter(istestfile, readdir(@__DIR__)) | ||
(file == basename(@__FILE__)) && continue | ||
@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) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
@eval module $(gensym()) | ||
using {PKGNAME}: {PKGNAME} | ||
using Aqua: Aqua | ||
using Test: @testset | ||
|
||
@testset "Code quality (Aqua.jl)" begin | ||
Aqua.test_all({PKGNAME}) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,49 @@ | ||
@eval module $(gensym()) | ||
using Test: @testset | ||
using SafeTestsets: @safetestset | ||
using Suppressor: @suppress | ||
|
||
@testset "ITensorPkgSkeleton.jl" begin | ||
filenames = filter(readdir(@__DIR__)) do f | ||
startswith("test_")(f) && endswith(".jl")(f) | ||
# check for filtered groups | ||
# either via `--group=ALL` or through ENV["GROUP"] | ||
const pat = r"(?:--group=)(\w+)" | ||
arg_id = findfirst(contains(pat), ARGS) | ||
const GROUP = uppercase( | ||
if isnothing(arg_id) | ||
get(ENV, "GROUP", "ALL") | ||
else | ||
only(match(pat, ARGS[arg_id]).captures) | ||
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 filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true)) | ||
@eval @safetestset $file begin | ||
include($file) | ||
end | ||
end | ||
end | ||
end | ||
@testset "Test $filename" for filename in filenames | ||
include(filename) | ||
|
||
# single files in top folder | ||
for file in filter(istestfile, readdir(@__DIR__)) | ||
(file == basename(@__FILE__)) && continue | ||
@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) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
@eval module $(gensym()) | ||
using ITensorPkgSkeleton: ITensorPkgSkeleton | ||
using Aqua: Aqua | ||
using Test: @testset | ||
|
||
@testset "Code quality (Aqua.jl)" begin | ||
Aqua.test_all(ITensorPkgSkeleton) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.