]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Better comments, TAP conformance 504/head
authorMartin Vidner <mvidner@suse.cz>
Thu, 28 Nov 2019 13:31:06 +0000 (14:31 +0100)
committerMartin Vidner <mvidner@suse.cz>
Thu, 28 Nov 2019 13:31:06 +0000 (14:31 +0100)
This test has been quickly and dirtily converted to TAP,
the Test Anything Protocol, http://testanything.org/tap-specification.html

testsuite-real/CAUTION
testsuite-real/run-all
testsuite-real/setup-and-run-all

index ac0d3dc22d1fbafcbfd50c1a48b880b7c61c8319..25c6106540ca835f4cb924311b3f3491ed417489 100644 (file)
@@ -7,7 +7,7 @@ The tests in this directory only work when run as the root user.
 
 They operate
 - on a scratch BTRFS filesystem (`/testsuite`)
-- created in a loopback-mounted file (`/testsuite.img`),
+- created in a loopback-mounted file (`/testsuite-of-snapper.img`),
 - using a scratch Snapper configuration (`testsuite`).
 
 However bugs do happen so it is recommended that you
@@ -16,3 +16,6 @@ LOSS OR CORRUPTION OF YOUR OWN BTRFS SNAPSHOTS AND DATA.
 
 See `setup-and-run-all` for the scratch setup and `run-all` for the actual
 test set.
+
+The tests conform to the Test Anything Protocol (sloppily).
+`prove setup-and-run-all` works.
index 70afdfbd94d5315c8c1e80a3423dd218472417f6..d24075f385e5cfee6da979f912883a1174967752 100755 (executable)
@@ -6,19 +6,28 @@ if [ "$(id -u)" != "0" ]; then
    exit 1
 fi
 
+# This test has been quickly and dirtily converted to TAP,
+# the Test Anything Protocol, http://testanything.org/tap-specification.html
+COUNT=0
+SUCCESS=true
+
 function run()
 {
+    COUNT=$((COUNT + 1))
     cmd=$1
 
-    echo
-    echo "*** running $cmd ***"
-    echo
+    echo >&2
+    echo >&2 "*** running $cmd ***"
+    echo >&2
 
     ./$cmd
 
     if [ $? != 0 ] ; then
-        echo "failed"
-        exit 1
+        echo "not ok $COUNT $cmd"
+        SUCCESS=false
+        # exit 1
+    else
+        echo "ok $COUNT $cmd"
     fi
 }
 
@@ -45,3 +54,6 @@ test -x xattrs1 && run xattrs1
 test -x xattrs2 && run xattrs2
 test -x xattrs3 && run xattrs3
 test -x xattrs4 && run xattrs4
+
+echo "1..$COUNT" # TAP test plan
+$SUCCESS
index f3edd0dca69d2ef6543055d90572ffdc157355bd..1e0485ae4c2aa07a971edcab7982c873756ee039 100755 (executable)
@@ -1,6 +1,11 @@
 #!/bin/bash
-set -eu
-set -x
+set -e # exit on failure.
+# ^
+# This also ensures that a failed test does not run the teardown step
+# and we can inspect the artifacts.
+set -u # unset variables are an error
+set -x # echo what's being done
+
 if [ "$(id -u)" != "0" ]; then
     set +x
     echo "These tests only work when run as root." >&2