diff 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
line wrap: on
line diff
--- a/test/runtests.jl	Wed Mar 17 10:20:05 2021 +0100
+++ b/test/runtests.jl	Fri Mar 19 16:52:53 2021 +0100
@@ -1,7 +1,53 @@
 include("test_utils.jl")
 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