]> arthur.barton.de Git - bup.git/commitdiff
Add tests for file and dir removal between index and save.
authorTim Riemenschneider <t.riemenschneider@detco.de>
Wed, 6 Mar 2013 13:33:22 +0000 (14:33 +0100)
committerRob Browning <rlb@defaultvalue.org>
Mon, 25 Mar 2013 00:35:40 +0000 (19:35 -0500)
Make sure the removals don't cause bup save to immediately abort.

Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
[rlb@defaultvalue.org: move tests to their own file.]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
t/test-rm-between-index-and-save.sh [new file with mode: 0755]

index 241a4bc82efcf9711f004eebd5488cd373c5eca7..b6a327fd69ac16a9b3e885bd7868c0761c03900a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -86,10 +86,11 @@ runtests-python: all
        $(PYTHON) wvtest.py lib/bup/t/tmetadata.py
 
 runtests-cmdline: all
-       t/test.sh
+       t/test-index-check-device.sh
        t/test-meta.sh
        t/test-restore-single-file.sh
-       t/test-index-check-device.sh
+       t/test-rm-between-index-and-save.sh
+       t/test.sh
 
 stupid:
        PATH=/bin:/usr/bin $(MAKE) test
diff --git a/t/test-rm-between-index-and-save.sh b/t/test-rm-between-index-and-save.sh
new file mode 100755 (executable)
index 0000000..1f21ac7
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+. ./wvtest-bup.sh
+
+set -e -o pipefail
+
+top="$(pwd)"
+tmpdir="$(wvmktempdir)"
+export BUP_DIR="$tmpdir/bup"
+D="$tmpdir/data"
+
+bup() { "$top/bup" "$@"; }
+
+WVSTART "remove file"
+# Fixed in commit 8585613c1f45f3e20feec00b24fc7e3a948fa23e ("Store
+# metadata in the index....")
+mkdir "$D"
+bup init
+echo "content" > "$D"/foo
+echo "content" > "$D"/bar
+bup index -ux "$D"
+bup save -n save-fail-missing "$D"
+echo "content" > "$D"/baz
+bup index -ux "$D"
+rm "$D"/foo
+WVFAIL bup save -n save-fail-missing "$D"
+WVPASSEQ "$(bup ls -a save-fail-missing/latest/$TOP/$D/)" "bar
+baz"
+
+# TODO: Test for racecondition between reading a file and reading its metadata?
+
+WVSTART "remove dir"
+rm -r "$D"
+mkdir "$D"
+rm -r "$BUP_DIR"
+bup init
+mkdir "$D"/foo
+mkdir "$D"/bar
+bup index -ux "$D"
+bup save -n save-fail-missing "$D"
+touch "$D"/bar
+mkdir "$D"/baz
+bup index -ux "$D"
+rmdir "$D"/foo
+WVFAIL bup save -n save-fail-missing "$D"
+WVPASSEQ "$(bup ls -a save-fail-missing/latest/$TOP/$D/)" "bar/
+baz/"
+
+rm -rf "$tmpdir"