#!/bin/sh

set -eu

export TZ=UTC

cd tests

EXIT=0

for i in *.testfile; do
    printf 'Testing: %s ... ' "$i"
    if [ -f ${i%%.testfile}.magic ]; then
        m="-m ${i%%.testfile}.magic"
    else
        m=
    fi;
    if [ "$(file -b $m "$i")" = "$(cat ${i%%.testfile}.result)" ] ; then
        echo 'pass'
    else
        echo 'FAILED'
        EXIT=1
    fi
done

exit $EXIT
