From ba7f5e072f8650e138ac380708c987e66835993b Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Mon, 21 Aug 2017 10:53:23 +0100 Subject: [PATCH] [functional-tests] run-functional-tests now takes a filter command line --- functional-tests/run-functional-tests.scm | 42 +++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/functional-tests/run-functional-tests.scm b/functional-tests/run-functional-tests.scm index 016e065..c321cba 100644 --- a/functional-tests/run-functional-tests.scm +++ b/functional-tests/run-functional-tests.scm @@ -1,12 +1,50 @@ -(import (chezscheme) +(import (rnrs) + (fmt fmt) (functional-tests) (cache-functional-tests) + (only (srfi s1 lists) break) + (srfi s8 receive) (thin-functional-tests)) +;;------------------------------------------------ + +(define (begins-with prefix xs) + (cond + ((null? prefix) #t) + ((null? xs) #f) + ((eq? (car prefix) (car xs)) + (begins-with (cdr prefix) (cdr xs))) + (else #f))) + +(define (split-list xs sep) + (define (safe-cdr xs) + (if (null? xs) '() (cdr xs))) + + (if (null? xs) + '() + (receive (p r) (break (lambda (c) + (eq? c sep)) + xs) + (cons p (split-list (safe-cdr r) sep))))) + +(define (string->syms str sep) + (map (lambda (cs) + (string->symbol + (list->string cs))) + (split-list (string->list str) sep))) + +(define (mk-filter pattern) + (let ((prefix (string->syms pattern #\/))) + (lambda (keys) + (begins-with prefix keys)))) + +;;------------------------------------------------ + (register-thin-tests) (register-cache-tests) -(if (run-scenarios (list-scenarios)) +(if (run-scenarios (filter (mk-filter (car (cdr (command-line)))) + (list-scenarios))) (exit) (exit #f))