Mercurial > repos > public > sbplib_julia
comparison test/runtests.jl @ 1765:5e4b2f8e9bf9 feature/jet_aqua
Improve logging when running tests
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Fri, 13 Sep 2024 21:52:06 +0200 |
| parents | c1ebc96961a2 |
| children | 6a56a853271d |
comparison
equal
deleted
inserted
replaced
| 1764:d207e1abacc1 | 1765:5e4b2f8e9bf9 |
|---|---|
| 30 run_testfiles(filepath, globs) | 30 run_testfiles(filepath, globs) |
| 31 end | 31 end |
| 32 end | 32 end |
| 33 | 33 |
| 34 if endswith(name, "_test.jl") && any(occursin.(globs, filepath)) | 34 if endswith(name, "_test.jl") && any(occursin.(globs, filepath)) |
| 35 printstyled("Running "; bold=true, color=:green) | 35 log_and_time(filepath) do |
| 36 print(filepath) | 36 @testset "$name" begin |
| 37 | 37 include(filepath) |
| 38 t_start = time() | 38 end |
| 39 @testset "$name" begin | |
| 40 include(filepath) | |
| 41 end | 39 end |
| 42 t_end = time() | |
| 43 | |
| 44 Δt = t_end - t_start | |
| 45 printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black) | |
| 46 println() | |
| 47 end | 40 end |
| 48 end | 41 end |
| 42 end | |
| 43 | |
| 44 function log_and_time(f, msg) | |
| 45 printstyled("Running "; bold=true, color=:green) | |
| 46 print(msg) | |
| 47 | |
| 48 t_start = time() | |
| 49 f() | |
| 50 t_end = time() | |
| 51 Δt = t_end - t_start | |
| 52 printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black) | |
| 53 println() | |
| 49 end | 54 end |
| 50 | 55 |
| 51 testsetname = isempty(ARGS) ? "Diffinitive.jl" : "["*join(ARGS, ", ")*"]" | 56 testsetname = isempty(ARGS) ? "Diffinitive.jl" : "["*join(ARGS, ", ")*"]" |
| 52 | 57 |
| 53 @testset "$testsetname" begin | 58 @testset "$testsetname" begin |
| 54 if isempty(ARGS) | 59 if isempty(ARGS) |
| 55 @testset "Code quality (Aqua.jl)" begin | 60 log_and_time("code quality tests using Aqua.jl") do |
| 56 Aqua.test_all(Diffinitive) | 61 @testset "Code quality (Aqua.jl)" begin |
| 62 Aqua.test_all(Diffinitive) | |
| 63 end | |
| 57 end | 64 end |
| 58 @testset "Code linting (JET.jl)" begin | 65 |
| 59 JET.test_package(Diffinitive; target_defined_modules = true) | 66 log_and_time("code linting using JET.jl") do |
| 67 @testset "Code linting (JET.jl)" begin | |
| 68 JET.test_package(Diffinitive; target_defined_modules = true) | |
| 69 end | |
| 60 end | 70 end |
| 61 end | 71 end |
| 62 | 72 |
| 63 run_testfiles(ARGS) | 73 run_testfiles(ARGS) |
| 64 println() | 74 println() |
