From 8c24a0902737201357faa93889713b16726ccb39 Mon Sep 17 00:00:00 2001 From: Brandon Cheng Date: Thu, 29 Nov 2018 18:25:09 -0500 Subject: [PATCH] Conditionally display reference output Fixes #2 --- genericTester.scm | 8 +++++--- genericTester.sh | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/genericTester.scm b/genericTester.scm index 239a729..e46d80b 100644 --- a/genericTester.scm +++ b/genericTester.scm @@ -11,6 +11,7 @@ ; test-assertion should be a lambda we can pass student-out and reference-out ; to. Ex: "(lambda (student reference) (< (abs (- student reference)) 0.0001)) (define test-assertion (read (current-input-port))) + (define show-reference-output (read (current-input-port))) (if (eq? test-output-transform "") (set! test-output-transform (lambda (x) x)) @@ -40,9 +41,10 @@ (apply (eval test-function (interaction-environment)) (eval test-arguments (interaction-environment))))) - ; (display "The solution was: " (current-error-port)) - ; (display reference-out (current-error-port)) - ; (newline (current-error-port)) + (if (eval show-reference-output (interaction-environment)) + (begin (display "The solution was: " (current-error-port)) + (display reference-out (current-error-port)) + (newline (current-error-port)))) ; Ensure only #t or #f is the last line. This may not be the case if there ; were calls to the display function in the student code. diff --git a/genericTester.sh b/genericTester.sh index 0f8ae84..6e235e9 100755 --- a/genericTester.sh +++ b/genericTester.sh @@ -5,12 +5,14 @@ PLEDGE="I confirm that my submitted solutions are the result of my own intellect # Default arguments CHECK_PLEDGE=false +SHOW_REFERENCE_OUTPUT="#f" testOutputTransform=${testOutputTransform:-(lambda (x) x)} # Parse command line flags while true; do case "$1" in --check-pledge ) CHECK_PLEDGE=true; shift ;; + --show-reference-output ) SHOW_REFERENCE_OUTPUT="#t"; shift ;; * ) break ;; esac done @@ -22,7 +24,8 @@ stdinToGenericTester=" $testFunction\n (list $testArguments)\n $testOutputTransform\n - (lambda (student reference) $testAssertion)\n" + (lambda (student reference) $testAssertion)\n + $SHOW_REFERENCE_OUTPUT\n" RESULT=`echo -e $stdinToGenericTester | plt-r5rs genericTester.scm 2>> DEBUG` # Treat the last line of the output as a fake exit status EXITSTATUS=`echo "$RESULT" | tail -n 1`