now disabling test coverage when its not needed

This commit is contained in:
Spencer Florence 2014-12-28 22:24:14 -06:00
parent c639552132
commit bb81fec0d6
3 changed files with 30 additions and 29 deletions

View File

@ -18,34 +18,35 @@
;; PathString * -> Boolean ;; PathString * -> Boolean
;; Test files and build coverage map ;; Test files and build coverage map
;; returns true if all tests passed ;; returns true if all tests passed
(define (test-files! . paths) (define (test-files! #:coverage [coverage? #t] . paths)
(clear-coverage!) (parameterize ([test-coverage-enabled coverage?])
(for ([p paths]) (clear-coverage!)
(let loop ()
(define-values (loc type) (get-module-path (build-path p)))
(case type
[(zo so)
(delete-file loc)
(loop)]
[else (void)])))
(parameterize ([use-compiled-file-paths
(cons (build-path "compiled" "better-test")
(use-compiled-file-paths))]
[current-compile (make-better-test-compile)])
(define tests-failed #f)
(for ([p paths]) (for ([p paths])
(define old-check (current-check-handler)) (let loop ()
(parameterize* ([current-namespace ns] (define-values (loc type) (get-module-path (build-path p)))
[current-check-handler (case type
(lambda x [(zo so)
(set! tests-failed #t) (delete-file loc)
(apply old-check x))]) (loop)]
(eval `(dynamic-require '(file ,p) #f)) [else (void)])))
(namespace-require `(file ,p)) (parameterize ([use-compiled-file-paths
(define submod `(submod (file ,p) test)) (cons (build-path "compiled" "better-test")
(when (module-declared? submod) (use-compiled-file-paths))]
(namespace-require submod)))) [current-compile (make-better-test-compile)])
(not tests-failed))) (define tests-failed #f)
(for ([p paths])
(define old-check (current-check-handler))
(parameterize* ([current-namespace ns]
[current-check-handler
(lambda x
(set! tests-failed #t)
(apply old-check x))])
(eval `(dynamic-require '(file ,p) #f))
(namespace-require `(file ,p))
(define submod `(submod (file ,p) test))
(when (module-declared? submod)
(namespace-require submod))))
(not tests-failed))))
(define (make-better-test-compile) (define (make-better-test-compile)
(define compile (current-compile)) (define compile (current-compile))

View File

@ -20,7 +20,7 @@
#:args files #:args files
files))) files)))
(printf "testing ~s\n" files) (printf "testing ~s\n" files)
(define passed (apply test-files! files)) (define passed (keyword-apply test-files! '(#:coverage) (list coverage?) files))
(when coverage? (when coverage?
(printf "COVERAGE!") (printf "COVERAGE!")
(define coverage (get-test-coverage)) (define coverage (get-test-coverage))

View File

@ -1,5 +1,5 @@
#lang racket/base #lang racket/base
(provide annotate-top) (provide annotate-top test-coverage-enabled)
(require errortrace/stacktrace (require errortrace/stacktrace
racket/function racket/function
racket/unit racket/unit