Mercurial > repos > public > sbplib_julia
diff test/runtests.jl @ 769:0158c3fd521c operator_storage_array_of_table
Merge in default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 15 Jul 2021 00:06:16 +0200 |
parents | e279c53eb647 |
children | f88b2117dc69 e7176fb09e98 |
line wrap: on
line diff
--- a/test/runtests.jl Wed Jul 14 23:40:10 2021 +0200 +++ b/test/runtests.jl Thu Jul 15 00:06:16 2021 +0200 @@ -1,6 +1,52 @@ using Test -using TestSetExtensions +using Glob + +""" + run_testfiles() + run_testfiles(path, globs) + +Find and run all files with filenames ending with "_test.jl". If `path` is omitted the test folder is assumed. +The argument `globs` can optionally be supplied to filter which test files are run. +""" +function run_testfiles(args) + if isempty(args) + globs = [fn"./*"] + else + globs = Glob.FilenameMatch.("./".*args) + end + + run_testfiles(".", globs) +end + +function run_testfiles(path, globs) + for name ∈ readdir(path) + filepath = joinpath(path, name) -@testset "All" begin - @includetests ARGS + if isdir(filepath) + @testset "$name" begin + run_testfiles(filepath, globs) + end + end + + if endswith(name, "_test.jl") && any(occursin.(globs, filepath)) + printstyled("Running "; bold=true, color=:green) + print(filepath) + + t_start = time() + @testset "$name" begin + include(filepath) + end + t_end = time() + + Δt = t_end - t_start + printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black) + println() + end + end end + +testsetname = isempty(ARGS) ? "Sbplib.jl" : "["*join(ARGS, ", ")*"]" + +@testset "$testsetname" begin + run_testfiles(ARGS) +end