summaryrefslogtreecommitdiffstats
path: root/tests/libzscanner/test_zscanner.in
blob: 10d2b5ce8227cbdf199231aceb560a9ea6029766 (plain)
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
#!/bin/sh

SOURCE=@top_srcdir@/tests/libzscanner
BUILD=@top_builddir@/tests/libzscanner

. @top_srcdir@/tests/tap/libtap.sh

cd "$BUILD"

TMPDIR=$(test_tmpdir)
TESTS_DIR="$SOURCE"/data
ZSCANNER_TOOL="$BUILD"/zscanner-tool

plan 86

mkdir -p "$TMPDIR"/includes/
for a in 1 2 3 4 5 6; do
    cat "$TESTS_DIR"/includes/include"$a" > "$TMPDIR"/includes/include"$a";
done

for case in $(cat "$SOURCE"/TESTS); do
    casein=$(test_file_path data/"$case".in)
    caseout=$(test_file_path data/"$case".out)
    filein="$TMPDIR"/"$case".in
    fileout="$TMPDIR"/"$case".out

    sed -e "s|@TMPDIR@|$TMPDIR|;" < "$casein" > "$filein"

    "$ZSCANNER_TOOL" -m 2 . "$filein" > "$fileout"

    if cmp -s "$fileout" "$caseout"; then
        ok "$case: output matches" true
        rm "$filein"
        rm "$fileout"
    else
        ok "$case: output differs" false
        diff -urNap "$caseout" "$fileout" | while read line; do diag "$line"; done
    fi
done

rm -rf "$TMPDIR"/includes/