[functionl-tests] allow multiple patterns on the run-test command line

This commit is contained in:
Joe Thornber 2017-08-21 11:33:44 +01:00
parent b0a9ac7fcf
commit a51aeb29a1

View File

@ -35,18 +35,32 @@
(list->string cs))) (list->string cs)))
(split-list (string->list str) sep))) (split-list (string->list str) sep)))
(define (mk-filter pattern) (define (mk-single-filter pattern)
(let ((prefix (string->syms pattern #\/))) (let ((prefix (string->syms pattern #\/)))
(lambda (keys) (lambda (keys)
(begins-with prefix keys)))) (begins-with prefix keys))))
(define (mk-filter patterns)
(if (null? patterns)
; accept everything if no patterns
(lambda (_) #t)
; Otherwise accept tests that pass a pattern
(let ((filters (map mk-single-filter patterns)))
(fold-left (lambda (fn-a fn-b)
(lambda (keys)
(or (fn-a keys)
(fn-b keys))))
(car filters)
(cdr filters)))))
;;------------------------------------------------ ;;------------------------------------------------
(register-thin-tests) (register-thin-tests)
(register-cache-tests) (register-cache-tests)
(if (run-scenarios (filter (mk-filter (car (cdr (command-line)))) (let ((pred (mk-filter (cdr (command-line)))))
(list-scenarios))) (if (run-scenarios (filter pred (list-scenarios)))
(exit) (exit)
(exit #f)) (exit #f)))