]> arthur.barton.de Git - bup.git/blob - t/test-save-restore-exclude-rx.sh
Move compression tests from test.sh to test-compression.sh.
[bup.git] / t / test-save-restore-exclude-rx.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh
3
4 set -o pipefail
5
6 top="$(WVPASS pwd)" || exit $?
7 tmpdir="$(WVPASS wvmktempdir)" || exit $?
8
9 export BUP_DIR="$tmpdir/bup"
10 export GIT_DIR="$tmpdir/bup"
11
12 bup() { "$top/bup" "$@"; }
13
14 WVPASS bup init
15 WVPASS cd "$tmpdir"
16
17
18 # bup index --exclude-rx ...
19 # ==========================
20
21 WVSTART "index --exclude-rx '^/foo' (root anchor)"
22 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
23 WVPASS bup init
24 WVPASS mkdir src
25 WVPASS touch src/a
26 WVPASS touch src/b
27 WVPASS mkdir src/sub1
28 WVPASS mkdir src/sub2
29 WVPASS touch src/sub1/a
30 WVPASS touch src/sub2/b
31 WVPASS bup index -u src --exclude-rx "^$(pwd)/src/sub1/"
32 WVPASS bup save --strip -n bupdir src
33 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
34 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
35 WVPASSEQ "$actual" ".
36 ./a
37 ./b
38 ./sub2
39 ./sub2/b"
40
41 WVSTART "index --exclude-rx '/foo$' (non-dir, tail anchor)"
42 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
43 WVPASS bup init
44 WVPASS mkdir src
45 WVPASS touch src/a
46 WVPASS touch src/b
47 WVPASS touch src/foo
48 WVPASS mkdir src/sub
49 WVPASS mkdir src/sub/foo
50 WVPASS touch src/sub/foo/a
51 WVPASS bup index -u src --exclude-rx '/foo$'
52 WVPASS bup save --strip -n bupdir src
53 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
54 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
55 WVPASSEQ "$actual" ".
56 ./a
57 ./b
58 ./sub
59 ./sub/foo
60 ./sub/foo/a"
61
62 WVSTART "index --exclude-rx '/foo/$' (dir, tail anchor)"
63 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
64 WVPASS bup init
65 WVPASS mkdir src
66 WVPASS touch src/a
67 WVPASS touch src/b
68 WVPASS touch src/foo
69 WVPASS mkdir src/sub
70 WVPASS mkdir src/sub/foo
71 WVPASS touch src/sub/foo/a
72 WVPASS bup index -u src --exclude-rx '/foo/$'
73 WVPASS bup save --strip -n bupdir src
74 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
75 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
76 WVPASSEQ "$actual" ".
77 ./a
78 ./b
79 ./foo
80 ./sub"
81
82 WVSTART "index --exclude-rx '/foo/.' (dir content)"
83 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
84 WVPASS bup init
85 WVPASS mkdir src
86 WVPASS touch src/a
87 WVPASS touch src/b
88 WVPASS touch src/foo
89 WVPASS mkdir src/sub
90 WVPASS mkdir src/sub/foo
91 WVPASS touch src/sub/foo/a
92 WVPASS bup index -u src --exclude-rx '/foo/.'
93 WVPASS bup save --strip -n bupdir src
94 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
95 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
96 WVPASSEQ "$actual" ".
97 ./a
98 ./b
99 ./foo
100 ./sub
101 ./sub/foo"
102
103
104 # bup index --exclude-rx-from ...
105 # ===============================
106 WVSTART "index --exclude-rx-from"
107 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
108 WVPASS bup init
109 WVPASS mkdir src
110 WVPASS touch src/a
111 WVPASS touch src/b
112 WVPASS mkdir src/sub1
113 WVPASS mkdir src/sub2
114 WVPASS touch src/sub1/a
115 WVPASS touch src/sub2/b
116 WVPASS echo "^$(pwd)/src/sub1/" > exclude-rx-file
117 WVPASS bup index -u src --exclude-rx-from exclude-rx-file
118 WVPASS bup save --strip -n bupdir src
119 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
120 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
121 WVPASSEQ "$actual" ".
122 ./a
123 ./b
124 ./sub2
125 ./sub2/b"
126
127
128 # bup restore --exclude-rx ...
129 # ============================
130
131 WVSTART "restore --exclude-rx '^/foo' (root anchor)"
132 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
133 WVPASS bup init
134 WVPASS mkdir src
135 WVPASS touch src/a
136 WVPASS touch src/b
137 WVPASS mkdir src/sub1
138 WVPASS mkdir src/sub2
139 WVPASS touch src/sub1/a
140 WVPASS touch src/sub2/b
141 WVPASS bup index -u src
142 WVPASS bup save --strip -n bupdir src
143 WVPASS bup restore -C buprestore.tmp --exclude-rx "^/sub1/" /bupdir/latest/
144 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
145 WVPASSEQ "$actual" ".
146 ./a
147 ./b
148 ./sub2
149 ./sub2/b"
150
151 WVSTART "restore --exclude-rx '/foo$' (non-dir, tail anchor)"
152 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
153 WVPASS bup init
154 WVPASS mkdir src
155 WVPASS touch src/a
156 WVPASS touch src/b
157 WVPASS touch src/foo
158 WVPASS mkdir src/sub
159 WVPASS mkdir src/sub/foo
160 WVPASS touch src/sub/foo/a
161 WVPASS bup index -u src
162 WVPASS bup save --strip -n bupdir src
163 WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo$' /bupdir/latest/
164 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
165 WVPASSEQ "$actual" ".
166 ./a
167 ./b
168 ./sub
169 ./sub/foo
170 ./sub/foo/a"
171
172 WVSTART "restore --exclude-rx '/foo/$' (dir, tail anchor)"
173 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
174 WVPASS bup init
175 WVPASS mkdir src
176 WVPASS touch src/a
177 WVPASS touch src/b
178 WVPASS touch src/foo
179 WVPASS mkdir src/sub
180 WVPASS mkdir src/sub/foo
181 WVPASS touch src/sub/foo/a
182 WVPASS bup index -u src
183 WVPASS bup save --strip -n bupdir src
184 WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo/$' /bupdir/latest/
185 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
186 WVPASSEQ "$actual" ".
187 ./a
188 ./b
189 ./foo
190 ./sub"
191
192 WVSTART "restore --exclude-rx '/foo/.' (dir content)"
193 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
194 WVPASS bup init
195 WVPASS mkdir src
196 WVPASS touch src/a
197 WVPASS touch src/b
198 WVPASS touch src/foo
199 WVPASS mkdir src/sub
200 WVPASS mkdir src/sub/foo
201 WVPASS touch src/sub/foo/a
202 WVPASS bup index -u src
203 WVPASS bup save --strip -n bupdir src
204 WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo/.' /bupdir/latest/
205 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
206 WVPASSEQ "$actual" ".
207 ./a
208 ./b
209 ./foo
210 ./sub
211 ./sub/foo"
212
213
214 # bup restore --exclude-rx-from ...
215 # =================================
216
217 WVSTART "restore --exclude-rx-from"
218 WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
219 WVPASS bup init
220 WVPASS mkdir src
221 WVPASS touch src/a
222 WVPASS touch src/b
223 WVPASS mkdir src/sub1
224 WVPASS mkdir src/sub2
225 WVPASS touch src/sub1/a
226 WVPASS touch src/sub2/b
227 WVPASS bup index -u src
228 WVPASS bup save --strip -n bupdir src
229 WVPASS echo "^/sub1/" > exclude-rx-file
230 WVPASS bup restore -C buprestore.tmp \
231     --exclude-rx-from exclude-rx-file /bupdir/latest/
232 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
233 WVPASSEQ "$actual" ".
234 ./a
235 ./b
236 ./sub2
237 ./sub2/b"
238
239 WVPASS rm -rf "$tmpdir"