-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split tests into groups + SafeTestsets #30
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0aef614
Move test dependencies
lkdvos 77757dc
reorganise tests into groups
lkdvos dc5cf3e
update structure
lkdvos 4372ca3
apply generate
lkdvos 64360a9
Fix typo
lkdvos b148014
assign group names to single tests and examples
lkdvos 76ea53e
Fix project
lkdvos 79255d6
fix test syntax
lkdvos 6cd80e4
Actually fix syntax?
lkdvos 6a9504d
Explicitly import `@safetestset`
lkdvos 0a6af80
Fix infinite recursion
lkdvos 5c3ab3f
Fix suppressor not defined
lkdvos f13bc27
testfiles start with `test_`
lkdvos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't
@testset
report times now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I.e. could we achieve this by wrapping all of this in
@testset
or@safetestset
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure, I mostly copied this from my other workflows. I think the main difference is that
@time
also reports splits in compiletime/runtime, which I find interesting, but I have absolutely no preference about this.Just as an aside, wrapping things in nested
@testset
structures makes it such that output is only printed after all tests finish. Not a big deal, but something to keep in mind.