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