]> arthur.barton.de Git - bup.git/commitdiff
Move save --strip/--graft tests from test.sh to test-save-strip-graft.sh.
authorRob Browning <rlb@defaultvalue.org>
Tue, 31 Dec 2013 17:35:21 +0000 (11:35 -0600)
committerRob Browning <rlb@defaultvalue.org>
Tue, 31 Dec 2013 17:37:53 +0000 (11:37 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
t/test-save-strip-graft.sh [new file with mode: 0755]
t/test.sh

index 7f063b3ce93764a202d9122bb08968890e6e557d..b125a6e3836786409726a9d938446ca147d102a6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -97,6 +97,7 @@ runtests-cmdline: all
        TMPDIR="$(test_tmp)" t/test-command-without-init-fails.sh
        TMPDIR="$(test_tmp)" t/test-redundant-saves.sh
        TMPDIR="$(test_tmp)" t/test-save-restore-exclude-rx.sh
+       TMPDIR="$(test_tmp)" t/test-save-strip-graft.sh
        TMPDIR="$(test_tmp)" t/test.sh
 
 stupid:
diff --git a/t/test-save-strip-graft.sh b/t/test-save-strip-graft.sh
new file mode 100755 (executable)
index 0000000..4f0e35d
--- /dev/null
@@ -0,0 +1,152 @@
+#!/usr/bin/env bash
+. ./wvtest-bup.sh
+. t/lib.sh
+
+set -o pipefail
+
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
+
+export BUP_DIR="$tmpdir/bup"
+export GIT_DIR="$tmpdir/bup"
+
+bup() { "$top/bup" "$@"; }
+compare-trees() { "$top/t/compare-trees" "$@"; }
+
+WVPASS cd "$tmpdir"
+
+
+WVSTART "save --strip"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save --strip -n foo src/x/y
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/x/y/ restore/latest/
+
+
+WVSTART "save --strip-path (relative)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save --strip-path src -n foo src/x
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/ restore/latest/
+
+
+WVSTART "save --strip-path (absolute)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save --strip-path "$tmpdir" -n foo src
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/ "restore/latest/src/"
+
+
+WVSTART "save --strip-path (no match)"
+if test $(WVPASS path-filesystems . | WVPASS sort -u | WVPASS wc -l) -ne 1
+then
+    # Skip the test because the attempt to restore parent dirs to the
+    # 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
+    echo "(running from tree with mixed filesystems; skipping test)" 1>&2
+    exit 0
+else
+    WVPASS force-delete "$BUP_DIR" src restore
+    WVPASS bup init
+    WVPASS mkdir -p src/x/y/z
+    WVPASS bup random 8k > src/x/y/random-1
+    WVPASS bup random 8k > src/x/y/z/random-2
+    WVPASS bup index -u src
+    WVPASS bup save --strip-path foo -n foo src/x
+    WVPASS bup restore -C restore /foo/latest
+    WVPASS compare-trees src/ "restore/latest/$tmpdir/src/"
+fi
+
+
+WVSTART "save --graft (empty graft points disallowed)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir src
+WVFAIL bup save --graft =/grafted -n graft-point-absolute src 2>&1 \
+    | WVPASS grep 'error: a graft point cannot be empty'
+WVFAIL bup save --graft $top/$tmp= -n graft-point-absolute src 2>&1 \
+    | WVPASS grep 'error: a graft point cannot be empty'
+
+
+WVSTART "save --graft /x/y=/a/b (relative paths)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save --graft src=x -n foo src
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/ "restore/latest/$tmpdir/x/"
+
+
+WVSTART "save --graft /x/y=/a/b (matching structure)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save -v --graft "$tmpdir/src/x/y=$tmpdir/src/a/b" -n foo src/x/y
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/x/y/ "restore/latest/$tmpdir/src/a/b/"
+
+
+WVSTART "save --graft /x/y=/a (shorter target)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save -v --graft "$tmpdir/src/x/y=/a" -n foo src/x/y
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/x/y/ "restore/latest/a/"
+
+
+WVSTART "save --graft /x=/a/b (longer target)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save -v --graft "$tmpdir/src=$tmpdir/src/a/b/c" -n foo src
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/ "restore/latest/$tmpdir/src/a/b/c/"
+
+
+WVSTART "save --graft /x=/ (root target)"
+WVPASS force-delete "$BUP_DIR" src restore
+WVPASS bup init
+WVPASS mkdir -p src/x/y/z
+WVPASS bup random 8k > src/x/y/random-1
+WVPASS bup random 8k > src/x/y/z/random-2
+WVPASS bup index -u src
+WVPASS bup save -v --graft "$tmpdir/src/x=/" -n foo src/x
+WVPASS bup restore -C restore /foo/latest
+WVPASS compare-trees src/x/ "restore/latest/"
+
+
+#WVSTART "save --graft /=/x/ (root source)"
+# FIXME: Not tested for now -- will require cleverness, or caution as root.
+
+
+WVPASS rm -rf "$tmpdir"
index be0d54996d128c0c34c99862e5f52b7e34a856b6..a5c286b49db747e8227e0d75fe9ba7a7c936ed36 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -413,177 +413,6 @@ WVSTART "save (no index)"
     WVPASS rm -r "$tmp"
 ) || exit $?
 
