adjust plai's test facility to print test failures to stderr

instead of stdout (in addition to making errors red in drracket,
this will also make some of the existing test suites more
drdr friendly)
This commit is contained in:
Robby Findler 2013-02-27 18:11:31 -06:00
parent f5e85a6503
commit 727d11df83
3 changed files with 11 additions and 5 deletions

View File

@ -124,7 +124,8 @@ PLAI Scheme provides the following syntactic forms for testing.
@defform/subs[(test result-expr expected-expr)()]{
If @racket[_result-expr] and @racket[_expected-expr] evaluate to the same
value, @racket[_result-value], the test prints
value, @racket[_result-value], the test prints the following expression
to @racket[(current-error-port)]:
@racketresultfont{(good result-expr result-value expected-value location)}.

View File

@ -69,9 +69,8 @@
(set! plai-all-test-results (cons result plai-all-test-results))
(when print?
(if (abridged-test-output)
(apply printf "(~s ~v ~v)" result)
(apply printf "(~s ~s ~v ~v ~s)" result))
(newline))
(apply eprintf "(~s ~v ~v)\n" result)
(apply eprintf "(~s ~s ~v ~v ~s)\n" result)))
(when (and halt-on-errors? error?)
(raise (make-exn:test (string->immutable-string (format "test failed: ~s" result))
(current-continuation-marks))))))

View File

@ -7,7 +7,13 @@
[id (s symbol?)])
(define-syntax-rule (->string e)
(regexp-replace "line [0-9]+" (with-output-to-string (λ () e)) "line ??"))
(regexp-replace "line [0-9]+" (with-err-output-to-string (λ () e)) "line ??"))
(define (with-err-output-to-string thunk)
(define sp (open-output-string))
(parameterize ([current-error-port sp])
(thunk))
(get-output-string sp))
(define (go catch? errors? abridged?)
(eli:test