Add test-include-paths and allow test-omit-paths to use regexps

This commit is contained in:
Jay McCarthy 2015-07-28 14:19:32 -06:00
parent b3887f37d3
commit efbd424ec0
6 changed files with 51 additions and 15 deletions

View File

@ -558,9 +558,10 @@
#:sema continue-sema)))] #:sema continue-sema)))]
[(and (or (not check-suffix?) [(and (or (not check-suffix?)
(regexp-match rx:default-suffixes p) (regexp-match rx:default-suffixes p)
(get-cmdline p #f #:check-info? #t)) (get-cmdline p #f #:check-info? #t)
(include-path? p #:check-info? #t))
(or (not check-suffix?) (or (not check-suffix?)
(not (omit-path? p #:check-info? #t)))) (not (omit-path? p #:check-info? #t))))
(unless check-suffix? (unless check-suffix?
;; make sure "info.rkt" information is loaded: ;; make sure "info.rkt" information is loaded:
(check-info p)) (check-info p))
@ -740,6 +741,7 @@
;; Reading "info.rkt" files ;; Reading "info.rkt" files
(define omit-paths (make-hash)) (define omit-paths (make-hash))
(define include-paths (make-hash))
(define command-line-arguments (make-hash)) (define command-line-arguments (make-hash))
(define timeouts (make-hash)) (define timeouts (make-hash))
(define lock-names (make-hash)) (define lock-names (make-hash))
@ -773,14 +775,22 @@
(hash-set! table dir #t)] (hash-set! table dir #t)]
[(list? v) [(list? v)
(for ([i (in-list v)]) (for ([i (in-list v)])
(unless (path-string? i) (bad what v)) (cond
(define p (normalize-info-path (path->complete-path i dir))) [(path-string? i)
(define dp (if (directory-exists? p) (define p (normalize-info-path (path->complete-path i dir)))
(path->directory-path p) (define dp (if (directory-exists? p)
p)) (path->directory-path p)
(hash-set! table dp #t))] p))
(hash-set! table dp #t)]
[(regexp? i)
(for ([f (in-directory dir)]
#:when (regexp-match i (path->string f)))
(hash-set! table f #t))]
[else
(bad what v)]))]
[else (bad what v)])) [else (bad what v)]))
(get-members omit-paths 'test-omit-paths #t) (get-members omit-paths 'test-omit-paths #t)
(get-members include-paths 'test-include-paths #t)
(get-members randoms 'test-randoms #t) (get-members randoms 'test-randoms #t)
(define (get-keyed table what check? #:ok-all? [ok-all? #f]) (define (get-keyed table what check? #:ok-all? [ok-all? #f])
@ -845,13 +855,18 @@
(define (normalize-info-path p) (define (normalize-info-path p)
(simplify-path (path->complete-path p) #f)) (simplify-path (path->complete-path p) #f))
(define (omit-path? p #:check-info? [check-info? #f]) (define (make-omit-path? omit-paths)
(when check-info? (check-info p)) (define (omit-path? p #:check-info? [check-info? #f])
(let ([p (normalize-info-path p)]) (when check-info? (check-info p))
(or (hash-ref omit-paths p #f) (let ([p (normalize-info-path p)])
(let-values ([(base name dir?) (split-path p)]) (or (hash-ref omit-paths p #f)
(and (path? base) (let-values ([(base name dir?) (split-path p)])
(omit-path? base)))))) (and (path? base)
(omit-path? base))))))
omit-path?)
(define omit-path? (make-omit-path? omit-paths))
(define include-path? (make-omit-path? include-paths))
(define (get-cmdline p [default null] #:check-info? [check-info? #f]) (define (get-cmdline p [default null] #:check-info? [check-info? #f])
(when check-info? (check-info p)) (when check-info? (check-info p))

View File

@ -0,0 +1,4 @@
#lang racket/base
(error 'bad)
(module+ test
(error 'bad))

View File

@ -0,0 +1,4 @@
#lang racket/base
(error 'bad)
(module+ test
(error 'bad))

View File

@ -0,0 +1,5 @@
#lang racket/base
(define (f x) x)
(module+ test
(require rackunit)
(check-equal? (f 1) 1))

View File

@ -0,0 +1,5 @@
#lang racket/base
(define (f x) x)
(module+ test
(require rackunit)
(check-equal? (f 1) 1))

View File

@ -0,0 +1,3 @@
#lang info
(define test-omit-paths '(#rx".*omit.*"))
(define test-include-paths '(#rx".*include.*"))