misc tests
This commit is contained in:
parent
838577d8fb
commit
87c39b5347
17
cover.rkt
17
cover.rkt
|
@ -41,22 +41,23 @@
|
|||
(define path (if (list? p) (car p) p))
|
||||
(define argv (if (list? p) (cadr p) #()))
|
||||
(vprintf "running file: ~s with args: ~s\n" path argv)
|
||||
(struct an-exit ())
|
||||
(define exited (an-exit))
|
||||
(struct an-exit (code))
|
||||
(with-handlers ([(lambda (x) (or (not (exn? x)) (exn:fail? x)))
|
||||
(lambda (x)
|
||||
(unless (eq? exited x)
|
||||
(set! tests-failed #t)
|
||||
(error-display x)))])
|
||||
(cond [(an-exit? x)
|
||||
(vprintf "file ~s exited code ~s" p (an-exit-code x))]
|
||||
[else
|
||||
(set! tests-failed #t)
|
||||
(error-display x)]))])
|
||||
(parameterize* ([current-command-line-arguments argv]
|
||||
[exit-handler (lambda (x) (raise exited))]
|
||||
[exit-handler (lambda (x) (raise (an-exit x)))]
|
||||
[current-namespace ns]
|
||||
[(get-check-handler-parameter)
|
||||
(lambda x
|
||||
(set! tests-failed #t)
|
||||
(vprintf "file ~s had failed tests\n" p)
|
||||
(apply old-check x))])
|
||||
(define file `(file ,path))
|
||||
(define file `(file ,(if (path? path) (path->string path) path)))
|
||||
(define submod `(submod ,file ,submod-name))
|
||||
(run-mod (if (module-declared? submod #t) submod file)))))
|
||||
(vprintf "ran ~s\n" paths)
|
||||
|
@ -164,7 +165,7 @@
|
|||
|
||||
(define out (make-hash))
|
||||
|
||||
(for ([v filtered])
|
||||
(for ([v (in-list filtered)])
|
||||
(define file (srcloc-source (cadr v)))
|
||||
(hash-update! out
|
||||
file
|
||||
|
|
2
info.rkt
2
info.rkt
|
@ -11,7 +11,7 @@
|
|||
|
||||
(define scribblings '(("scribblings/cover.scrbl" (multi-page))))
|
||||
|
||||
(define test-omit-paths (list "tests/error-file.rkt"))
|
||||
(define test-omit-paths (list "tests/error-file.rkt" "scribblings"))
|
||||
|
||||
(define cover-formats '(("html" cover generate-html-coverage)
|
||||
("coveralls" cover generate-coveralls-coverage)
|
||||
|
|
6
raco.rkt
6
raco.rkt
|
@ -81,7 +81,7 @@
|
|||
(define comped (map regexp exts))
|
||||
(define paths+vectors
|
||||
(flatten
|
||||
(for/list ([f files])
|
||||
(for/list ([f (in-list files)])
|
||||
(if (not (directory-exists? f))
|
||||
f
|
||||
(parameterize ([current-directory
|
||||
|
@ -231,8 +231,8 @@
|
|||
(contract coverage-gen/c f 'cover ident ident #f)))))
|
||||
|
||||
(define ((make-cover-load-error dir v) . _)
|
||||
(error 'cover "unable to load coverage format from ~s. Found unusable value ~s"
|
||||
dir v))
|
||||
(error 'cover "unable to load coverage format from ~s. Found unusable value ~s" dir v))
|
||||
|
||||
(define ((make-cover-require-error ident path))
|
||||
(error 'cover "unable to load symbol ~s from ~s" ident path))
|
||||
|
||||
|
|
5
tests/do-eval.rkt
Normal file
5
tests/do-eval.rkt
Normal file
|
@ -0,0 +1,5 @@
|
|||
#lang racket/base
|
||||
(require racket/runtime-path "../main.rkt" rackunit)
|
||||
(define-runtime-path eval.rkt "eval.rkt")
|
||||
(check-true (test-files! eval.rkt))
|
||||
(clear-coverage!)
|
5
tests/do-exit.rkt
Normal file
5
tests/do-exit.rkt
Normal file
|
@ -0,0 +1,5 @@
|
|||
#lang racket/base
|
||||
(require "../main.rkt" racket/runtime-path)
|
||||
(define-runtime-path exit.rkt "exit.rkt")
|
||||
(test-files! exit.rkt)
|
||||
(clear-coverage!)
|
5
tests/eval.rkt
Normal file
5
tests/eval.rkt
Normal file
|
@ -0,0 +1,5 @@
|
|||
#lang racket/base
|
||||
(require rackunit)
|
||||
(define-namespace-anchor nsa)
|
||||
(define ns (namespace-anchor->namespace nsa))
|
||||
(check-equal? (eval `(+ 1 1) ns) 2)
|
3
tests/exit.rkt
Normal file
3
tests/exit.rkt
Normal file
|
@ -0,0 +1,3 @@
|
|||
#lang racket/base
|
||||
;; this should cause things to fail if the exit isn't trapped
|
||||
(exit 0)
|
|
@ -4,6 +4,7 @@
|
|||
;; tests that file and checks its coverage against an
|
||||
;; .rktl file of the same name
|
||||
(require (only-in "../main.rkt" test-files! clear-coverage! get-test-coverage)
|
||||
"../private/file-utils.rkt"
|
||||
racket/runtime-path rackunit)
|
||||
|
||||
(define (test-dir d)
|
||||
|
@ -65,3 +66,14 @@
|
|||
(module+ test
|
||||
(define-runtime-path-list test-dirs '("basic" "simple-multi"))
|
||||
(for-each (compose test-dir path->string) test-dirs))
|
||||
|
||||
(module+ test
|
||||
(define-runtime-path prog.rkt "prog.rkt")
|
||||
(test-begin
|
||||
(after
|
||||
(test-files! (->absolute prog.rkt))
|
||||
(define abs (get-test-coverage))
|
||||
(test-files! (->relative prog.rkt))
|
||||
(define rel (get-test-coverage))
|
||||
(check-equal? abs rel)
|
||||
(clear-coverage!))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user