270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
|
(else ;; not waiting on items, waiting on entire waiton test.
(let* ((patts (string-split test-patt ","))
(new-patts (if (member waiton-test patts)
patts
(cons waiton-test patts))))
(string-intersperse (delete-duplicates new-patts) ",")))))
(define *glob-like-match-cache* (make-hash-table))
(define (tests:cache-regexp str-in flag)
(let* ((key (conc str-in flag)))
(or (hash-table-ref/default *glob-like-match-cache* key #f)
(let* ((newrx (regexp str-in flag)))
(hash-table-set! *glob-like-match-cache* key newrx)
newrx))))
;; tests:glob-like-match
(define (tests:glob-like-match patt str)
(let ((like (substring-index "%" patt)))
(let* ((notpatt (equal? (substring-index "~" patt) 0))
(newpatt (if notpatt (substring patt 1) patt))
(finpatt (if like
(string-substitute (regexp "%") ".*" newpatt #f)
(string-substitute (regexp "\\*") ".*" newpatt #f)))
(res #f))
(let* ((like (substring-index "%" patt))
(notpatt (equal? (substring-index "~" patt) 0))
(newpatt (if notpatt (substring patt 1) patt))
(finpatt (if like
(string-substitute (regexp "%") ".*" newpatt #f)
(string-substitute (regexp "\\*") ".*" newpatt #f)))
(rx (tests:cache-regexp finpatt (if like #t #f)))
(res (string-match rx str)))
;; (print "tests:glob-like-match => notpatt: " notpatt ", newpatt: " newpatt ", finpatt: " finpatt)
(set! res (string-match (regexp finpatt (if like #t #f)) str))
(if notpatt (not res) res))))
(if notpatt (not res) res)))
;; if itempath is #f then look only at the testname part
;;
(define (tests:match patterns testname itempath #!key (required '()))
(if (string? patterns)
(let ((patts (append (string-split patterns ",") required)))
(if (null? patts) ;;; no pattern(s) means no match
|