summaryrefslogtreecommitdiffstats
path: root/debian/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:52:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:52:52 +0000
commit424f663819ec59abc4edab03a667845835e57ac1 (patch)
tree63b79645aaee07c3de90e4b70dd8d6371faa1747 /debian/tests
parentAdding upstream version 1:5.44. (diff)
downloadfile-debian/1%5.44-3.tar.xz
file-debian/1%5.44-3.zip
Adding debian version 1:5.44-3.debian/1%5.44-3debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests')
-rw-r--r--debian/tests/control2
-rwxr-xr-xdebian/tests/run-testsuite57
2 files changed, 59 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..cf8e922
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: run-testsuite
+Depends: @
diff --git a/debian/tests/run-testsuite b/debian/tests/run-testsuite
new file mode 100755
index 0000000..91082ee
--- /dev/null
+++ b/debian/tests/run-testsuite
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+set -eu
+
+export TZ=UTC
+
+cd tests
+
+failing=0
+
+for i in *.testfile; do
+ t=${i%%.testfile}
+ printf "Running test: %s ... " "$t"
+
+ m=
+ for j in $(eval echo "${t}"*.magic); do
+ if [ -f "$j" ]; then
+ if [ -z "$m" ]; then
+ m="$j"
+ else
+ m="$m:$j"
+ fi
+ fi
+ done
+ if [ "$m" ]; then
+ export MAGIC="$m"
+ else
+ unset MAGIC
+ fi
+
+ if [ -f "${t}.flags" ]; then
+ f="-$(cat "${t}.flags")"
+ else
+ f=
+ fi
+
+ expect="$(cat "${i%%.testfile}.result")"
+ # shellcheck disable=SC2086
+ got="$(file -b $f "$i" 2>/dev/null)"
+ if [ "$got" = "$expect" ]; then
+ echo 'pass'
+ else
+ cat <<__EOS__
+FAIL:
+ expect: $expect
+ got: $got
+__EOS__
+ failing=$((failing+1))
+ fi
+done
+
+if [ "$failing" -gt 0 ]; then
+ echo "Fail count: $failing"
+ exit 1
+fi
+
+exit 0