From efbd424ec0e6a6b1e91c5df67c58a9885f28bbb3 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 28 Jul 2015 14:19:32 -0600 Subject: [PATCH] Add test-include-paths and allow test-omit-paths to use regexps --- compiler-lib/compiler/commands/test.rkt | 45 ++++++++++++------- .../test/extensions/a-omit-1.racket-file | 4 ++ .../compiler/test/extensions/a-omit-1.rkt | 4 ++ .../test/extensions/b-include-1.racket-file | 5 +++ .../compiler/test/extensions/b-include-1.rkt | 5 +++ .../tests/compiler/test/extensions/info.rkt | 3 ++ 6 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 compiler-test/tests/compiler/test/extensions/a-omit-1.racket-file create mode 100644 compiler-test/tests/compiler/test/extensions/a-omit-1.rkt create mode 100644 compiler-test/tests/compiler/test/extensions/b-include-1.racket-file create mode 100644 compiler-test/tests/compiler/test/extensions/b-include-1.rkt create mode 100644 compiler-test/tests/compiler/test/extensions/info.rkt diff --git a/compiler-lib/compiler/commands/test.rkt b/compiler-lib/compiler/commands/test.rkt index b927636c40..1458f23499 100644 --- a/compiler-lib/compiler/commands/test.rkt +++ b/compiler-lib/compiler/commands/test.rkt @@ -558,9 +558,10 @@ #:sema continue-sema)))] [(and (or (not check-suffix?) (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?) - (not (omit-path? p #:check-info? #t)))) + (not (omit-path? p #:check-info? #t)))) (unless check-suffix? ;; make sure "info.rkt" information is loaded: (check-info p)) @@ -740,6 +741,7 @@ ;; Reading "info.rkt" files (define omit-paths (make-hash)) +(define include-paths (make-hash)) (define command-line-arguments (make-hash)) (define timeouts (make-hash)) (define lock-names (make-hash)) @@ -773,14 +775,22 @@ (hash-set! table dir #t)] [(list? v) (for ([i (in-list v)]) - (unless (path-string? i) (bad what v)) - (define p (normalize-info-path (path->complete-path i dir))) - (define dp (if (directory-exists? p) - (path->directory-path p) - p)) - (hash-set! table dp #t))] + (cond + [(path-string? i) + (define p (normalize-info-path (path->complete-path i dir))) + (define dp (if (directory-exists? p) + (path->directory-path p) + 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)])) (get-members omit-paths 'test-omit-paths #t) + (get-members include-paths 'test-include-paths #t) (get-members randoms 'test-randoms #t) (define (get-keyed table what check? #:ok-all? [ok-all? #f]) @@ -845,13 +855,18 @@ (define (normalize-info-path p) (simplify-path (path->complete-path p) #f)) -(define (omit-path? p #:check-info? [check-info? #f]) - (when check-info? (check-info p)) - (let ([p (normalize-info-path p)]) - (or (hash-ref omit-paths p #f) - (let-values ([(base name dir?) (split-path p)]) - (and (path? base) - (omit-path? base)))))) +(define (make-omit-path? omit-paths) + (define (omit-path? p #:check-info? [check-info? #f]) + (when check-info? (check-info p)) + (let ([p (normalize-info-path p)]) + (or (hash-ref omit-paths p #f) + (let-values ([(base name dir?) (split-path p)]) + (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]) (when check-info? (check-info p)) diff --git a/compiler-test/tests/compiler/test/extensions/a-omit-1.racket-file b/compiler-test/tests/compiler/test/extensions/a-omit-1.racket-file new file mode 100644 index 0000000000..46347b55a1 --- /dev/null +++ b/compiler-test/tests/compiler/test/extensions/a-omit-1.racket-file @@ -0,0 +1,4 @@ +#lang racket/base +(error 'bad) +(module+ test + (error 'bad)) diff --git a/compiler-test/tests/compiler/test/extensions/a-omit-1.rkt b/compiler-test/tests/compiler/test/extensions/a-omit-1.rkt new file mode 100644 index 0000000000..46347b55a1 --- /dev/null +++ b/compiler-test/tests/compiler/test/extensions/a-omit-1.rkt @@ -0,0 +1,4 @@ +#lang racket/base +(error 'bad) +(module+ test + (error 'bad)) diff --git a/compiler-test/tests/compiler/test/extensions/b-include-1.racket-file b/compiler-test/tests/compiler/test/extensions/b-include-1.racket-file new file mode 100644 index 0000000000..5e2f56f1f0 --- /dev/null +++ b/compiler-test/tests/compiler/test/extensions/b-include-1.racket-file @@ -0,0 +1,5 @@ +#lang racket/base +(define (f x) x) +(module+ test + (require rackunit) + (check-equal? (f 1) 1)) diff --git a/compiler-test/tests/compiler/test/extensions/b-include-1.rkt b/compiler-test/tests/compiler/test/extensions/b-include-1.rkt new file mode 100644 index 0000000000..5e2f56f1f0 --- /dev/null +++ b/compiler-test/tests/compiler/test/extensions/b-include-1.rkt @@ -0,0 +1,5 @@ +#lang racket/base +(define (f x) x) +(module+ test + (require rackunit) + (check-equal? (f 1) 1)) diff --git a/compiler-test/tests/compiler/test/extensions/info.rkt b/compiler-test/tests/compiler/test/extensions/info.rkt new file mode 100644 index 0000000000..572ef689aa --- /dev/null +++ b/compiler-test/tests/compiler/test/extensions/info.rkt @@ -0,0 +1,3 @@ +#lang info +(define test-omit-paths '(#rx".*omit.*")) +(define test-include-paths '(#rx".*include.*"))