1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
if test -d dist-ghc ; then
HJSMIN=$(find dist-ghc -type f -name hjsmin)
elif test -d ../dist-ghc ; then
HJSMIN=$(find ../dist-ghc -type f -name hjsmin)
fi
echo
echo $HJSMIN
echo
DIFF=${USE_DIFF:-diff -u}
colourReset='\e[0m'
colourGreen='\e[0;32m'
colourRed='\e[0;31m'
colourYellow='\e[0;33m'
testname=$(basename $(dirname $0))
# Failure is the default!
RESULT="FAILED"
type "$HJSMIN" > /dev/null 2>&1 || {
echo "No hjsmin executable specified on command line or on path."
exit 1
}
ROOT=$(dirname "$0")/../../..
ROOT=$(cd "$ROOT" > /dev/null 2>&1 && pwd)
TMP=${ROOT}/tmp
TEST=${TMP}/test/$$
mkdir -p ${TEST}
cleanup () {
echo "Cleaning up (${TEST})"
rm -rf "${TEST}"
echo ${RESULT}
echo
}
trap cleanup EXIT
banner () {
echo "${colourYellow}== $* ==${colourReset}"
echo "== Running in ${TEST} =="
}
assert_file_exists () {
if test ! -f "$1" ; then
echo "Output file '$1' is missing."
fail_test
fi
}
pass_test () {
RESULT="${colourGreen}PASSED [ ${testname} ]${colourReset}"
exit 0
}
fail_test () {
RESULT="${colourRed}FAILED [ ${testname} ]${colourReset}"
exit 1
}
sort_diff () {
EXP="$1"
ACTUAL="$2"
EXPECTED_SORTED=${OUTPUT_DIR}/sort_diff.expected.$(basename $EXP)
ACTUAL_SORTED=${OUTPUT_DIR}/sort_diff.actual.$(basename $ACTUAL)
sort ${EXP} > ${EXPECTED_SORTED}
sort ${ACTUAL} > ${ACTUAL_SORTED}
diff ${EXPECTED_SORTED} ${ACTUAL_SORTED}
}
|