Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conditionally show test call
Fixes #27
  • Loading branch information
Brandon committed Nov 29, 2018
1 parent 8c24a09 commit 8434f30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions genericTester.scm
Expand Up @@ -12,16 +12,18 @@
; 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)))
(define show-test-call (read (current-input-port)))

(if (eq? test-output-transform "")
(set! test-output-transform (lambda (x) x))
(set! test-output-transform (eval test-output-transform (interaction-environment))))

; (display "Testing: (apply " (current-error-port))
; (display test-function (current-error-port))
; (display " '" (current-error-port))
; (display (eval test-arguments (interaction-environment)) (current-error-port))
; (display ")\n" (current-error-port))
(if (eval show-test-call (interaction-environment))
(begin (display "Running: (apply " (current-error-port))
(display test-function (current-error-port))
(display " '" (current-error-port))
(display (eval test-arguments (interaction-environment)) (current-error-port))
(display ")\n" (current-error-port))))

; Load student solution and grab their answer
(load student-answers-file)
Expand Down
5 changes: 4 additions & 1 deletion genericTester.sh
Expand Up @@ -6,13 +6,15 @@ PLEDGE="I confirm that my submitted solutions are the result of my own intellect
# Default arguments
CHECK_PLEDGE=false
SHOW_REFERENCE_OUTPUT="#f"
SHOW_TEST_CALL="#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 ;;
--show-test-call ) SHOW_TEST_CALL="#t"; shift ;;
* ) break ;;
esac
done
Expand All @@ -25,7 +27,8 @@ stdinToGenericTester="
(list $testArguments)\n
$testOutputTransform\n
(lambda (student reference) $testAssertion)\n
$SHOW_REFERENCE_OUTPUT\n"
$SHOW_REFERENCE_OUTPUT\n
$SHOW_TEST_CALL\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 8434f30

Please sign in to comment.