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
|
#!/bin/bash
set -e -u -o pipefail
export VERBOSE=false
if [[ $# -ge 1 && $1 = -v ]]; then
VERBOSE=true
fi
err () {
if "$VERBOSE"; then
sed "s/^/$1: /"
else
cat >/dev/null
fi
}
colournul () {
local colour
colour=$(printf '\033[0;36m') plain=$(printf '\033[0m')
sed -e "s/\\x0/${colour}0&${plain}/g"
}
cd "$(dirname "$0")"
declare -i tests=0
declare -i failures=0
for xml in *.xml; do
test=${xml%%.xml}
rm -f "$test.{output,bin}"
if ! (
xmllint --dtdvalid ../src/lrx.dtd --noout "$test.xml" &&
../src/lrx-comp "$test.xml" "$test.bin" &> >(err "$test") &&
../src/lrx-proc -m -z "$test.bin" < "$test.input" > "$test.output" 2> >(err "$test") &&
diff -au "$test.expected" "$test.output" | colournul
)
then
echo "$test: FAILED"
(( failures++ )) || true
fi
(( tests++ )) || true
done
for bin in bincompat/*.bin; do
test=$(basename "${bin%%.bin}")
rm -f "$test.output"
if ! (
../src/lrx-proc -m -z "${bin}" < "$test.input" > "$test.output" 2> >(err "$test") &&
diff -au "$test.expected" "$test.output" | colournul
)
then
echo "$test: FAILED"
(( failures++ )) || true
fi
(( tests++ )) || true
done
$VERBOSE && printf "\nPASS: %s\nFAIL: %s\nTOTAL: %s\n" $(( tests - failures )) ${failures} ${tests}
if [[ $failures -gt 0 ]]; then
exit 1
fi
|