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
|
#!/bin/sh
errors=0
fatal() {
echo "$@" 1>&2
exit 1
}
compare() {
local infile="$1"
local reffile="$2"
[ -r "${infile}" ] || fatal "cannot read MIDIfile '${infile}'"
[ -r "${reffile}" ] || fatal "cannot read reference file '${reffile}'"
local outfile=$(mktemp)
echo "comparing '${infile}' with '${reffile}' via '${outfile}'"
mftext "${infile}" > "${outfile}"
diff -bBw "${outfile}" "${reffile}" 1>&2 || errors=1
rm "${outfile}" "${infile}"
}
doit() {
echo "========= $1 ========="
python3 "$1" || exit 1
compare "$2" "$3"
echo ""
}
doit examples/single-note-example.py output.mid debian/tests/output.txt
doit examples/c-major-scale.py major-scale.mid debian/tests/major-scale.txt
exit $errors
|