Mercurial > repos > public > sbplib_julia
comparison test/runtests.jl @ 711:df88aee35bb9 feature/selectable_tests
Switch to _test.jl suffix
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Sat, 20 Feb 2021 20:45:40 +0100 |
| parents | 48a61e085e60 |
| children | be648c6d6686 |
comparison
equal
deleted
inserted
replaced
| 710:44fa9a171557 | 711:df88aee35bb9 |
|---|---|
| 4 """ | 4 """ |
| 5 run_testfiles() | 5 run_testfiles() |
| 6 run_testfiles(path) | 6 run_testfiles(path) |
| 7 run_testfiles(path, glob) | 7 run_testfiles(path, glob) |
| 8 | 8 |
| 9 Find and run all files with filenames starting with "test". If `path` is omitted the test folder is assumed. | 9 Find and run all files with filenames ending with "_test.jl". If `path` is omitted the test folder is assumed. |
| 10 The argument `glob` can optionally be supplied to filter which test files are run. | 10 The argument `glob` can optionally be supplied to filter which test files are run. |
| 11 """ | 11 """ |
| 12 function run_testfiles(args) | 12 function run_testfiles(args) |
| 13 if isempty(args) | 13 if isempty(args) |
| 14 glob = fn"./*" | 14 glob = fn"./*" |
| 17 end | 17 end |
| 18 | 18 |
| 19 run_testfiles(".", glob) | 19 run_testfiles(".", glob) |
| 20 end | 20 end |
| 21 | 21 |
| 22 # TODO change from prefix `test` to suffix `_test` for testfiles | |
| 23 function run_testfiles(path, glob) | 22 function run_testfiles(path, glob) |
| 24 for name ∈ readdir(path) | 23 for name ∈ readdir(path) |
| 25 filepath = joinpath(path, name) | 24 filepath = joinpath(path, name) |
| 26 | 25 |
| 27 if isdir(filepath) | 26 if isdir(filepath) |
| 28 @testset "$name" begin | 27 @testset "$name" begin |
| 29 run_testfiles(filepath, glob) | 28 run_testfiles(filepath, glob) |
| 30 end | 29 end |
| 31 end | 30 end |
| 32 | 31 |
| 33 if !endswith(name, ".jl") ## TODO combine this into test below when switching to suffix | 32 if endswith(name, "_test.jl") && occursin(glob, filepath) |
| 34 continue | |
| 35 end | |
| 36 | |
| 37 if startswith(name, "test") && occursin(glob, filepath) | |
| 38 printstyled("Running "; bold=true, color=:green) | 33 printstyled("Running "; bold=true, color=:green) |
| 39 println(filepath) | 34 println(filepath) |
| 40 include(filepath) | 35 include(filepath) |
| 41 end | 36 end |
| 42 end | 37 end |
