Mercurial > repos > public > sbplib_julia
diff test/runtests.jl @ 1853:a12708e48499
Merge feature/jet_aqua
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 11 Jan 2025 10:17:12 +0100 |
parents | 6a56a853271d |
children |
line wrap: on
line diff
--- a/test/runtests.jl Fri Jan 10 20:22:04 2025 +0100 +++ b/test/runtests.jl Sat Jan 11 10:17:12 2025 +0100 @@ -1,4 +1,7 @@ +using Diffinitive using Test +using JET +using Aqua using Glob """ @@ -18,7 +21,7 @@ run_testfiles(".", globs) end -function run_testfiles(path, globs) +function run_testfiles(path, globs) for name ∈ readdir(path) filepath = joinpath(path, name) @@ -29,25 +32,44 @@ 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) + log_and_time(filepath) do + @testset "$name" begin + include(filepath) + end end - t_end = time() - - Δt = t_end - t_start - printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black) - println() end end end +function log_and_time(f, msg) + printstyled("Running "; bold=true, color=:green) + print(msg) + + t_start = time() + f() + t_end = time() + Δt = t_end - t_start + printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black) + println() +end + testsetname = isempty(ARGS) ? "Diffinitive.jl" : "["*join(ARGS, ", ")*"]" @testset "$testsetname" begin + if isempty(ARGS) + log_and_time("code quality tests using Aqua.jl") do + @testset "Code quality (Aqua.jl)" begin + Aqua.test_all(Diffinitive) + end + end + + log_and_time("code linting using JET.jl") do + @testset "Code linting (JET.jl)" begin + JET.test_package(Diffinitive; target_defined_modules = true) + end + end + end + run_testfiles(ARGS) println() end