From 511ed88376e170b3663c73577bbda13990bceb9e Mon Sep 17 00:00:00 2001 From: Spencer Florence Date: Mon, 29 Dec 2014 10:29:03 -0600 Subject: [PATCH] fixed tests and renamed to cover --- info.rkt | 4 ++-- private/coveralls.rkt | 7 +++---- private/format-utils.rkt | 8 +++++--- private/html.rkt | 16 +++++++--------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/info.rkt b/info.rkt index d686081..fadf938 100644 --- a/info.rkt +++ b/info.rkt @@ -1,7 +1,7 @@ #lang setup/infotab -(define name "better-test") +(define name "cover") (define deps '("base" "errortrace-lib" "rackunit-lib" "syntax-color-lib")) (define raco-commands - '(("better-test" (submod better-test/raco main) "a better testing library" 100))) + '(("cover" (submod cover/raco main) "a code coverage tool" 100))) diff --git a/private/coveralls.rkt b/private/coveralls.rkt index 986c557..023be8f 100644 --- a/private/coveralls.rkt +++ b/private/coveralls.rkt @@ -3,9 +3,7 @@ (require racket/runtime-path json "format-utils.rkt") (module+ test - (require rackunit "../main.rkt") - (define (simple-path . directories) - (path->string (simplify-path (apply build-path directories))))) + (require rackunit "../main.rkt" racket/runtime-path)) ;; Coveralls @@ -62,8 +60,9 @@ (reverse line-cover)) (module+ test + (define-runtime-path path "../tests/basic/not-run.rkt") (let () - (define file (simple-path (current-directory) 'up "tests/basic/not-run.rkt")) + (define file (path->string (simplify-path path))) (test-files! file) (check-equal? (line-coverage (get-test-coverage) file) '(1 0)) (clear-coverage!))) diff --git a/private/format-utils.rkt b/private/format-utils.rkt index f44d9ab..b9d243f 100644 --- a/private/format-utils.rkt +++ b/private/format-utils.rkt @@ -1,7 +1,7 @@ #lang racket (provide get-percentages/top get-percentages/file covered?) (require syntax/modread syntax/parse unstable/sequence syntax-color/racket-lexer) -(module+ test (require rackunit "../main.rkt")) +(module+ test (require rackunit "../main.rkt" racket/runtime-path)) ;;;;; a Coverage is the output of (get-test-coverage) ;;;;; a FileCoverage is the values of the hashmap from (get-test-coverage) @@ -67,8 +67,9 @@ (values (/ covered count) count)) (module+ test + (define-runtime-path path "../tests/basic/prog.rkt") (test-begin - (define f (path->string (build-path (current-directory) "tests/basic/prog.rkt"))) + (define f (path->string (simplify-path path))) (test-files! f) (define-values (result _) (expr-percentage f (hash-ref (get-test-coverage) f))) (check-equal? result 1) @@ -158,8 +159,9 @@ [else 'missing])) (module+ test + (define-runtime-path path2 "../tests/prog.rkt") (test-begin - (define f (path->string (build-path (current-directory) "tests/prog.rkt"))) + (define f (path->string (simplify-path path2))) (test-files! f) (define coverage (hash-ref (get-test-coverage) f)) (check-equal? (covered? 17 coverage f) 'missing) diff --git a/private/html.rkt b/private/html.rkt index 96904a3..8acee7e 100644 --- a/private/html.rkt +++ b/private/html.rkt @@ -3,9 +3,7 @@ (require (only-in xml write-xexpr) "format-utils.rkt") (module+ test - (require rackunit "../main.rkt") - (define (simple-path . directories) - (path->string (simplify-path (apply build-path directories))))) + (require rackunit "../main.rkt" racket/runtime-path)) ;;; Coverage [PathString] -> Void (define (generate-html-coverage coverage [dir "coverage"]) @@ -32,9 +30,9 @@ ,@(file->html coverage path)))) (module+ test + (define-runtime-path path "../tests/basic/prog.rkt") (test-begin - (define f - (simple-path (current-directory) 'up "tests/basic/prog.rkt")) + (define f (path->string (simplify-path path))) (test-files! f) (check-equal? (make-html-file (hash-ref (get-test-coverage) f) f) `(html () @@ -85,13 +83,13 @@ `(div ((style ,(string-append "color:" color))) ,@body)) (module+ test - (define (test f out) - (define file (simple-path (current-directory) f)) + (define (test file out) (test-files! file) (check-equal? (file->html (hash-ref (get-test-coverage) file) file) out) (clear-coverage!)) - (test "../tests/basic/prog.rkt" + (define f (path->string (simplify-path path))) + (test f `((div ((style "color:green")) - ,@(encode-string (file->string "../tests/basic/prog.rkt")))))) + ,@(encode-string (file->string f))))))