fixed tests and renamed to cover

This commit is contained in:
Spencer Florence 2014-12-29 10:29:03 -06:00
parent fc37df938d
commit 511ed88376
4 changed files with 17 additions and 18 deletions

View File

@ -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)))

View File

@ -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!)))

View File

@ -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)

View File

@ -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))))))