Skip to content

Instantly share code, notes, and snippets.

@niflostancu
Created November 19, 2012 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niflostancu/4110183 to your computer and use it in GitHub Desktop.
Save niflostancu/4110183 to your computer and use it in GitHub Desktop.
Evaluator bonus Tema 2 CPL
#!/bin/bash
TESTS_DIR="_tests"
export CLASSPATH="$CLASSPATH:./bin:antlr-3.4.jar:java-cup-11a-runtime.jar"
PARSER="java Semant"
function fail {
printf "FAIL (%s)\n" "$1"
}
function pass {
printf "PASS\n"
}
function test_correct {
printf "%-50s" "Testing file $1... "
rm -f __stdout
rm -f __stderr
$PARSER -tail_recursive < $1 1>__stdout 2>__stderr
STDERR=$(cat __stderr)
DIFF_CMD="diff -w -u <(grep -vE '^\s*(#[0-9]+|$)' __stdout) <(grep -vE '^\s*(#[0-9]+|$)' $2) "
if [ -n "$STDERR" ]; then
fail "compilation errors"
echo "-- First lines of stderr below --"
cat __stderr | head -n 3
echo "-----"
echo
else
if [ -z "$( eval $DIFF_CMD )" ]; then
pass
else
fail "differences found"
echo "-- First lines of the diff below --"
eval $DIFF_CMD | head -n 20
echo "-----"
echo
fi
fi
}
echo "******************************"
echo "**** Running bonus tests ****"
echo "******************************"
echo
for CL_SRC in $TESTS_DIR/bonus/*.in.ast; do
test_correct $CL_SRC ${CL_SRC/%in.ast/ast}
done
echo
echo
rm -f __stdout
rm -f __stderr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment