Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrastructure #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions exercises/lib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ IFS=$'\n\t'

grade() {
local f="$1"
$LEARN grade --timeout=5 --grade-student=$f --dump-reports=${f%.ml} >${f%.ml}.log 2>&1
$LEARN grade --timeout=5 --grade-student="$f" --dump-reports="${f%.ml}" >"${f%.ml}.log" 2>&1
}
export -f grade

filter() {
local f="$1"
rm -f $.bak
mv $f $f.bak
grep -v "Learnocaml v" $f.bak >$f
rm -f $f.bak
rm -f "$f.bak"
mv "$f" "$f.bak"
grep -v "Learnocaml v" "$f.bak" >"$f"
rm -f "$f.bak"
}
export -f filter

positive_test() {
local f="$1"
if grade $f ; then
if grade "$f" ; then
echo " [OK] $f is correctly accepted." ;
else
echo "[FAIL] $f is rejected!" ;
fi
filter ${f%.ml}.log
filter "${f%.ml}.log"
}
export -f positive_test

negative_test() {
local f="$1"
rm -f ${f%.ml}.report.txt ${f%.ml}.report.html ;
if grade $f ; then
rm -f "${f%.ml}.report.txt" "${f%.ml}.report.html" ;
if grade "$f" ; then
echo "[FAIL] $f is incorrectly accepted!" ;
else
echo " [OK] $f is correctly rejected." ;
fi
filter ${f%.ml}.log
filter "${f%.ml}.log"
}
export -f negative_test

Expand All @@ -49,12 +49,12 @@ time -p positive_test solution.ml
# Allow other correct solutions to be proposed.
if [ -d right ] ; then
echo "Grading known correct solutions..."
time -p (ls right/*.ml | parallel --no-notice positive_test) ;
time -p (find . -maxdepth 1 -name "right/*.ml" | parallel --no-notice positive_test) ;
fi

# Make sure that a number of known incorrect solutions are rejected.
echo "Grading known incorrect solutions..."
time -p (ls wrong/*.ml | parallel --no-notice negative_test)
time -p (find . -maxdepth 1 -name "wrong/*.ml" | parallel --no-notice negative_test)

# Use git status to display any differences with respect to the expected
# output and expected log (which should be checked in).
Expand Down