]> arthur.barton.de Git - bup.git/commitdiff
Teach pytest to handle WVSKIP and use it where we can
authorRob Browning <rlb@defaultvalue.org>
Sat, 4 Dec 2021 18:32:50 +0000 (12:32 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sun, 5 Dec 2021 20:26:53 +0000 (14:26 -0600)
Have pytest scan the wvtest output for skip messages, and for now,
treat the whole test as skipped if we find any.  This means that
for now WVSKIP can only be used as an up-front guard, but that's all
we need in most cases.

This should help make it more likely that we'll notice when tests are
unexpectedly skipped.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
12 files changed:
test/ext/conftest.py
test/ext/test-fuse
test/ext/test-import-duplicity
test/ext/test-import-rdiff-backup
test/ext/test-index-check-device
test/ext/test-meta
test/ext/test-restore-map-owner
test/ext/test-save-restore
test/ext/test-save-strip-graft
test/ext/test-sparse-files
test/ext/test-web
test/ext/test-xdev

index a79d03374f6cdefe60042a58e193aa160d5026d7..2c8f03e8e9d45dd00cea7ebd26bd6ea2c320b625 100644 (file)
@@ -28,7 +28,12 @@ class BupSubprocTestRunner(pytest.Item):
         out = p.communicate()[0]
         sys.stdout.flush()
         byte_stream(sys.stdout).write(out)
-        failures = [line for line in out.splitlines()
+        lines = out.splitlines()
+        for line in lines:
+            if line.startswith(b'!') and line.lower().endswith(b' skip ok'):
+                pytest.skip(line.decode('ascii'))
+                return
+        failures = [line for line in lines
                     if (line.startswith(b'!')
                         and line.lower().endswith(b' failed'))]
         if failures or p.returncode != 0:
index f3ca49355089fbca730c50d9e70630ada8bc7c62..bfe04a978928fccb859c4ab6efe3574cfed8d77b 100755 (executable)
@@ -9,22 +9,22 @@ unset BLOCKSIZE BLOCK_SIZE DF_BLOCK_SIZE
 root_status="$(dev/root-status)" || exit $?
 
 if ! bup-python -c 'import fuse' 2> /dev/null; then
-    WVSTART 'unable to import fuse; skipping test'
+    WVSKIP 'unable to import fuse; skipping test'
     exit 0
 fi
 
 if test -n "$(type -p modprobe)" && ! modprobe fuse; then
-    echo 'Unable to load fuse module; skipping dependent tests.' 1>&2
+    WVSKIP 'Unable to load fuse module; skipping dependent tests.'
     exit 0
 fi
 
 if ! fusermount -V; then
-    echo 'skipping FUSE tests: fusermount does not appear to work'
+    WVSKIP 'skipping FUSE tests: fusermount does not appear to work'
     exit 0
 fi
 
 if ! groups | grep -q fuse && test "$root_status" != root; then
-    echo 'skipping FUSE tests: you are not root and not in the fuse group'
+    WVSKIP 'skipping FUSE tests: you are not root and not in the fuse group'
     exit 0
 fi
 
index 9374f9a80b4c9054fb6095bb75af4c010f0a2bd7..289793ec39b9c4669500ac0f529b3b5c6d346dc3 100755 (executable)
@@ -4,8 +4,7 @@
 set -o pipefail
 
 if ! [ "$(type -p duplicity)" != "" ]; then
-    # FIXME: add WVSKIP.
-    echo "Cannot find duplicity; skipping test)" 1>&2
+    WVSKIP 'Cannot find duplicity; skipping test)'
     exit 0
 fi
 
index 359f081149887d31801851ce69adb30298f05f58..6e719ec363e0550a0e29ff170917468f9501d98f 100755 (executable)
@@ -12,8 +12,7 @@ export GIT_DIR="$tmpdir/bup"
 bup() { "$top/bup" "$@"; }
 
 if ! [ "$(type -p rdiff-backup)" != "" ]; then
-    # FIXME: add WVSKIP.
-    echo "Cannot find rdiff-backup; skipping test)" 1>&2
+    WVSKIP 'Cannot find rdiff-backup; skipping test)'
     exit 0
 fi
 
index a0861c711938bee4b779d4afca0c9be852c71080..3bba9999b308954119dce52584e97198e345802d 100755 (executable)
@@ -7,23 +7,23 @@ set -o pipefail
 root_status="$(dev/root-status)" || exit $?
 
 if [ "$root_status" != root ]; then
-    echo 'Not root: skipping --check-device tests.'
-    exit 0 # FIXME: add WVSKIP.
+    WVSKIP 'Not root: skipping --check-device tests.'
+    exit 0
 fi
 
 if test -n "$(type -p modprobe)" && ! modprobe loop; then
-    echo 'Unable to load loopback module; skipping --check-device test.' 1>&2
+    WVSKIP 'Unable to load loopback module; skipping --check-device test.'
     exit 0
 fi
 
 if test -z "$(type -p losetup)"; then
-    echo 'Unable to find losetup: skipping --check-device tests.' 1>&2
-    exit 0 # FIXME: add WVSKIP.
+    WVSKIP 'Unable to find losetup: skipping --check-device tests.'
+    exit 0
 fi
 
 if test -z "$(type -p mke2fs)"; then
-    echo 'Unable to find mke2fs: skipping --check-device tests.' 1>&2
-    exit 0 # FIXME: add WVSKIP.
+    WVSKIP 'Unable to find mke2fs: skipping --check-device tests.'
+    exit 0
 fi
 
 WVSTART '--check-device'
index a20748b207092518c886a3c1dc85355ac08e95ea..4d6b86aaed94de96a506745b2dc94a7d22e66fb1 100755 (executable)
@@ -640,7 +640,7 @@ if [ "$root_status" = root ]; then
 
         if ! modprobe loop; then
             echo 'Unable to load loopback module; skipping dependent tests.' 1>&2
-            exit 0
+            exit 0 # FIXME: allow intermixed WVSKIPs
         fi
 
         testfs="$(WVPASS wvmkmountpt)" || exit $?
index 348ce3c3230a06a25764c3a3fca6da2c0db29b9f..ff164da610ae15ba0437e09a2385ed08efe6adf1 100755 (executable)
@@ -5,8 +5,8 @@
 root_status="$(dev/root-status)" || exit $?
 
 if [ "$root_status" != root ]; then
-    echo 'Not root: skipping restore --map-* tests.'
-    exit 0 # FIXME: add WVSKIP.
+    WVSKIP 'Not root: skipping restore --map-* tests.'
+    exit 0
 fi
 
 top="$(WVPASS pwd)" || exit $?
index 30ade4c5c078dba56a0a61fc2896e9cff52d0222..012ae688433d2b5e8c1dffea593926f4c7d52aff 100755 (executable)
@@ -131,7 +131,7 @@ WVSTART "save disjoint top-level directories"
 
     if [ "$pwd_top" = "$tmp_top" ]; then
         echo "(running from within /$tmp_top; skipping test)" 1>&2
-        exit 0
+        exit 0 # FIXME: allow intermixed WVSKIPs
     fi
     D=bupdata.tmp
     WVPASS force-delete $D
index 78b79fe7e2ec925f919744717a805ab340cdf04a..32b954b818234bfcc1f0ff58ab161d92c8f5e887 100755 (executable)
@@ -59,7 +59,7 @@ then
     # current filesystem may fail -- i.e. running from
     # /foo/ext4/bar/btrfs will fail when bup tries to restore linux
     # attrs above btrfs to the restore tree *inside* btrfs.
-    # FIXME: add WVSKIP
+    # FIXME: allow intermixed WVSKIPs
     echo "(running from tree with mixed filesystems; skipping test)" 1>&2
     exit 0
 else
index c0007849db5b18e400cf121f5982b8e511179b1d..d19bf18195c0a7b6eefc2efd7f91013334de97de 100755 (executable)
@@ -27,7 +27,7 @@ readonly block_size data_size
 WVPASS dd if=/dev/zero of=test-sparse-probe seek="$data_size" bs=1 count=1
 probe_size=$(WVPASS du -k -s test-sparse-probe | WVPASS cut -f1) || exit $?
 if [ "$probe_size" -ge "$((data_size / 1024))" ]; then
-    WVSTART "no sparse support detected -- skipping tests"
+    WVSKIP "no sparse support detected -- skipping tests"
     exit 0
 fi
 
index b53eb5cfd7a0b0f8ef219134098cb89be5d40448..7349890b9a235891a91d8d3c027023e1697a9cf9 100755 (executable)
@@ -27,21 +27,20 @@ wait-for-server-start()
 
 WVPASS cd "$tmpdir"
 
-# FIXME: add WVSKIP
 if test -z "$(type -p curl)"; then
-    WVSTART 'curl does not appear to be installed; skipping  test'
+    WVSKIP 'curl does not appear to be installed; skipping test'
     exit 0
 fi
     
 WVPASS bup-cfg-py -c "import socket as s; s.socket(s.AF_UNIX).bind('socket')"
 curl -s --unix-socket ./socket http://localhost/foo
 if test $? -ne 7; then
-    WVSTART 'curl does not appear to support --unix-socket; skipping test'
+    WVSKIP 'curl does not appear to support --unix-socket; skipping test'
     exit 0
 fi
 
 if ! bup-python -c 'import tornado' 2> /dev/null; then
-    WVSTART 'unable to import tornado; skipping test'
+    WVSKIP 'unable to import tornado; skipping test'
     exit 0
 fi
 
index 78861a998f0a9e1915b5e9aa4a81b0563d686fc3..cc5a2c0802c512f92e95563f85923dfe4abbe2c4 100755 (executable)
@@ -6,20 +6,20 @@ set -o pipefail
 root_status="$(dev/root-status)" || exit $?
 
 if [ "$root_status" != root ]; then
-    WVSTART 'not root: skipping tests'
-    exit 0 # FIXME: add WVSKIP.
+    WVSKIP 'not root: skipping tests'
+    exit 0
 fi
 
 if ! modprobe loop; then
-    WVSTART 'unable to load loopback module; skipping tests' 1>&2
+    WVSKIP 'unable to load loopback module; skipping tests'
     exit 0
 fi
 
 # These tests are only likely to work under Linux for now
 # (patches welcome).
 if ! [[ $(uname) =~ Linux ]]; then
-    WVSTART 'not Linux: skipping tests'
-    exit 0 # FIXME: add WVSKIP.
+    WVSKIP 'not Linux: skipping tests'
+    exit 0
 fi
 
 top="$(WVPASS pwd)" || exit $?