From 2fd2227db43b24c209a9527a832399e7774f1d63 Mon Sep 17 00:00:00 2001 From: Spencer Florence Date: Sun, 22 Feb 2015 15:57:47 -0500 Subject: [PATCH] ports must now directly call the compiler --- cover.rkt | 29 ++++++----------------------- main.rkt | 4 ++-- private/coveralls.rkt | 3 ++- private/html/html.rkt | 3 ++- scribblings/api.scrbl | 11 ++++++----- 5 files changed, 18 insertions(+), 32 deletions(-) diff --git a/cover.rkt b/cover.rkt index 6a28c89..f858cce 100644 --- a/cover.rkt +++ b/cover.rkt @@ -43,14 +43,12 @@ in "coverage.rkt". This raw coverage information is converted to a usable form b (define abs (for/list ([p (in-list files)]) (if (list? p) - (cons (->absolute/port (car p)) (cdr p)) - (->absolute/port p)))) + (cons (->absolute (car p)) (cdr p)) + (->absolute p)))) (define abs-names - (for/list ([p abs]) + (for/list ([p (in-list abs)]) (match p [(cons p _) p] - [(? input-port? p) - (object-name p)] [_ p]))) (define tests-failed #f) (for ([p (in-list abs)]) @@ -86,23 +84,15 @@ in "coverage.rkt". This raw coverage information is converted to a usable form b ;;; ---------------------- Running Aux --------------------------------- (define (run-file the-file submod-name) - (cond [(input-port? the-file) - (eval (read-syntax (object-name the-file) the-file))] - [else - (define sfile `(file ,(if (path? the-file) (path->string the-file) the-file))) - (define submod `(submod ,sfile ,submod-name)) - (run-mod (if (module-declared? submod #t) submod sfile))])) + (define sfile `(file ,(if (path? the-file) (path->string the-file) the-file))) + (define submod `(submod ,sfile ,submod-name)) + (run-mod (if (module-declared? submod #t) submod sfile))) (define (run-mod to-run) (vprintf "running ~s\n" to-run) (eval (make-dyn-req-expr to-run)) (vprintf "finished running ~s\n" to-run)) -;; (U InputPort PathString) -> (U InputPort PathString) -;; like ->absolute but handles ports -(define (->absolute/port p) - (if (port? p) p (->absolute p))) - (define (make-dyn-req-expr to-run) `(dynamic-require ',to-run 0)) @@ -181,13 +171,6 @@ in "coverage.rkt". This raw coverage information is converted to a usable form b (load-raw-coverage) (load-current-check-handler)))) -;; -> Void -;; loads any needed names from `ns` before it can get polluted. -(define (load-names) - (load-annotate-top) - (load-raw-coverage) - (load-current-check-handler)) - (define (get-annotate-top) (get-val environment-ann-top)) (define (load-annotate-top) diff --git a/main.rkt b/main.rkt index 91519b3..d951225 100644 --- a/main.rkt +++ b/main.rkt @@ -14,8 +14,8 @@ [test-files! (->* () (#:submod symbol? #:env environment?) #:rest - (listof (or/c (or/c path-string? input-port?) - (list/c (or/c path-string? input-port?) + (listof (or/c path-string? + (list/c path-string? (not-impersonated/c (vectorof (not-impersonated/c string?) #:immutable #t))))) any)] diff --git a/private/coveralls.rkt b/private/coveralls.rkt index 6b7dc85..5a8889c 100644 --- a/private/coveralls.rkt +++ b/private/coveralls.rkt @@ -128,7 +128,8 @@ ;; Generates a string that represents a valid coveralls json_file object (define (generate-source-files coverage) (define src-files - (for/list ([file (in-list (hash-keys coverage))]) + (for/list ([file (in-list (hash-keys coverage))] + #:when (absolute-path? file)) (define local-file (path->string (find-relative-path (current-directory) file))) (define src (file->string file)) (define c (line-coverage coverage file)) diff --git a/private/html/html.rkt b/private/html/html.rkt index df90039..0ddaca5 100644 --- a/private/html/html.rkt +++ b/private/html/html.rkt @@ -46,7 +46,8 @@ (define (get-files coverage dir) (define file-list - (for/list ([(k v) (in-hash coverage)]) + (for/list ([(k v) (in-hash coverage)] + #:when (absolute-path? k)) (vprintf "building html coverage for: ~a\n" k) (define exploded (explode-path k)) (define-values (_ dir-list) diff --git a/scribblings/api.scrbl b/scribblings/api.scrbl index 0c0e85a..191be23 100644 --- a/scribblings/api.scrbl +++ b/scribblings/api.scrbl @@ -15,7 +15,7 @@ functions of test coverage. @defthing[file-coverage/c contract? #:value (listof (list/c boolean? srcloc?))])]{ Coverage information is a hash map mapping absolute file paths to a list detailing the coverage of -that file. The file is keyed on the @racket[syntax-source] of the syntax objects for that +that file. The file is keyed on the @racket[syntax-source] of the syntax objects from that file. Usually this will be the absolute path to the file. The file coverage information is a list of lists, mapping a boolean to a range of characters within the file. True means the @racket[srcloc] structure represents an expression that was run, and False means the structure represents an @@ -25,10 +25,11 @@ expansion and are thus neither run or not run. Note that the @racket[srcloc]s a meaning a @racket[1] represents the first character in the file.} @defproc[(test-files! (#:submod submod symbol? 'test) - (files (or/c (or/c path-string? input-port?) - (list/c (or/c path-string? input-port?) - (not-impersonated/c - (vectorof (not-impersonated/c string?) #:immutable #t))))) ...) + (files + (or/c path-string? + (list/c path-string? + (not-impersonated/c + (vectorof (not-impersonated/c string?) #:immutable #t))))) ...) any]{ Runs all given @racket[files] and their submodule @racket[submod] (if it exists), storing the