Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSE1729-Mimir-Testing-Scripts/genericTester.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
62 lines (54 sloc)
1.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
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 | |
# Unfortunately we can't restrict file system access from student submissions. | |
# The best we can do to prevent a submission with (load "referenceSolution.scm") | |
# from passing is randomizing the file name of the solution. | |
referenceSolutionFile=$(tempfile) | |
mv referenceSolution.scm "$referenceSolutionFile" | |
# Get first file with .rkt extension. | |
studentAnswersFile="$(ls | grep ".rkt" | head -n 1)" | |
stdinToGenericTester=" | |
\"$referenceSolutionFile\"\n | |
\"$studentAnswersFile\"\n | |
$testFunction\n | |
(list $testArguments)\n | |
$testOutputTransform\n | |
(lambda (student reference) $testAssertion)\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` | |
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 | |
echo "false" > OUTPUT | |
fi |