aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-07 01:24:05 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-07 21:20:13 +0200
commit34a732ae8e1682b5825970dab6e27ed305626b3a (patch)
treef5cede104bb57f92eb8c73e7aa8f41ac018e5d6e
parentBetter expected/actual printing in tests. (diff)
downloadcalp-34a732ae8e1682b5825970dab6e27ed305626b3a.tar.gz
calp-34a732ae8e1682b5825970dab6e27ed305626b3a.tar.xz
Tests allows multiple --only and --skip.
-rwxr-xr-xtests/run-tests.scm39
1 files changed, 33 insertions, 6 deletions
diff --git a/tests/run-tests.scm b/tests/run-tests.scm
index d868fd2c..3955a6a2 100755
--- a/tests/run-tests.scm
+++ b/tests/run-tests.scm
@@ -27,6 +27,7 @@ fi
(ice-9 pretty-print)
(ice-9 getopt-long)
(ice-9 match)
+ (ice-9 regex)
(system vm coverage)
((all-modules) :select (fs-find))
)
@@ -224,9 +225,6 @@ fi
;; (format #t "Running on:~%~y~%" files)
-(awhen (option-ref options 'only #f)
- (set! files (list (path-append "test" it))))
-
((@ (hnh util exceptions) warnings-are-errors) #t)
@@ -261,9 +259,38 @@ fi
(test-begin "suite")
-(awhen (option-ref options 'skip #f)
- (format #t "Skipping ~s~%" it)
- (test-skip it))
+
+(define onlies
+ (let %loop ((args (command-line)) (onlies '()))
+ (define* (loop args key: only)
+ (if only
+ (%loop args (cons only onlies))
+ (%loop args onlies)))
+ (if (null? args)
+ onlies
+ (cond ((string-match "^--skip(=.*)?$" (car args))
+ => (lambda (m)
+ (cond ((match:substring m 1)
+ => (lambda (s)
+ (format #t "Skipping ~s~%" s)
+ (test-skip s)
+ (loop (cdr args))))
+ (else (format #t "Skipping ~s~%" (cadr args))
+ (test-skip (cadr args))
+ (loop (cddr args))))))
+ ((string-match "^--only(=.*)?$" (car args))
+ => (lambda (m)
+ (cond ((match:substring m 1)
+ => (lambda (s)
+ (loop (cdr args) only: s)))
+ (else (loop (cddr args) only: (cadr args))))))
+ (else (loop (cdr args)))))))
+
+(unless (null? onlies)
+ (set! files
+ (map (lambda (x) (path-append "test" x))
+ ;; reverse only until I have built a dependency graph for tests
+ (reverse onlies))))
(finalizer (lambda () (for-each (lambda (f) (catch/print-trace (lambda () (test-group f (load f)))))
files)))