]> arthur.barton.de Git - bup.git/blob - t/test-index.sh
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / test-index.sh
1 #!/usr/bin/env bash
2 . wvtest.sh
3 . wvtest-bup.sh
4 . t/lib.sh
5
6 set -o pipefail
7
8 top="$(WVPASS pwd)" || exit $?
9 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
11
12 bup() { "$top/bup" "$@"; }
13
14 WVPASS cd "$tmpdir"
15
16 WVPASS bup init
17
18 WVSTART "index"
19 D=bupdata.tmp
20 WVPASS force-delete $D
21 WVPASS mkdir $D
22 WVFAIL bup index --exclude-from $D/cannot-exist $D
23 WVPASSEQ "$(bup index --check -p)" ""
24 WVPASSEQ "$(bup index --check -p $D)" ""
25 WVFAIL [ -e $D.fake ]
26 WVFAIL bup index --check -u $D.fake
27 WVPASS bup index --check -u $D
28 WVPASSEQ "$(bup index --check -p $D)" "$D/"
29 WVPASS touch $D/a
30 WVPASS bup random 128k >$D/b
31 WVPASS mkdir $D/d $D/d/e
32 WVPASS bup random 512 >$D/f
33 WVPASS ln -s non-existent-file $D/g
34 WVPASSEQ "$(bup index -s $D/)" "A $D/"
35 WVPASSEQ "$(bup index -s $D/b)" ""
36 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
37 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
38 "A $D/d/e/
39 A $D/d/
40 A $D/b"
41 WVPASS touch $D/d/z
42 WVPASS bup tick
43 WVPASSEQ "$(bup index --check -usx $D)" \
44 "A $D/g
45 A $D/f
46 A $D/d/z
47 A $D/d/e/
48 A $D/d/
49 A $D/b
50 A $D/a
51 A $D/"
52 WVPASSEQ "$(bup index --check -us $D/a $D/b --fake-valid)" \
53 "  $D/b
54   $D/a"
55 WVPASSEQ "$(bup index --check -us $D/a)" "  $D/a"  # stays unmodified
56 WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
57 "  $D/d/z
58   $D/d/e/
59   $D/d/"
60 WVPASS touch $D/d/z
61 WVPASS bup index -u $D/d/z  # becomes modified
62 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
63 "A $D/g
64 A $D/f
65 M $D/d/z
66   $D/d/e/
67 M $D/d/
68   $D/b
69   $D/a
70 A $D/"
71
72 WVPASS bup index -u $D/d/e $D/a --fake-invalid
73 WVPASSEQ "$(cd $D && bup index -m .)" \
74 "./g
75 ./f
76 ./d/z
77 ./d/e/
78 ./d/
79 ./a
80 ./"
81 WVPASSEQ "$(cd $D && bup index -m)" \
82 "g
83 f
84 d/z
85 d/e/
86 d/
87 a
88 ./"
89 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
90
91 WVFAIL bup save -t $D/doesnt-exist-filename
92
93 WVPASS mv "$BUP_DIR/bupindex" "$BUP_DIR/bi.old"
94 WVFAIL bup save -t $D/d/e/fifotest
95 WVPASS mkfifo $D/d/e/fifotest
96 WVPASS bup index -u $D/d/e/fifotest
97 WVPASS bup save -t $D/d/e/fifotest
98 WVPASS bup save -t $D/d/e
99 WVPASS rm -f $D/d/e/fifotest
100 WVPASS bup index -u $D/d/e
101 WVFAIL bup save -t $D/d/e/fifotest
102 WVPASS mv "$BUP_DIR/bi.old" "$BUP_DIR/bupindex"
103
104 WVPASS bup index -u $D/d/e
105 WVPASS bup save -t $D/d/e
106 WVPASSEQ "$(cd $D && bup index -m)" \
107 "g
108 f
109 d/z
110 d/
111 a
112 ./"
113 WVPASS bup save -t $D/d
114 WVPASS bup index --fake-invalid $D/d/z
115 WVPASS bup save -t $D/d/z
116 WVPASS bup save -t $D/d/z  # test regenerating trees when no files are changed
117 WVPASS bup save -t $D/d
118 WVPASSEQ "$(cd $D && bup index -m)" \
119 "g
120 f
121 a
122 ./"
123 WVPASS bup save -r ":$BUP_DIR" -n r-test $D
124 WVFAIL bup save -r ":$BUP_DIR/fake/path" -n r-test $D
125 WVFAIL bup save -r ":$BUP_DIR" -n r-test $D/fake/path
126
127 WVPASS rm -rf "$tmpdir"