Blame


1 2ec1f75b 2019-03-26 stsp #!/bin/sh
2 2ec1f75b 2019-03-26 stsp #
3 2ec1f75b 2019-03-26 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 2ec1f75b 2019-03-26 stsp #
5 2ec1f75b 2019-03-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 2ec1f75b 2019-03-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 2ec1f75b 2019-03-26 stsp # copyright notice and this permission notice appear in all copies.
8 2ec1f75b 2019-03-26 stsp #
9 2ec1f75b 2019-03-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 2ec1f75b 2019-03-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 2ec1f75b 2019-03-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 2ec1f75b 2019-03-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 2ec1f75b 2019-03-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 2ec1f75b 2019-03-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 2ec1f75b 2019-03-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 2ec1f75b 2019-03-26 stsp
17 2ec1f75b 2019-03-26 stsp . ./common.sh
18 2ec1f75b 2019-03-26 stsp
19 f6cae3ed 2020-09-13 naddy test_rm_basic() {
20 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_basic`
21 2ec1f75b 2019-03-26 stsp
22 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 2ec1f75b 2019-03-26 stsp ret="$?"
24 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
25 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
26 2ec1f75b 2019-03-26 stsp return 1
27 2ec1f75b 2019-03-26 stsp fi
28 2ec1f75b 2019-03-26 stsp
29 17ed4618 2019-06-02 stsp echo 'D alpha' > $testroot/stdout.expected
30 17ed4618 2019-06-02 stsp echo 'D beta' >> $testroot/stdout.expected
31 17ed4618 2019-06-02 stsp (cd $testroot/wt && got rm alpha beta > $testroot/stdout)
32 2ec1f75b 2019-03-26 stsp
33 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
34 2ec1f75b 2019-03-26 stsp ret="$?"
35 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
36 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
37 17ed4618 2019-06-02 stsp test_done "$testroot" "$ret"
38 17ed4618 2019-06-02 stsp return 1
39 2ec1f75b 2019-03-26 stsp fi
40 2ec1f75b 2019-03-26 stsp
41 17ed4618 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
42 17ed4618 2019-06-02 stsp
43 17ed4618 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
44 17ed4618 2019-06-02 stsp ret="$?"
45 17ed4618 2019-06-02 stsp if [ "$ret" != "0" ]; then
46 17ed4618 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
47 17ed4618 2019-06-02 stsp test_done "$testroot" "$ret"
48 2ec1f75b 2019-03-26 stsp return 1
49 2ec1f75b 2019-03-26 stsp fi
50 2ec1f75b 2019-03-26 stsp
51 17ed4618 2019-06-02 stsp for f in alpha beta; do
52 17ed4618 2019-06-02 stsp if [ -e $testroot/wt/$f ]; then
53 17ed4618 2019-06-02 stsp echo "removed file $f still exists on disk" >&2
54 17ed4618 2019-06-02 stsp test_done "$testroot" "1"
55 17ed4618 2019-06-02 stsp return 1
56 17ed4618 2019-06-02 stsp fi
57 17ed4618 2019-06-02 stsp done
58 17ed4618 2019-06-02 stsp
59 17ed4618 2019-06-02 stsp test_done "$testroot" "0"
60 2ec1f75b 2019-03-26 stsp }
61 2ec1f75b 2019-03-26 stsp
62 f6cae3ed 2020-09-13 naddy test_rm_with_local_mods() {
63 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_with_local_mods`
64 2ec1f75b 2019-03-26 stsp
65 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
66 2ec1f75b 2019-03-26 stsp ret="$?"
67 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
68 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
69 2ec1f75b 2019-03-26 stsp return 1
70 2ec1f75b 2019-03-26 stsp fi
71 2ec1f75b 2019-03-26 stsp
72 2ec1f75b 2019-03-26 stsp echo "modified beta" > $testroot/wt/beta
73 f0b0c0ce 2019-08-04 stsp echo 'got: beta: file contains modifications' \
74 f0b0c0ce 2019-08-04 stsp > $testroot/stderr.expected
75 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm beta 2>$testroot/stderr)
76 2ec1f75b 2019-03-26 stsp
77 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
78 2ec1f75b 2019-03-26 stsp ret="$?"
79 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
80 2ec1f75b 2019-03-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
81 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
82 2ec1f75b 2019-03-26 stsp return 1
83 2ec1f75b 2019-03-26 stsp fi
84 2ec1f75b 2019-03-26 stsp
85 2ec1f75b 2019-03-26 stsp echo 'D beta' > $testroot/stdout.expected
86 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm -f beta > $testroot/stdout)
87 2ec1f75b 2019-03-26 stsp
88 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
89 2ec1f75b 2019-03-26 stsp ret="$?"
90 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
91 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
92 2ec1f75b 2019-03-26 stsp fi
93 2ec1f75b 2019-03-26 stsp
94 2ec1f75b 2019-03-26 stsp if [ -e $testroot/wt/beta ]; then
95 2ec1f75b 2019-03-26 stsp echo "removed file beta still exists on disk" >&2
96 2ec1f75b 2019-03-26 stsp test_done "$testroot" "1"
97 2ec1f75b 2019-03-26 stsp return 1
98 2ec1f75b 2019-03-26 stsp fi
99 2ec1f75b 2019-03-26 stsp
100 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
101 2ec1f75b 2019-03-26 stsp }
102 2ec1f75b 2019-03-26 stsp
103 f6cae3ed 2020-09-13 naddy test_double_rm() {
104 71a29355 2019-03-27 stsp local testroot=`test_init double_rm`
105 71a29355 2019-03-27 stsp
106 71a29355 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
107 71a29355 2019-03-27 stsp ret="$?"
108 71a29355 2019-03-27 stsp if [ "$ret" != "0" ]; then
109 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
110 71a29355 2019-03-27 stsp return 1
111 71a29355 2019-03-27 stsp fi
112 71a29355 2019-03-27 stsp
113 71a29355 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
114 71a29355 2019-03-27 stsp
115 71a29355 2019-03-27 stsp for fflag in "" "-f"; do
116 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
117 6d022e97 2019-08-04 stsp (cd $testroot/wt && got rm $fflag beta > $testroot/stdout \
118 6d022e97 2019-08-04 stsp 2> $testroot/stderr)
119 71a29355 2019-03-27 stsp ret="$?"
120 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
121 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
122 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
123 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
124 6d022e97 2019-08-04 stsp return 1
125 71a29355 2019-03-27 stsp fi
126 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
127 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
128 71a29355 2019-03-27 stsp ret="$?"
129 71a29355 2019-03-27 stsp if [ "$ret" != "0" ]; then
130 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
131 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
132 6d022e97 2019-08-04 stsp return 1
133 71a29355 2019-03-27 stsp fi
134 71a29355 2019-03-27 stsp done
135 71a29355 2019-03-27 stsp test_done "$testroot" "0"
136 71a29355 2019-03-27 stsp }
137 71a29355 2019-03-27 stsp
138 f6cae3ed 2020-09-13 naddy test_rm_and_add_elsewhere() {
139 f0b0c0ce 2019-08-04 stsp local testroot=`test_init rm_and_add_elsewhere`
140 f0b0c0ce 2019-08-04 stsp
141 f0b0c0ce 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
142 f0b0c0ce 2019-08-04 stsp ret="$?"
143 f0b0c0ce 2019-08-04 stsp if [ "$ret" != "0" ]; then
144 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
145 f0b0c0ce 2019-08-04 stsp return 1
146 f0b0c0ce 2019-08-04 stsp fi
147 f0b0c0ce 2019-08-04 stsp
148 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && mv alpha epsilon/)
149 f0b0c0ce 2019-08-04 stsp
150 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
151 f0b0c0ce 2019-08-04 stsp
152 f0b0c0ce 2019-08-04 stsp echo '! alpha' > $testroot/stdout.expected
153 f0b0c0ce 2019-08-04 stsp echo '? epsilon/alpha' >> $testroot/stdout.expected
154 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
155 f0b0c0ce 2019-08-04 stsp ret="$?"
156 f0b0c0ce 2019-08-04 stsp if [ "$ret" != "0" ]; then
157 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
158 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
159 f0b0c0ce 2019-08-04 stsp return 1
160 f0b0c0ce 2019-08-04 stsp fi
161 f0b0c0ce 2019-08-04 stsp
162 f0b0c0ce 2019-08-04 stsp echo 'D alpha' > $testroot/stdout.expected
163 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got rm alpha > $testroot/stdout)
164 f0b0c0ce 2019-08-04 stsp
165 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
166 f0b0c0ce 2019-08-04 stsp ret="$?"
167 f0b0c0ce 2019-08-04 stsp if [ "$ret" != "0" ]; then
168 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
169 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
170 f0b0c0ce 2019-08-04 stsp return 1
171 f0b0c0ce 2019-08-04 stsp fi
172 f0b0c0ce 2019-08-04 stsp
173 f0b0c0ce 2019-08-04 stsp echo 'A epsilon/alpha' > $testroot/stdout.expected
174 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got add epsilon/alpha > $testroot/stdout)
175 f0b0c0ce 2019-08-04 stsp
176 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
177 f0b0c0ce 2019-08-04 stsp ret="$?"
178 f0b0c0ce 2019-08-04 stsp if [ "$ret" != "0" ]; then
179 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
180 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
181 f0b0c0ce 2019-08-04 stsp return 1
182 f0b0c0ce 2019-08-04 stsp fi
183 f0b0c0ce 2019-08-04 stsp
184 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
185 f0b0c0ce 2019-08-04 stsp
186 f0b0c0ce 2019-08-04 stsp echo 'D alpha' > $testroot/stdout.expected
187 f0b0c0ce 2019-08-04 stsp echo 'A epsilon/alpha' >> $testroot/stdout.expected
188 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
189 f0b0c0ce 2019-08-04 stsp ret="$?"
190 f0b0c0ce 2019-08-04 stsp if [ "$ret" != "0" ]; then
191 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
192 f0b0c0ce 2019-08-04 stsp fi
193 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
194 f0b0c0ce 2019-08-04 stsp }
195 f0b0c0ce 2019-08-04 stsp
196 f6cae3ed 2020-09-13 naddy test_rm_directory() {
197 f2a9dc41 2019-12-13 tracey local testroot=`test_init rm_directory`
198 f2a9dc41 2019-12-13 tracey
199 f2a9dc41 2019-12-13 tracey got checkout $testroot/repo $testroot/wt > /dev/null
200 f2a9dc41 2019-12-13 tracey ret="$?"
201 f2a9dc41 2019-12-13 tracey if [ "$ret" != "0" ]; then
202 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
203 f2a9dc41 2019-12-13 tracey return 1
204 f2a9dc41 2019-12-13 tracey fi
205 f2a9dc41 2019-12-13 tracey
206 f2a9dc41 2019-12-13 tracey (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
207 f2a9dc41 2019-12-13 tracey ret="$?"
208 f2a9dc41 2019-12-13 tracey echo "got: removing directories requires -R option" \
209 f2a9dc41 2019-12-13 tracey > $testroot/stderr.expected
210 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stderr.expected $testroot/stderr
211 f2a9dc41 2019-12-13 tracey ret="$?"
212 f2a9dc41 2019-12-13 tracey if [ "$ret" != "0" ]; then
213 f2a9dc41 2019-12-13 tracey diff -u $testroot/stderr.expected $testroot/stderr
214 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
215 f2a9dc41 2019-12-13 tracey return 1
216 f2a9dc41 2019-12-13 tracey fi
217 f2a9dc41 2019-12-13 tracey
218 f2a9dc41 2019-12-13 tracey echo -n > $testroot/stdout.expected
219 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
220 f2a9dc41 2019-12-13 tracey ret="$?"
221 f2a9dc41 2019-12-13 tracey if [ "$ret" != "0" ]; then
222 f2a9dc41 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
223 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
224 f2a9dc41 2019-12-13 tracey return 1
225 f2a9dc41 2019-12-13 tracey fi
226 f2a9dc41 2019-12-13 tracey
227 f2a9dc41 2019-12-13 tracey (cd $testroot/wt && got rm -R . > $testroot/stdout)
228 f2a9dc41 2019-12-13 tracey
229 f2a9dc41 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
230 f2a9dc41 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
231 f2a9dc41 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
232 f2a9dc41 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
233 f2a9dc41 2019-12-13 tracey
234 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
235 f2a9dc41 2019-12-13 tracey ret="$?"
236 f2a9dc41 2019-12-13 tracey if [ "$ret" != "0" ]; then
237 f2a9dc41 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
238 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
239 f2a9dc41 2019-12-13 tracey return 1
240 f2a9dc41 2019-12-13 tracey fi
241 f2a9dc41 2019-12-13 tracey
242 6b36edd8 2020-10-03 naddy (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
243 15341bfd 2020-03-05 tracey
244 15341bfd 2020-03-05 tracey echo -n '' > $testroot/stdout.expected
245 15341bfd 2020-03-05 tracey
246 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
247 15341bfd 2020-03-05 tracey ret="$?"
248 15341bfd 2020-03-05 tracey if [ "$ret" != "0" ]; then
249 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
250 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
251 15341bfd 2020-03-05 tracey return 1
252 15341bfd 2020-03-05 tracey fi
253 15341bfd 2020-03-05 tracey
254 6b36edd8 2020-10-03 naddy (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
255 15341bfd 2020-03-05 tracey
256 15341bfd 2020-03-05 tracey echo -n '' > $testroot/stdout.expected
257 15341bfd 2020-03-05 tracey
258 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
259 15341bfd 2020-03-05 tracey ret="$?"
260 15341bfd 2020-03-05 tracey if [ "$ret" != "0" ]; then
261 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
262 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
263 15341bfd 2020-03-05 tracey return 1
264 15341bfd 2020-03-05 tracey fi
265 15341bfd 2020-03-05 tracey
266 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
267 f2a9dc41 2019-12-13 tracey }
268 70e3e7f5 2019-12-13 tracey
269 f6cae3ed 2020-09-13 naddy test_rm_directory_keep_files() {
270 9c2e8939 2020-03-22 stsp local testroot=`test_init rm_directory_keep_files`
271 70e3e7f5 2019-12-13 tracey
272 70e3e7f5 2019-12-13 tracey got checkout $testroot/repo $testroot/wt > /dev/null
273 70e3e7f5 2019-12-13 tracey ret="$?"
274 70e3e7f5 2019-12-13 tracey if [ "$ret" != "0" ]; then
275 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
276 70e3e7f5 2019-12-13 tracey return 1
277 70e3e7f5 2019-12-13 tracey fi
278 70e3e7f5 2019-12-13 tracey
279 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
280 70e3e7f5 2019-12-13 tracey ret="$?"
281 70e3e7f5 2019-12-13 tracey echo "got: removing directories requires -R option" \
282 70e3e7f5 2019-12-13 tracey > $testroot/stderr.expected
283 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stderr.expected $testroot/stderr
284 70e3e7f5 2019-12-13 tracey ret="$?"
285 70e3e7f5 2019-12-13 tracey if [ "$ret" != "0" ]; then
286 70e3e7f5 2019-12-13 tracey diff -u $testroot/stderr.expected $testroot/stderr
287 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
288 70e3e7f5 2019-12-13 tracey return 1
289 70e3e7f5 2019-12-13 tracey fi
290 f2a9dc41 2019-12-13 tracey
291 70e3e7f5 2019-12-13 tracey echo -n > $testroot/stdout.expected
292 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
293 70e3e7f5 2019-12-13 tracey ret="$?"
294 70e3e7f5 2019-12-13 tracey if [ "$ret" != "0" ]; then
295 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
296 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
297 70e3e7f5 2019-12-13 tracey return 1
298 70e3e7f5 2019-12-13 tracey fi
299 70e3e7f5 2019-12-13 tracey
300 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got rm -k -R . > $testroot/stdout)
301 70e3e7f5 2019-12-13 tracey
302 70e3e7f5 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
303 70e3e7f5 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
304 70e3e7f5 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
305 70e3e7f5 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
306 70e3e7f5 2019-12-13 tracey
307 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
308 70e3e7f5 2019-12-13 tracey ret="$?"
309 70e3e7f5 2019-12-13 tracey if [ "$ret" != "0" ]; then
310 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
311 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
312 70e3e7f5 2019-12-13 tracey return 1
313 70e3e7f5 2019-12-13 tracey fi
314 70e3e7f5 2019-12-13 tracey
315 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got st . > $testroot/stdout)
316 70e3e7f5 2019-12-13 tracey
317 70e3e7f5 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
318 70e3e7f5 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
319 70e3e7f5 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
320 70e3e7f5 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
321 70e3e7f5 2019-12-13 tracey
322 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
323 70e3e7f5 2019-12-13 tracey ret="$?"
324 70e3e7f5 2019-12-13 tracey if [ "$ret" != "0" ]; then
325 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
326 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
327 70e3e7f5 2019-12-13 tracey return 1
328 70e3e7f5 2019-12-13 tracey fi
329 70e3e7f5 2019-12-13 tracey
330 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got commit -m "keep" > /dev/null)
331 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got st . > $testroot/stdout)
332 70e3e7f5 2019-12-13 tracey
333 70e3e7f5 2019-12-13 tracey echo '? alpha' > $testroot/stdout.expected
334 70e3e7f5 2019-12-13 tracey echo '? beta' >> $testroot/stdout.expected
335 70e3e7f5 2019-12-13 tracey echo '? epsilon/zeta' >> $testroot/stdout.expected
336 70e3e7f5 2019-12-13 tracey echo '? gamma/delta' >> $testroot/stdout.expected
337 70e3e7f5 2019-12-13 tracey
338 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
339 70e3e7f5 2019-12-13 tracey ret="$?"
340 70e3e7f5 2019-12-13 tracey if [ "$ret" != "0" ]; then
341 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
342 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
343 70e3e7f5 2019-12-13 tracey return 1
344 70e3e7f5 2019-12-13 tracey fi
345 70e3e7f5 2019-12-13 tracey
346 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
347 70e3e7f5 2019-12-13 tracey }
348 70e3e7f5 2019-12-13 tracey
349 f6cae3ed 2020-09-13 naddy test_rm_subtree() {
350 15341bfd 2020-03-05 tracey local testroot=`test_init rm_subtree`
351 15341bfd 2020-03-05 tracey
352 15341bfd 2020-03-05 tracey got checkout $testroot/repo $testroot/wt > /dev/null
353 15341bfd 2020-03-05 tracey ret="$?"
354 15341bfd 2020-03-05 tracey if [ "$ret" != "0" ]; then
355 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
356 15341bfd 2020-03-05 tracey return 1
357 15341bfd 2020-03-05 tracey fi
358 15341bfd 2020-03-05 tracey
359 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/baz
360 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/bax
361 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
362 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
363 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
364 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
365 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
366 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
367 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
368 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
369 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
370 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
371 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
372 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
373 15341bfd 2020-03-05 tracey (cd $testroot/wt && got add -R epsilon >/dev/null)
374 15341bfd 2020-03-05 tracey (cd $testroot/wt && got commit -m "add subtree" >/dev/null)
375 15341bfd 2020-03-05 tracey
376 15341bfd 2020-03-05 tracey # now delete and revert the entire subtree
377 15341bfd 2020-03-05 tracey (cd $testroot/wt && got rm -R epsilon/foo >/dev/null)
378 15341bfd 2020-03-05 tracey
379 15341bfd 2020-03-05 tracey if [ -d $testroot/wt/epsilon/foo ]; then
380 15341bfd 2020-03-05 tracey echo "removed dir epsilon/foo still exists on disk" >&2
381 15341bfd 2020-03-05 tracey test_done "$testroot" "1"
382 15341bfd 2020-03-05 tracey return 1
383 15341bfd 2020-03-05 tracey fi
384 15341bfd 2020-03-05 tracey
385 15341bfd 2020-03-05 tracey echo "D epsilon/foo/a.o" > $testroot/stdout.expected
386 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/b.d" >> $testroot/stdout.expected
387 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/b.o" >> $testroot/stdout.expected
388 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
389 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
390 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
391 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
392 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
393 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
394 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
395 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
396 15341bfd 2020-03-05 tracey
397 15341bfd 2020-03-05 tracey (cd $testroot/wt && got status > $testroot/stdout)
398 a919d5c4 2020-07-23 stsp
399 a919d5c4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
400 a919d5c4 2020-07-23 stsp ret="$?"
401 a919d5c4 2020-07-23 stsp if [ "$ret" != "0" ]; then
402 a919d5c4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
403 a919d5c4 2020-07-23 stsp fi
404 a919d5c4 2020-07-23 stsp test_done "$testroot" "$ret"
405 a919d5c4 2020-07-23 stsp }
406 a919d5c4 2020-07-23 stsp
407 f6cae3ed 2020-09-13 naddy test_rm_symlink() {
408 a919d5c4 2020-07-23 stsp local testroot=`test_init rm_symlink`
409 a919d5c4 2020-07-23 stsp
410 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
411 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
412 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
413 64773fde 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
414 64773fde 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
415 a919d5c4 2020-07-23 stsp (cd $testroot/repo && git add .)
416 64773fde 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
417 a919d5c4 2020-07-23 stsp
418 a919d5c4 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
419 a919d5c4 2020-07-23 stsp ret="$?"
420 a919d5c4 2020-07-23 stsp if [ "$ret" != "0" ]; then
421 a919d5c4 2020-07-23 stsp test_done "$testroot" "$ret"
422 a919d5c4 2020-07-23 stsp return 1
423 a919d5c4 2020-07-23 stsp fi
424 15341bfd 2020-03-05 tracey
425 a919d5c4 2020-07-23 stsp echo 'D alpha.link' > $testroot/stdout.expected
426 64773fde 2020-07-23 stsp echo 'D epsilon/beta.link' >> $testroot/stdout.expected
427 f1417e9f 2021-10-12 thomas echo 'D epsilon.link' >> $testroot/stdout.expected
428 64773fde 2020-07-23 stsp echo 'D nonexistent.link' >> $testroot/stdout.expected
429 f1417e9f 2021-10-12 thomas echo 'D passwd.link' >> $testroot/stdout.expected
430 64773fde 2020-07-23 stsp (cd $testroot/wt && got rm alpha.link epsilon.link passwd.link \
431 64773fde 2020-07-23 stsp epsilon/beta.link nonexistent.link > $testroot/stdout)
432 766841c2 2020-08-13 stsp
433 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
434 766841c2 2020-08-13 stsp ret="$?"
435 766841c2 2020-08-13 stsp if [ "$ret" != "0" ]; then
436 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
437 766841c2 2020-08-13 stsp fi
438 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
439 766841c2 2020-08-13 stsp }
440 766841c2 2020-08-13 stsp
441 f6cae3ed 2020-09-13 naddy test_rm_status_code() {
442 766841c2 2020-08-13 stsp local testroot=`test_init rm_status_code`
443 766841c2 2020-08-13 stsp
444 766841c2 2020-08-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
445 766841c2 2020-08-13 stsp ret="$?"
446 766841c2 2020-08-13 stsp if [ "$ret" != "0" ]; then
447 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
448 766841c2 2020-08-13 stsp return 1
449 766841c2 2020-08-13 stsp fi
450 766841c2 2020-08-13 stsp
451 766841c2 2020-08-13 stsp echo "modified beta" > $testroot/wt/beta
452 766841c2 2020-08-13 stsp
453 766841c2 2020-08-13 stsp echo "got: invalid status code 'x'" > $testroot/stderr.expected
454 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -s Mx beta 2>$testroot/stderr)
455 766841c2 2020-08-13 stsp
456 766841c2 2020-08-13 stsp cmp -s $testroot/stderr.expected $testroot/stderr
457 766841c2 2020-08-13 stsp ret="$?"
458 766841c2 2020-08-13 stsp if [ "$ret" != "0" ]; then
459 766841c2 2020-08-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
460 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
461 766841c2 2020-08-13 stsp return 1
462 766841c2 2020-08-13 stsp fi
463 766841c2 2020-08-13 stsp
464 766841c2 2020-08-13 stsp rm $testroot/wt/epsilon/zeta # put file into 'missing' status
465 766841c2 2020-08-13 stsp
466 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' > $testroot/stdout.expected
467 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -R -s '!' . >$testroot/stdout)
468 766841c2 2020-08-13 stsp
469 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
470 766841c2 2020-08-13 stsp ret="$?"
471 766841c2 2020-08-13 stsp if [ "$ret" != "0" ]; then
472 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
473 766841c2 2020-08-13 stsp fi
474 a919d5c4 2020-07-23 stsp
475 766841c2 2020-08-13 stsp if [ ! -e $testroot/wt/beta ]; then
476 766841c2 2020-08-13 stsp echo "file beta was unexpectedly removed from disk" >&2
477 766841c2 2020-08-13 stsp test_done "$testroot" "1"
478 766841c2 2020-08-13 stsp return 1
479 766841c2 2020-08-13 stsp fi
480 766841c2 2020-08-13 stsp
481 766841c2 2020-08-13 stsp # put file into 'missing' status again
482 766841c2 2020-08-13 stsp (cd $testroot/wt && got revert epsilon/zeta > /dev/null)
483 766841c2 2020-08-13 stsp rm $testroot/wt/epsilon/zeta
484 766841c2 2020-08-13 stsp
485 766841c2 2020-08-13 stsp echo 'D beta' > $testroot/stdout.expected
486 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
487 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -R -s 'M!' . >$testroot/stdout)
488 766841c2 2020-08-13 stsp
489 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
490 15341bfd 2020-03-05 tracey ret="$?"
491 15341bfd 2020-03-05 tracey if [ "$ret" != "0" ]; then
492 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
493 766841c2 2020-08-13 stsp test_done "$testroot" "1"
494 766841c2 2020-08-13 stsp return 1
495 15341bfd 2020-03-05 tracey fi
496 766841c2 2020-08-13 stsp
497 766841c2 2020-08-13 stsp if [ -e $testroot/wt/beta ]; then
498 766841c2 2020-08-13 stsp echo "removed file beta still exists on disk" >&2
499 766841c2 2020-08-13 stsp test_done "$testroot" "1"
500 766841c2 2020-08-13 stsp return 1
501 766841c2 2020-08-13 stsp fi
502 766841c2 2020-08-13 stsp
503 766841c2 2020-08-13 stsp echo 'D beta' > $testroot/stdout.expected
504 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
505 766841c2 2020-08-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
506 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
507 766841c2 2020-08-13 stsp ret="$?"
508 766841c2 2020-08-13 stsp if [ "$ret" != "0" ]; then
509 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
510 766841c2 2020-08-13 stsp test_done "$testroot" "1"
511 766841c2 2020-08-13 stsp return 1
512 766841c2 2020-08-13 stsp fi
513 766841c2 2020-08-13 stsp
514 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
515 15341bfd 2020-03-05 tracey }
516 15341bfd 2020-03-05 tracey
517 766841c2 2020-08-13 stsp
518 7fb414ae 2020-08-08 stsp test_parseargs "$@"
519 2ec1f75b 2019-03-26 stsp run_test test_rm_basic
520 2ec1f75b 2019-03-26 stsp run_test test_rm_with_local_mods
521 71a29355 2019-03-27 stsp run_test test_double_rm
522 f0b0c0ce 2019-08-04 stsp run_test test_rm_and_add_elsewhere
523 f2a9dc41 2019-12-13 tracey run_test test_rm_directory
524 70e3e7f5 2019-12-13 tracey run_test test_rm_directory_keep_files
525 15341bfd 2020-03-05 tracey run_test test_rm_subtree
526 a919d5c4 2020-07-23 stsp run_test test_rm_symlink
527 766841c2 2020-08-13 stsp run_test test_rm_status_code