` is text too
[efmt.git] / run_tests.sh
blob3a7e2d731396af4f9b76f0f01a734071cd4be094
1 #!/bin/sh
3 set -eu
5 root=$(dirname $(readlink -f "$0") )
6 tmpdir=$(mktemp -d)
7 ret=0
9 cd "${root}"
10 pat=""
11 [ "$#" -ge 1 ] && pat="$1"
13 for inputf in $(ls tests/*${pat}*.input)
15 nicename="${inputf%.input}"
16 outputf="${nicename}.output"
17 resultf="${tmpdir}/"$(basename "${outputf}")
19 if [ -f "${outputf}" ]
20 then
21 printf '%s... ' "${nicename}"
22 "${root}/obj/efmt" < "${inputf}" \
23 2>&1 > "${resultf}"
24 if diff -q "${outputf}" "${resultf}" >/dev/null 2>&1
25 then
26 printf '\033[1;34mPASS\033[0m\n'
27 else
28 ret=1
29 printf '\033[1;31mFAIL\033[0m\n'
30 diff -u "${resultf}" "${outputf}"
32 else
33 printf '%s... ' "${nicename}"
34 printf '\033[1;33mNO STORED OUTPUT\033[0m\n'
36 done
38 rm -rf "${tmpdir}"
40 exit "${ret}"