-WVSTART "save --strip"
-(
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save --strip -n foo $tmp/src/x/y
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/"
-) || exit $?
-
-WVSTART "save --strip-path (relative)"
-(
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save --strip-path $tmp/src -n foo $tmp/src/x
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/"
-) || exit $?
-
-WVSTART "save --strip-path (absolute)"
-(
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save --strip-path "$TOP" -n foo $tmp/src
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$tmp/src/"
-) || exit $?
-
-WVSTART "save --strip-path (no match)"
-(
-    if test $(WVPASS path-filesystems . | WVPASS sort -u | WVPASS wc -l) -ne 1
-    then
-        # Skip the test because the attempt to restore parent dirs to
-        # the 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.
-        echo "(running from tree with mixed filesystems; skipping test)" 1>&2
-        exit 0
-    fi
-
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save --strip-path $tmp/foo -n foo $tmp/src/x
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/"
-) || exit $?
-
-WVSTART "save --graft (empty graft points disallowed)"
-(
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVFAIL bup save --graft =/grafted -n graft-point-absolute $tmp
-    WVFAIL bup save --graft $TOP/$tmp= -n graft-point-absolute $tmp
-) || exit $?
-
-WVSTART "save --graft /x/y=/a/b (relative paths)"
-(
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save --graft $tmp/src=x -n foo $tmp/src
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/x/"
-) || exit $?
-
-WVSTART "save --graft /x/y=/a/b (matching structure)"
-(
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=$TOP/$tmp/src/a/b" \
-        -n foo $tmp/src/x/y
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/x/y/ \
-        "$tmp/restore/latest/$TOP/$tmp/src/a/b/"
-) || exit $?
-
-WVSTART "save --graft /x/y=/a (shorter target)"
-(
-    tmp=graft-points.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=/a" -n foo $tmp/src/x/y
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/a/"
-) || exit $?
-
-WVSTART "save --graft /x=/a/b (longer target)"
-(
-    tmp=graft-points.tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save -v --graft "$TOP/$tmp/src=$TOP/$tmp/src/a/b/c" \
-        -n foo $tmp/src
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/a/b/c/"
-) || exit $?
-
-WVSTART "save --graft /x=/ (root target)"
-(
-    tmp=graft-points.tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save -v --graft "$TOP/$tmp/src/x=/" -n foo $tmp/src/x
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS t/compare-trees $tmp/src/x/ "$tmp/restore/latest/"
-) || exit $?
-
-#WVSTART "save --graft /=/x/ (root source)"
-# FIXME: Not tested for now -- will require cleverness, or caution as root.
-
 WVSTART "indexfile"
 D=indexfile.tmp
 INDEXFILE=tmpindexfile.tmp