now catching errors from running files (Issue #5)

This commit is contained in:
Spencer Florence 2015-01-07 19:21:25 -05:00
parent 471105c343
commit afea19c4b8
5 changed files with 38 additions and 12 deletions

View File

@ -8,5 +8,5 @@ before_install:
script: script:
- /usr/racket/bin/raco pkg install $TRAVIS_BUILD_DIR - /usr/racket/bin/raco pkg install $TRAVIS_BUILD_DIR
- /usr/racket/bin/raco test $TRAVIS_BUILD_DIR - /usr/racket/bin/raco test -Q $TRAVIS_BUILD_DIR
- /usr/racket/bin/raco cover -c coveralls -d $TRAVIS_BUILD_DIR/coverage -p $TRAVIS_BUILD_DIR - /usr/racket/bin/raco cover -c coveralls -d $TRAVIS_BUILD_DIR/coverage -p $TRAVIS_BUILD_DIR

View File

@ -9,6 +9,7 @@
unstable/syntax unstable/syntax
racket/runtime-path racket/runtime-path
rackunit rackunit
unstable/error
"private/shared.rkt") "private/shared.rkt")
@ -40,17 +41,20 @@
(for ([p paths]) (for ([p paths])
(vprintf "running file: ~s\n" p) (vprintf "running file: ~s\n" p)
(define old-check (current-check-handler)) (define old-check (current-check-handler))
(parameterize* ([current-namespace ns] (with-handlers ([void (lambda (x)
[current-check-handler (set! tests-failed #t)
(lambda x (error-display x))])
(set! tests-failed #t) (parameterize* ([current-namespace ns]
(vprintf "file ~s had failed tests\n" p) [current-check-handler
(apply old-check x))]) (lambda x
(eval `(dynamic-require '(file ,p) #f)) (set! tests-failed #t)
(namespace-require `(file ,p)) (vprintf "file ~s had failed tests\n" p)
(define submod `(submod (file ,p) test)) (apply old-check x))])
(when (module-declared? submod) (eval `(dynamic-require '(file ,p) #f))
(namespace-require submod)))) (namespace-require `(file ,p))
(define submod `(submod (file ,p) test))
(when (module-declared? submod)
(namespace-require submod)))))
(not tests-failed))) (not tests-failed)))
(define (make-better-test-compile) (define (make-better-test-compile)

View File

@ -10,3 +10,5 @@
'(("cover" (submod cover/raco main) "a code coverage tool" 30))) '(("cover" (submod cover/raco main) "a code coverage tool" 30)))
(define scribblings '(("scribblings/cover.scrbl" (multi-page)))) (define scribblings '(("scribblings/cover.scrbl" (multi-page))))
(define test-omit-paths (list "tests/error-file.rkt"))

2
tests/error-file.rkt Normal file
View File

@ -0,0 +1,2 @@
#lang racket
(error "this is supposed to happend")

18
tests/error.rkt Normal file
View File

@ -0,0 +1,18 @@
#lang racket
(require "../main.rkt" rackunit)
(test-begin
(after
(define (do-test files)
(apply test-files! files)
(define c (get-test-coverage))
(define covered
(map (compose path->string last explode-path) files))
(for-each
(lambda (x) (check-not-false (member x covered)))
files)
(clear-coverage!))
(define files (list "error-file.rkt" "prog.rkt"))
(do-test files)
(do-test (reverse files))
(clear-coverage!)))