]> arthur.barton.de Git - bup.git/blob - t/test-rm-between-index-and-save.sh
Add tests for file and dir removal between index and save.
[bup.git] / t / test-rm-between-index-and-save.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh
3
4 set -e -o pipefail
5
6 top="$(pwd)"
7 tmpdir="$(wvmktempdir)"
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 mkdir "$D"
17 bup init
18 echo "content" > "$D"/foo
19 echo "content" > "$D"/bar
20 bup index -ux "$D"
21 bup save -n save-fail-missing "$D"
22 echo "content" > "$D"/baz
23 bup index -ux "$D"
24 rm "$D"/foo
25 WVFAIL bup save -n save-fail-missing "$D"
26 WVPASSEQ "$(bup ls -a save-fail-missing/latest/$TOP/$D/)" "bar
27 baz"
28
29 # TODO: Test for racecondition between reading a file and reading its metadata?
30
31 WVSTART "remove dir"
32 rm -r "$D"
33 mkdir "$D"
34 rm -r "$BUP_DIR"
35 bup init
36 mkdir "$D"/foo
37 mkdir "$D"/bar
38 bup index -ux "$D"
39 bup save -n save-fail-missing "$D"
40 touch "$D"/bar
41 mkdir "$D"/baz
42 bup index -ux "$D"
43 rmdir "$D"/foo
44 WVFAIL bup save -n save-fail-missing "$D"
45 WVPASSEQ "$(bup ls -a save-fail-missing/latest/$TOP/$D/)" "bar/
46 baz/"
47
48 rm -rf "$tmpdir"