[functional-tests] You can now specify tests using a regex.
Prefix the command line arg with 're:'.
This commit is contained in:
parent
87b3556d36
commit
52f17c3230
@ -7,6 +7,7 @@
|
|||||||
(cache-functional-tests)
|
(cache-functional-tests)
|
||||||
(parser-combinators)
|
(parser-combinators)
|
||||||
(only (srfi s1 lists) break)
|
(only (srfi s1 lists) break)
|
||||||
|
(regex)
|
||||||
(srfi s8 receive)
|
(srfi s8 receive)
|
||||||
(thin-functional-tests))
|
(thin-functional-tests))
|
||||||
|
|
||||||
@ -37,18 +38,32 @@
|
|||||||
(list->string cs)))
|
(list->string cs)))
|
||||||
(split-list (string->list str) sep)))
|
(split-list (string->list str) sep)))
|
||||||
|
|
||||||
(define (mk-single-filter pattern)
|
(define (mk-string-matcher 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-regex-matcher pattern)
|
||||||
|
(let ((rx (regex pattern)))
|
||||||
|
(lambda (keys)
|
||||||
|
(rx (apply string-append
|
||||||
|
(intersperse "/"
|
||||||
|
(map symbol->string keys)))))))
|
||||||
|
|
||||||
|
;; If the filter begins with 're:' then we make a regex matcher, otherwise
|
||||||
|
;; we use a simple string matcher.
|
||||||
|
(define (mk-single-matcher pattern)
|
||||||
|
(if (string=? (substring pattern 0 3) "re:")
|
||||||
|
(mk-regex-matcher (substring pattern 3 (string-length pattern)))
|
||||||
|
(mk-string-matcher pattern)))
|
||||||
|
|
||||||
(define (mk-filter patterns)
|
(define (mk-filter patterns)
|
||||||
(if (null? patterns)
|
(if (null? patterns)
|
||||||
; accept everything if no patterns
|
; accept everything if no patterns
|
||||||
(lambda (_) #t)
|
(lambda (_) #t)
|
||||||
|
|
||||||
; Otherwise accept tests that pass a pattern
|
; Otherwise accept tests that pass a pattern
|
||||||
(let ((filters (map mk-single-filter patterns)))
|
(let ((filters (map mk-single-matcher patterns)))
|
||||||
(fold-left (lambda (fn-a fn-b)
|
(fold-left (lambda (fn-a fn-b)
|
||||||
(lambda (keys)
|
(lambda (keys)
|
||||||
(or (fn-a keys)
|
(or (fn-a keys)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user