]> arthur.barton.de Git - bup.git/commitdiff
Move force-delete to t/lib.sh from test.sh and test-meta.sh; improve.
authorRob Browning <rlb@defaultvalue.org>
Fri, 8 Mar 2013 01:55:18 +0000 (19:55 -0600)
committerRob Browning <rlb@defaultvalue.org>
Fri, 8 Mar 2013 02:51:43 +0000 (20:51 -0600)
Only call chattr and setfacl on Linux for now.

Test that each item is actually gone.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
t/lib.sh [new file with mode: 0644]
t/test-meta.sh
t/test.sh

diff --git a/t/lib.sh b/t/lib.sh
new file mode 100644 (file)
index 0000000..e8e5268
--- /dev/null
+++ b/t/lib.sh
@@ -0,0 +1,19 @@
+
+force-delete()
+{
+    # Try *hard* to delete $@.  Among other things, some systems have
+    # r-xr-xr-x for root and other system dirs.
+    rm -rf "$@" # Maybe we'll get lucky.
+    for f in "$@"; do
+        test -e "$@" || continue
+        chmod -R u+w "$@"
+        if [[ $(uname) =~ Linux ]]; then
+            chattr -fR = "$@"
+            setfacl -Rb "$@"
+        fi
+        rm -r "$@"
+        if test -e "$@"; then
+            return 1
+        fi
+    done
+}
index 3a1da1d47522af76563e71f00efd63027c71b504..1354505253f34ebc5569a7ea10919977e5877928 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
 . wvtest.sh
+. t/lib.sh
 
 TOP="$(pwd)"
 export BUP_DIR="$TOP/buptest.tmp"
@@ -34,21 +35,6 @@ actually-root()
     test "$(whoami)" == root -a -z "$FAKEROOTKEY"
 }
 
-force-delete()
-{
-    if ! actually-root; then
-        rm -rf "$@"
-    else
-        # Go to greater lengths to deal with any test detritus.
-        for f in "$@"; do
-            test -e "$@" || continue
-            chattr -fR = "$@" || true
-            setfacl -Rb "$@"
-            rm -r "$@"
-        done
-    fi
-}
-
 test-src-create-extract()
 {
     # Test bup meta create/extract for ./src -> ./src-restore.
index 8c814526a7716548c90c50d8891c6109aca76736..4211658cef4837c3d74f834eb59a2e3a081723a7 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 . wvtest.sh
+. t/lib.sh
+
 #set -e
 
 TOP="$(/bin/pwd)"
@@ -10,17 +12,6 @@ bup()
     "$TOP/bup" "$@"
 }
 
-force-delete()
-{
-    chmod -R u+w "$@"
-    for f in "$@"; do
-        test -e "$@" || continue
-        chattr -fR = "$@" || true
-        setfacl -Rb "$@"
-        rm -r "$@"
-    done
-}
-
 WVSTART "init"
 
 #set -x