3 2ec1f75b 2019-03-26 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 2ec1f75b 2019-03-26 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_rm_basic() {
20 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_basic`
22 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
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)
33 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
35 49c543a6 2022-03-31 naddy if [ $ret -ne 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"
41 17ed4618 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
43 17ed4618 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
45 49c543a6 2022-03-31 naddy if [ $ret -ne 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"
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"
59 17ed4618 2019-06-02 stsp test_done "$testroot" "0"
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`
65 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
67 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
68 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
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)
77 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
79 49c543a6 2022-03-31 naddy if [ $ret -ne 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"
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)
88 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
90 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
91 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
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"
100 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
103 f6cae3ed 2020-09-13 naddy test_double_rm() {
104 71a29355 2019-03-27 stsp local testroot=`test_init double_rm`
106 71a29355 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
108 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
109 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
113 71a29355 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
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)
120 49c543a6 2022-03-31 naddy if [ $ret -ne 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"
126 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
127 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
129 49c543a6 2022-03-31 naddy if [ $ret -ne 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"
135 71a29355 2019-03-27 stsp test_done "$testroot" "0"
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`
141 f0b0c0ce 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
144 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
148 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && mv alpha epsilon/)
150 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
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
156 49c543a6 2022-03-31 naddy if [ $ret -ne 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"
162 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm alpha > $testroot/stdout 2> $testroot/stderr)
164 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
165 4e12cd97 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
166 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
167 4e12cd97 2022-01-25 stsp test_done "$testroot" "1"
171 4e12cd97 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
172 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
175 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
176 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
180 4e12cd97 2022-01-25 stsp echo "got: alpha: No such file or directory" \
181 4e12cd97 2022-01-25 stsp > $testroot/stderr.expected
182 4e12cd97 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
184 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
185 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
186 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
190 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm -f alpha > $testroot/stdout)
192 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
193 4e12cd97 2022-01-25 stsp echo "got rm command failed unexpectedly" >&2
194 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
199 f0b0c0ce 2019-08-04 stsp echo 'D alpha' > $testroot/stdout.expected
200 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
203 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
204 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
208 692bdcc4 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
211 692bdcc4 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
216 692bdcc4 2022-01-25 stsp # While here, test behaviour of rm on files in unversioned status.
217 692bdcc4 2022-01-25 stsp (cd $testroot/wt && got rm epsilon/alpha > $testroot/stdout \
218 692bdcc4 2022-01-25 stsp 2> $testroot/stderr)
220 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
221 692bdcc4 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
222 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
223 692bdcc4 2022-01-25 stsp test_done "$testroot" "1"
227 692bdcc4 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
228 692bdcc4 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
230 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
231 692bdcc4 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
232 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
236 692bdcc4 2022-01-25 stsp echo "got: epsilon/alpha: file has unexpected status" \
237 692bdcc4 2022-01-25 stsp > $testroot/stderr.expected
238 692bdcc4 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
240 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
241 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
242 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
246 692bdcc4 2022-01-25 stsp # And test the same case with -f.
247 692bdcc4 2022-01-25 stsp (cd $testroot/wt && got rm -f epsilon/alpha > $testroot/stdout \
248 692bdcc4 2022-01-25 stsp 2> $testroot/stderr)
250 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
251 692bdcc4 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
252 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
253 692bdcc4 2022-01-25 stsp test_done "$testroot" "1"
257 692bdcc4 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
258 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
260 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
261 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
266 692bdcc4 2022-01-25 stsp echo "got: epsilon/alpha: file has unexpected status" \
267 692bdcc4 2022-01-25 stsp > $testroot/stderr.expected
268 692bdcc4 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
271 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
272 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
276 f0b0c0ce 2019-08-04 stsp echo 'A epsilon/alpha' > $testroot/stdout.expected
277 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got add epsilon/alpha > $testroot/stdout)
279 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
281 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
282 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
283 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
287 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
289 f0b0c0ce 2019-08-04 stsp echo 'D alpha' > $testroot/stdout.expected
290 f0b0c0ce 2019-08-04 stsp echo 'A epsilon/alpha' >> $testroot/stdout.expected
291 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
293 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
294 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
296 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
299 f6cae3ed 2020-09-13 naddy test_rm_directory() {
300 f2a9dc41 2019-12-13 tracey local testroot=`test_init rm_directory`
302 f2a9dc41 2019-12-13 tracey got checkout $testroot/repo $testroot/wt > /dev/null
304 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
305 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
309 f2a9dc41 2019-12-13 tracey (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
311 f2a9dc41 2019-12-13 tracey echo "got: removing directories requires -R option" \
312 f2a9dc41 2019-12-13 tracey > $testroot/stderr.expected
313 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stderr.expected $testroot/stderr
315 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
316 f2a9dc41 2019-12-13 tracey diff -u $testroot/stderr.expected $testroot/stderr
317 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
321 f2a9dc41 2019-12-13 tracey echo -n > $testroot/stdout.expected
322 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
324 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
325 f2a9dc41 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
326 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
330 f2a9dc41 2019-12-13 tracey (cd $testroot/wt && got rm -R . > $testroot/stdout)
332 f2a9dc41 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
333 f2a9dc41 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
334 f2a9dc41 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
335 f2a9dc41 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
337 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
339 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
340 f2a9dc41 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
341 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
345 6b36edd8 2020-10-03 naddy (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
347 15341bfd 2020-03-05 tracey echo -n '' > $testroot/stdout.expected
349 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
351 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
352 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
353 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
357 6b36edd8 2020-10-03 naddy (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
359 15341bfd 2020-03-05 tracey echo -n '' > $testroot/stdout.expected
361 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
363 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
364 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
365 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
369 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
372 f6cae3ed 2020-09-13 naddy test_rm_directory_keep_files() {
373 9c2e8939 2020-03-22 stsp local testroot=`test_init rm_directory_keep_files`
375 70e3e7f5 2019-12-13 tracey got checkout $testroot/repo $testroot/wt > /dev/null
377 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
378 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
382 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
384 70e3e7f5 2019-12-13 tracey echo "got: removing directories requires -R option" \
385 70e3e7f5 2019-12-13 tracey > $testroot/stderr.expected
386 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stderr.expected $testroot/stderr
388 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
389 70e3e7f5 2019-12-13 tracey diff -u $testroot/stderr.expected $testroot/stderr
390 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
394 70e3e7f5 2019-12-13 tracey echo -n > $testroot/stdout.expected
395 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
397 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
398 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
399 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
403 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got rm -k -R . > $testroot/stdout)
405 70e3e7f5 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
406 70e3e7f5 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
407 70e3e7f5 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
408 70e3e7f5 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
410 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
412 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
413 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
414 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
418 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got st . > $testroot/stdout)
420 70e3e7f5 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
421 70e3e7f5 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
422 70e3e7f5 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
423 70e3e7f5 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
425 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
427 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
428 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
429 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
433 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got commit -m "keep" > /dev/null)
434 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got st . > $testroot/stdout)
436 70e3e7f5 2019-12-13 tracey echo '? alpha' > $testroot/stdout.expected
437 70e3e7f5 2019-12-13 tracey echo '? beta' >> $testroot/stdout.expected
438 70e3e7f5 2019-12-13 tracey echo '? epsilon/zeta' >> $testroot/stdout.expected
439 70e3e7f5 2019-12-13 tracey echo '? gamma/delta' >> $testroot/stdout.expected
441 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
443 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
444 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
445 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
449 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
452 f6cae3ed 2020-09-13 naddy test_rm_subtree() {
453 15341bfd 2020-03-05 tracey local testroot=`test_init rm_subtree`
455 15341bfd 2020-03-05 tracey got checkout $testroot/repo $testroot/wt > /dev/null
457 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
458 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
462 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/baz
463 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/bax
464 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
465 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
466 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
467 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
468 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
469 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
470 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
471 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
472 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
473 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
474 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
475 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
476 15341bfd 2020-03-05 tracey (cd $testroot/wt && got add -R epsilon >/dev/null)
477 15341bfd 2020-03-05 tracey (cd $testroot/wt && got commit -m "add subtree" >/dev/null)
479 15341bfd 2020-03-05 tracey # now delete and revert the entire subtree
480 15341bfd 2020-03-05 tracey (cd $testroot/wt && got rm -R epsilon/foo >/dev/null)
482 15341bfd 2020-03-05 tracey if [ -d $testroot/wt/epsilon/foo ]; then
483 15341bfd 2020-03-05 tracey echo "removed dir epsilon/foo still exists on disk" >&2
484 15341bfd 2020-03-05 tracey test_done "$testroot" "1"
488 15341bfd 2020-03-05 tracey echo "D epsilon/foo/a.o" > $testroot/stdout.expected
489 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/b.d" >> $testroot/stdout.expected
490 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/b.o" >> $testroot/stdout.expected
491 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
492 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
493 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
494 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
495 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
496 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
497 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
498 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
500 15341bfd 2020-03-05 tracey (cd $testroot/wt && got status > $testroot/stdout)
502 a919d5c4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
504 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
505 a919d5c4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
507 a919d5c4 2020-07-23 stsp test_done "$testroot" "$ret"
510 f6cae3ed 2020-09-13 naddy test_rm_symlink() {
511 a919d5c4 2020-07-23 stsp local testroot=`test_init rm_symlink`
513 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
514 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
515 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
516 64773fde 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
517 64773fde 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
518 a919d5c4 2020-07-23 stsp (cd $testroot/repo && git add .)
519 64773fde 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
521 a919d5c4 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
523 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
524 a919d5c4 2020-07-23 stsp test_done "$testroot" "$ret"
528 a919d5c4 2020-07-23 stsp echo 'D alpha.link' > $testroot/stdout.expected
529 64773fde 2020-07-23 stsp echo 'D epsilon/beta.link' >> $testroot/stdout.expected
530 10a623df 2021-10-11 stsp echo 'D epsilon.link' >> $testroot/stdout.expected
531 64773fde 2020-07-23 stsp echo 'D nonexistent.link' >> $testroot/stdout.expected
532 10a623df 2021-10-11 stsp echo 'D passwd.link' >> $testroot/stdout.expected
533 64773fde 2020-07-23 stsp (cd $testroot/wt && got rm alpha.link epsilon.link passwd.link \
534 64773fde 2020-07-23 stsp epsilon/beta.link nonexistent.link > $testroot/stdout)
536 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
538 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
539 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
541 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
544 f6cae3ed 2020-09-13 naddy test_rm_status_code() {
545 766841c2 2020-08-13 stsp local testroot=`test_init rm_status_code`
547 766841c2 2020-08-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
549 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
550 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
554 766841c2 2020-08-13 stsp echo "modified beta" > $testroot/wt/beta
556 766841c2 2020-08-13 stsp echo "got: invalid status code 'x'" > $testroot/stderr.expected
557 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -s Mx beta 2>$testroot/stderr)
559 766841c2 2020-08-13 stsp cmp -s $testroot/stderr.expected $testroot/stderr
561 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
562 766841c2 2020-08-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
563 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
567 766841c2 2020-08-13 stsp rm $testroot/wt/epsilon/zeta # put file into 'missing' status
569 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' > $testroot/stdout.expected
570 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -R -s '!' . >$testroot/stdout)
572 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
574 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
575 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
578 766841c2 2020-08-13 stsp if [ ! -e $testroot/wt/beta ]; then
579 766841c2 2020-08-13 stsp echo "file beta was unexpectedly removed from disk" >&2
580 766841c2 2020-08-13 stsp test_done "$testroot" "1"
584 766841c2 2020-08-13 stsp # put file into 'missing' status again
585 766841c2 2020-08-13 stsp (cd $testroot/wt && got revert epsilon/zeta > /dev/null)
586 766841c2 2020-08-13 stsp rm $testroot/wt/epsilon/zeta
588 766841c2 2020-08-13 stsp echo 'D beta' > $testroot/stdout.expected
589 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
590 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -R -s 'M!' . >$testroot/stdout)
592 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
594 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
595 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
596 766841c2 2020-08-13 stsp test_done "$testroot" "1"
600 766841c2 2020-08-13 stsp if [ -e $testroot/wt/beta ]; then
601 766841c2 2020-08-13 stsp echo "removed file beta still exists on disk" >&2
602 766841c2 2020-08-13 stsp test_done "$testroot" "1"
606 766841c2 2020-08-13 stsp echo 'D beta' > $testroot/stdout.expected
607 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
608 766841c2 2020-08-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
609 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
611 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
612 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
613 4e12cd97 2022-01-25 stsp test_done "$testroot" "1"
617 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
620 4e12cd97 2022-01-25 stsp test_rm_nonexistent_directory() {
621 4e12cd97 2022-01-25 stsp local testroot=`test_init rm_nonexistent_directory`
623 4e12cd97 2022-01-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
625 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
626 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
630 4e12cd97 2022-01-25 stsp rm -r $testroot/wt/epsilon
632 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm epsilon > $testroot/stdout \
633 4e12cd97 2022-01-25 stsp 2> $testroot/stderr)
635 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
636 4e12cd97 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
637 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
638 766841c2 2020-08-13 stsp test_done "$testroot" "1"
642 4e12cd97 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
643 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
645 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
646 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
647 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
651 4e12cd97 2022-01-25 stsp echo "got: epsilon: No such file or directory" \
652 4e12cd97 2022-01-25 stsp > $testroot/stderr.expected
653 4e12cd97 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
655 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
656 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
657 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
661 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm -f epsilon > $testroot/stdout \
662 4e12cd97 2022-01-25 stsp 2> $testroot/stderr)
664 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
665 4e12cd97 2022-01-25 stsp echo "got rm command failed unexpectedly" >&2
666 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
667 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
671 4e12cd97 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
672 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
674 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
675 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
676 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
680 4e12cd97 2022-01-25 stsp echo -n '' > $testroot/stderr.expected
681 4e12cd97 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
683 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
684 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
685 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
689 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
693 7fb414ae 2020-08-08 stsp test_parseargs "$@"
694 2ec1f75b 2019-03-26 stsp run_test test_rm_basic
695 2ec1f75b 2019-03-26 stsp run_test test_rm_with_local_mods
696 71a29355 2019-03-27 stsp run_test test_double_rm
697 f0b0c0ce 2019-08-04 stsp run_test test_rm_and_add_elsewhere
698 f2a9dc41 2019-12-13 tracey run_test test_rm_directory
699 70e3e7f5 2019-12-13 tracey run_test test_rm_directory_keep_files
700 15341bfd 2020-03-05 tracey run_test test_rm_subtree
701 a919d5c4 2020-07-23 stsp run_test test_rm_symlink
702 766841c2 2020-08-13 stsp run_test test_rm_status_code
703 4e12cd97 2022-01-25 stsp run_test test_rm_nonexistent_directory