2017-08-21 15:45:23 +05:30
|
|
|
#! /usr/bin/scheme-script
|
|
|
|
|
2017-08-21 15:23:23 +05:30
|
|
|
(import (rnrs)
|
|
|
|
(fmt fmt)
|
2017-08-15 20:37:45 +05:30
|
|
|
(functional-tests)
|
2017-08-17 20:54:10 +05:30
|
|
|
(cache-functional-tests)
|
2017-08-21 15:23:23 +05:30
|
|
|
(only (srfi s1 lists) break)
|
|
|
|
(srfi s8 receive)
|
2017-08-15 20:37:45 +05:30
|
|
|
(thin-functional-tests))
|
|
|
|
|
2017-08-21 15:23:23 +05:30
|
|
|
;;------------------------------------------------
|
|
|
|
|
|
|
|
(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)))
|
|
|
|
|
2017-08-21 16:03:44 +05:30
|
|
|
(define (mk-single-filter pattern)
|
2017-08-21 15:23:23 +05:30
|
|
|
(let ((prefix (string->syms pattern #\/)))
|
|
|
|
(lambda (keys)
|
|
|
|
(begins-with prefix keys))))
|
|
|
|
|
2017-08-21 16:03:44 +05:30
|
|
|
(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)))))
|
|
|
|
|
2017-08-21 15:23:23 +05:30
|
|
|
;;------------------------------------------------
|
|
|
|
|
2017-08-15 20:37:45 +05:30
|
|
|
(register-thin-tests)
|
2017-08-17 20:54:10 +05:30
|
|
|
(register-cache-tests)
|
2017-08-21 14:48:10 +05:30
|
|
|
|
2017-08-21 16:03:44 +05:30
|
|
|
(let ((pred (mk-filter (cdr (command-line)))))
|
|
|
|
(if (run-scenarios (filter pred (list-scenarios)))
|
2017-08-21 14:48:10 +05:30
|
|
|
(exit)
|
2017-08-21 16:03:44 +05:30
|
|
|
(exit #f)))
|
2017-08-15 20:37:45 +05:30
|
|
|
|