Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conditionally display reference output
Fixes #2
  • Loading branch information
Brandon committed Nov 29, 2018
1 parent 6ded700 commit 8c24a09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions genericTester.scm
Expand Up @@ -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))
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion genericTester.sh
Expand Up @@ -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
Expand All @@ -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`
Expand Down

0 comments on commit 8c24a09

Please sign in to comment.