From 727d11df835b6a15c974d5102db321905f2b2d7e Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 27 Feb 2013 18:11:31 -0600 Subject: [PATCH] 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) --- collects/plai/scribblings/plai.scrbl | 3 ++- collects/plai/test-harness.rkt | 5 ++--- collects/tests/plai/test-harness.rkt | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/collects/plai/scribblings/plai.scrbl b/collects/plai/scribblings/plai.scrbl index 7606d65053..54fdc83bcf 100644 --- a/collects/plai/scribblings/plai.scrbl +++ b/collects/plai/scribblings/plai.scrbl @@ -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)}. diff --git a/collects/plai/test-harness.rkt b/collects/plai/test-harness.rkt index a3f9575331..0d46dc471e 100644 --- a/collects/plai/test-harness.rkt +++ b/collects/plai/test-harness.rkt @@ -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)))))) diff --git a/collects/tests/plai/test-harness.rkt b/collects/tests/plai/test-harness.rkt index fc5ad2fc49..49ba469043 100644 --- a/collects/tests/plai/test-harness.rkt +++ b/collects/tests/plai/test-harness.rkt @@ -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