]> arthur.barton.de Git - bup.git/blob - 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
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3
4 set -o pipefail
5
6 top="$(WVPASS pwd)" || exit $?
7 tmpdir="$(WVPASS wvmktempdir)" || exit $?
8 export BUP_DIR="$tmpdir/bup"
9 D="$tmpdir/data"
10
11 bup() { "$top/bup" "$@"; }
12
13 WVSTART "remove file"
14 # Fixed in commit 8585613c1f45f3e20feec00b24fc7e3a948fa23e ("Store
15 # metadata in the index....")
16 WVPASS mkdir "$D"
17 WVPASS bup init
18 WVPASS echo "content" > "$D"/foo
19 WVPASS echo "content" > "$D"/bar
20 WVPASS bup tick
21 WVPASS bup index -ux "$D"
22 WVPASS bup save -n save-fail-missing "$D"
23 WVPASS echo "content" > "$D"/baz
24 WVPASS bup tick
25 WVPASS bup index -ux "$D"
26 WVPASS rm "$D"/foo
27 # When "bup tick" is removed above, this may fail (complete with warning),
28 # since the ctime/mtime of "foo" might be pushed back:
29 WVPASS bup save -n save-fail-missing "$D"
30 # when the save-call failed, foo is missing from output, since only
31 # then bup notices, that it was removed:
32 WVPASSEQ "$(bup ls -A save-fail-missing/latest/$TOP/$D/)" "bar
33 baz
34 foo"
35 # index/save again
36 WVPASS bup tick
37 WVPASS bup index -ux "$D"
38 WVPASS bup save -n save-fail-missing "$D"
39 # now foo is gone:
40 WVPASSEQ "$(bup ls -A save-fail-missing/latest/$TOP/$D/)" "bar
41 baz"
42
43
44 # TODO: Test for racecondition between reading a file and reading its metadata?
45
46 WVSTART "remove dir"
47 WVPASS rm -r "$D"
48 WVPASS mkdir "$D"
49 WVPASS rm -r "$BUP_DIR"
50 WVPASS bup init
51 WVPASS mkdir "$D"/foo
52 WVPASS mkdir "$D"/bar
53 WVPASS bup tick
54 WVPASS bup index -ux "$D"
55 WVPASS bup save -n save-fail-missing "$D"
56 WVPASS touch "$D"/bar
57 WVPASS mkdir "$D"/baz
58 WVPASS bup tick
59 WVPASS bup index -ux "$D"
60 WVPASS rmdir "$D"/foo
61 # with directories, bup notices that foo is missing, so it fails
62 # (complete with delayed error)
63 WVFAIL bup save -n save-fail-missing "$D"
64 # ...but foo is still saved since it was just fine in the index
65 WVPASSEQ "$(bup ls -AF save-fail-missing/latest/$TOP/$D/)" "bar/
66 baz/
67 foo/"
68 # Index again:
69 WVPASS bup tick
70 WVPASS bup index -ux "$D"
71 # no non-zero-exitcode anymore:
72 WVPASS bup save -n save-fail-missing "$D"
73 # foo is now gone
74 WVPASSEQ "$(bup ls -AF save-fail-missing/latest/$TOP/$D/)" "bar/
75 baz/"
76
77 WVPASS rm -rf "$tmpdir"
78