File: runner

package info (click to toggle)
haskell-hjsmin 0.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 112 kB
  • sloc: haskell: 152; sh: 30; makefile: 3
file content (74 lines) | stat: -rw-r--r-- 1,467 bytes parent folder | download | duplicates (2)
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}
}