]> arthur.barton.de Git - bup.git/blobdiff - t/test-rm-between-index-and-save.sh
save: always push parents when entering a subtree
[bup.git] / t / test-rm-between-index-and-save.sh
index 1f21ac7a5666dd151fdb9c31d86baccf1204716d..67c5b8ad89c22f341c9c43f70f8a53c92a21a34e 100755 (executable)
@@ -1,10 +1,10 @@
 #!/usr/bin/env bash
-. ./wvtest-bup.sh
+. ./wvtest-bup.sh || exit $?
 
-set -e -o pipefail
+set -o pipefail
 
-top="$(pwd)"
-tmpdir="$(wvmktempdir)"
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
 export BUP_DIR="$tmpdir/bup"
 D="$tmpdir/data"
 
@@ -13,36 +13,66 @@ 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
+WVPASS mkdir "$D"
+WVPASS bup init
+WVPASS echo "content" > "$D"/foo
+WVPASS echo "content" > "$D"/bar
+WVPASS bup tick
+WVPASS bup index -ux "$D"
+WVPASS bup save -n save-fail-missing "$D"
+WVPASS echo "content" > "$D"/baz
+WVPASS bup tick
+WVPASS bup index -ux "$D"
+WVPASS rm "$D"/foo
+# When "bup tick" is removed above, this may fail (complete with warning),
+# since the ctime/mtime of "foo" might be pushed back:
+WVPASS bup save -n save-fail-missing "$D"
+# when the save-call failed, foo is missing from output, since only
+# then bup notices, that it was removed:
+WVPASSEQ "$(bup ls -A save-fail-missing/latest/$TOP/$D/)" "bar
+baz
+foo"
+# index/save again
+WVPASS bup tick
+WVPASS bup index -ux "$D"
+WVPASS bup save -n save-fail-missing "$D"
+# now foo is gone:
+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
+WVPASS rm -r "$D"
+WVPASS mkdir "$D"
+WVPASS rm -r "$BUP_DIR"
+WVPASS bup init
+WVPASS mkdir "$D"/foo
+WVPASS mkdir "$D"/bar
+WVPASS bup tick
+WVPASS bup index -ux "$D"
+WVPASS bup save -n save-fail-missing "$D"
+WVPASS touch "$D"/bar
+WVPASS mkdir "$D"/baz
+WVPASS bup tick
+WVPASS bup index -ux "$D"
+WVPASS rmdir "$D"/foo
+# with directories, bup notices that foo is missing, so it fails
+# (complete with delayed error)
 WVFAIL bup save -n save-fail-missing "$D"
-WVPASSEQ "$(bup ls -a save-fail-missing/latest/$TOP/$D/)" "bar/
+# ...but foo is still saved since it was just fine in the index
+WVPASSEQ "$(bup ls -AF save-fail-missing/latest/$TOP/$D/)" "bar/
+baz/
+foo/"
+# Index again:
+WVPASS bup tick
+WVPASS bup index -ux "$D"
+# no non-zero-exitcode anymore:
+WVPASS bup save -n save-fail-missing "$D"
+# foo is now gone
+WVPASSEQ "$(bup ls -AF save-fail-missing/latest/$TOP/$D/)" "bar/
 baz/"
 
-rm -rf "$tmpdir"
+WVPASS rm -rf "$tmpdir"
+