From 6ded700656f48dc50546a9c05481eb5c4427c1cd Mon Sep 17 00:00:00 2001 From: Brandon Cheng Date: Thu, 29 Nov 2018 18:17:06 -0500 Subject: [PATCH] Conditionally check for honor code Fixes #1 --- genericTester.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/genericTester.sh b/genericTester.sh index 9707f20..0f8ae84 100755 --- a/genericTester.sh +++ b/genericTester.sh @@ -1,7 +1,20 @@ #!/bin/bash +# Constants +PLEDGE="I confirm that my submitted solutions are the result of my own intellectual effort, and comply with the 1729 honor code and the UConn standards for academic integrity" + +# Default arguments +CHECK_PLEDGE=false testOutputTransform=${testOutputTransform:-(lambda (x) x)} +# Parse command line flags +while true; do + case "$1" in + --check-pledge ) CHECK_PLEDGE=true; shift ;; + * ) break ;; + esac +done + # Get first file with .rkt extension. studentAnswersFile="$(ls | grep ".rkt" | head -n 1)" stdinToGenericTester=" @@ -14,6 +27,21 @@ 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` +if [ "$CHECK_PLEDGE" = true ] ; then + # Check if pledge appears in the students answer + # file. The sed replacement generates a RegExp + # that allows us to find the statement if it + # spans multiple lines. + # + # Every student has to include the pledge in their code + + if ! echo $PLEDGE | sed -e 's/ /[\\n\\s;]+/g' | grep -Pziq -f - "$studentAnswersFile" ; then + echo "Error: Statement to uphold 1729 honor code was not found." >> DEBUG + echo "false" > OUTPUT + exit 0 + fi +fi + if [ "$EXITSTATUS" = "#t" ] ; then echo "true" > OUTPUT else