Mercurial > repos > public > sbplib_julia
comparison test/runtests.jl @ 750:f88b2117dc69 feature/laplace_opset
Merge in default
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Fri, 19 Mar 2021 16:52:53 +0100 |
| parents | 988e9cfcd58d e279c53eb647 |
| children | ff0ef711c388 |
comparison
equal
deleted
inserted
replaced
| 723:c16abc564b82 | 750:f88b2117dc69 |
|---|---|
| 1 include("test_utils.jl") | 1 include("test_utils.jl") |
| 2 using Test | 2 using Test |
| 3 using TestSetExtensions | 3 using Glob |
| 4 | 4 |
| 5 @testset "All" begin | 5 """ |
| 6 @includetests ARGS | 6 run_testfiles() |
| 7 run_testfiles(path, globs) | |
| 8 | |
| 9 Find and run all files with filenames ending with "_test.jl". If `path` is omitted the test folder is assumed. | |
| 10 The argument `globs` can optionally be supplied to filter which test files are run. | |
| 11 """ | |
| 12 function run_testfiles(args) | |
| 13 if isempty(args) | |
| 14 globs = [fn"./*"] | |
| 15 else | |
| 16 globs = Glob.FilenameMatch.("./".*args) | |
| 17 end | |
| 18 | |
| 19 run_testfiles(".", globs) | |
| 7 end | 20 end |
| 21 | |
| 22 function run_testfiles(path, globs) | |
| 23 for name ∈ readdir(path) | |
| 24 filepath = joinpath(path, name) | |
| 25 | |
| 26 if isdir(filepath) | |
| 27 @testset "$name" begin | |
| 28 run_testfiles(filepath, globs) | |
| 29 end | |
| 30 end | |
| 31 | |
| 32 if endswith(name, "_test.jl") && any(occursin.(globs, filepath)) | |
| 33 printstyled("Running "; bold=true, color=:green) | |
| 34 print(filepath) | |
| 35 | |
| 36 t_start = time() | |
| 37 @testset "$name" begin | |
| 38 include(filepath) | |
| 39 end | |
| 40 t_end = time() | |
| 41 | |
| 42 Δt = t_end - t_start | |
| 43 printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black) | |
| 44 println() | |
| 45 end | |
| 46 end | |
| 47 end | |
| 48 | |
| 49 testsetname = isempty(ARGS) ? "Sbplib.jl" : "["*join(ARGS, ", ")*"]" | |
| 50 | |
| 51 @testset "$testsetname" begin | |
| 52 run_testfiles(ARGS) | |
| 53 end |
