Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 test_rm_basic() {
20 local testroot=`test_init rm_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret=$?
24 if [ $ret -ne 0 ]; then
25 test_done "$testroot" "$ret"
26 return 1
27 fi
29 echo 'D alpha' > $testroot/stdout.expected
30 echo 'D beta' >> $testroot/stdout.expected
31 (cd $testroot/wt && got rm alpha beta > $testroot/stdout)
33 cmp -s $testroot/stdout.expected $testroot/stdout
34 ret=$?
35 if [ $ret -ne 0 ]; then
36 diff -u $testroot/stdout.expected $testroot/stdout
37 test_done "$testroot" "$ret"
38 return 1
39 fi
41 (cd $testroot/wt && got status > $testroot/stdout)
43 cmp -s $testroot/stdout.expected $testroot/stdout
44 ret=$?
45 if [ $ret -ne 0 ]; then
46 diff -u $testroot/stdout.expected $testroot/stdout
47 test_done "$testroot" "$ret"
48 return 1
49 fi
51 for f in alpha beta; do
52 if [ -e $testroot/wt/$f ]; then
53 echo "removed file $f still exists on disk" >&2
54 test_done "$testroot" "1"
55 return 1
56 fi
57 done
59 test_done "$testroot" "0"
60 }
62 test_rm_with_local_mods() {
63 local testroot=`test_init rm_with_local_mods`
65 got checkout $testroot/repo $testroot/wt > /dev/null
66 ret=$?
67 if [ $ret -ne 0 ]; then
68 test_done "$testroot" "$ret"
69 return 1
70 fi
72 echo "modified beta" > $testroot/wt/beta
73 echo 'got: beta: file contains modifications' \
74 > $testroot/stderr.expected
75 (cd $testroot/wt && got rm beta 2>$testroot/stderr)
77 cmp -s $testroot/stderr.expected $testroot/stderr
78 ret=$?
79 if [ $ret -ne 0 ]; then
80 diff -u $testroot/stderr.expected $testroot/stderr
81 test_done "$testroot" "$ret"
82 return 1
83 fi
85 echo 'D beta' > $testroot/stdout.expected
86 (cd $testroot/wt && got rm -f beta > $testroot/stdout)
88 cmp -s $testroot/stdout.expected $testroot/stdout
89 ret=$?
90 if [ $ret -ne 0 ]; then
91 diff -u $testroot/stdout.expected $testroot/stdout
92 fi
94 if [ -e $testroot/wt/beta ]; then
95 echo "removed file beta still exists on disk" >&2
96 test_done "$testroot" "1"
97 return 1
98 fi
100 test_done "$testroot" "$ret"
103 test_double_rm() {
104 local testroot=`test_init double_rm`
106 got checkout $testroot/repo $testroot/wt > /dev/null
107 ret=$?
108 if [ $ret -ne 0 ]; then
109 test_done "$testroot" "$ret"
110 return 1
111 fi
113 (cd $testroot/wt && got rm beta > /dev/null)
115 for fflag in "" "-f"; do
116 echo -n > $testroot/stderr.expected
117 (cd $testroot/wt && got rm $fflag beta > $testroot/stdout \
118 2> $testroot/stderr)
119 ret=$?
120 if [ $ret -ne 0 ]; then
121 echo "got rm command failed unexpectedly" >&2
122 diff -u $testroot/stderr.expected $testroot/stderr
123 test_done "$testroot" "$ret"
124 return 1
125 fi
126 echo -n > $testroot/stdout.expected
127 cmp -s $testroot/stdout.expected $testroot/stdout
128 ret=$?
129 if [ $ret -ne 0 ]; then
130 diff -u $testroot/stdout.expected $testroot/stdout
131 test_done "$testroot" "$ret"
132 return 1
133 fi
134 done
135 test_done "$testroot" "0"
138 test_rm_and_add_elsewhere() {
139 local testroot=`test_init rm_and_add_elsewhere`
141 got checkout $testroot/repo $testroot/wt > /dev/null
142 ret=$?
143 if [ $ret -ne 0 ]; then
144 test_done "$testroot" "$ret"
145 return 1
146 fi
148 (cd $testroot/wt && mv alpha epsilon/)
150 (cd $testroot/wt && got status > $testroot/stdout)
152 echo '! alpha' > $testroot/stdout.expected
153 echo '? epsilon/alpha' >> $testroot/stdout.expected
154 cmp -s $testroot/stdout.expected $testroot/stdout
155 ret=$?
156 if [ $ret -ne 0 ]; then
157 diff -u $testroot/stdout.expected $testroot/stdout
158 test_done "$testroot" "$ret"
159 return 1
160 fi
162 (cd $testroot/wt && got rm alpha > $testroot/stdout 2> $testroot/stderr)
163 ret=$?
164 if [ $ret -eq 0 ]; then
165 echo "got rm command succeeded unexpectedly" >&2
166 diff -u $testroot/stderr.expected $testroot/stderr
167 test_done "$testroot" "1"
168 return 1
169 fi
171 echo -n '' > $testroot/stdout.expected
172 cmp -s $testroot/stdout.expected $testroot/stdout
173 ret=$?
174 if [ $ret -ne 0 ]; then
175 diff -u $testroot/stdout.expected $testroot/stdout
176 test_done "$testroot" "$ret"
177 return 1
178 fi
180 echo "got: alpha: No such file or directory" \
181 > $testroot/stderr.expected
182 cmp -s $testroot/stderr.expected $testroot/stderr
183 ret=$?
184 if [ $ret -ne 0 ]; then
185 diff -u $testroot/stderr.expected $testroot/stderr
186 test_done "$testroot" "$ret"
187 return 1
188 fi
190 (cd $testroot/wt && got rm -f alpha > $testroot/stdout)
191 ret=$?
192 if [ $ret -ne 0 ]; then
193 echo "got rm command failed unexpectedly" >&2
194 diff -u $testroot/stderr.expected $testroot/stderr
195 test_done "$testroot" "$ret"
196 return 1
197 fi
199 echo 'D alpha' > $testroot/stdout.expected
200 cmp -s $testroot/stdout.expected $testroot/stdout
201 ret=$?
202 if [ $ret -ne 0 ]; then
203 diff -u $testroot/stdout.expected $testroot/stdout
204 test_done "$testroot" "$ret"
205 return 1
206 fi
208 cmp -s $testroot/stdout.expected $testroot/stdout
209 ret=$?
210 if [ $ret -ne 0 ]; then
211 diff -u $testroot/stdout.expected $testroot/stdout
212 test_done "$testroot" "$ret"
213 return 1
214 fi
216 # While here, test behaviour of rm on files in unversioned status.
217 (cd $testroot/wt && got rm epsilon/alpha > $testroot/stdout \
218 2> $testroot/stderr)
219 ret=$?
220 if [ $ret -eq 0 ]; then
221 echo "got rm command succeeded unexpectedly" >&2
222 diff -u $testroot/stderr.expected $testroot/stderr
223 test_done "$testroot" "1"
224 return 1
225 fi
227 echo -n '' > $testroot/stdout.expected
228 cmp -s $testroot/stdout.expected $testroot/stdout
229 ret=$?
230 if [ $ret -ne 0 ]; then
231 diff -u $testroot/stdout.expected $testroot/stdout
232 test_done "$testroot" "$ret"
233 return 1
234 fi
236 echo "got: epsilon/alpha: file has unexpected status" \
237 > $testroot/stderr.expected
238 cmp -s $testroot/stderr.expected $testroot/stderr
239 ret=$?
240 if [ $ret -ne 0 ]; then
241 diff -u $testroot/stderr.expected $testroot/stderr
242 test_done "$testroot" "$ret"
243 return 1
244 fi
246 # And test the same case with -f.
247 (cd $testroot/wt && got rm -f epsilon/alpha > $testroot/stdout \
248 2> $testroot/stderr)
249 ret=$?
250 if [ $ret -eq 0 ]; then
251 echo "got rm command succeeded unexpectedly" >&2
252 diff -u $testroot/stderr.expected $testroot/stderr
253 test_done "$testroot" "1"
254 return 1
255 fi
257 echo -n '' > $testroot/stdout.expected
258 cmp -s $testroot/stdout.expected $testroot/stdout
259 ret=$?
260 if [ $ret -ne 0 ]; then
261 diff -u $testroot/stdout.expected $testroot/stdout
262 test_done "$testroot" "$ret"
263 return 1
264 fi
266 echo "got: epsilon/alpha: file has unexpected status" \
267 > $testroot/stderr.expected
268 cmp -s $testroot/stderr.expected $testroot/stderr
269 ret=$?
270 if [ $ret -ne 0 ]; then
271 diff -u $testroot/stderr.expected $testroot/stderr
272 test_done "$testroot" "$ret"
273 return 1
274 fi
276 echo 'A epsilon/alpha' > $testroot/stdout.expected
277 (cd $testroot/wt && got add epsilon/alpha > $testroot/stdout)
279 cmp -s $testroot/stdout.expected $testroot/stdout
280 ret=$?
281 if [ $ret -ne 0 ]; then
282 diff -u $testroot/stdout.expected $testroot/stdout
283 test_done "$testroot" "$ret"
284 return 1
285 fi
287 (cd $testroot/wt && got status > $testroot/stdout)
289 echo 'D alpha' > $testroot/stdout.expected
290 echo 'A epsilon/alpha' >> $testroot/stdout.expected
291 cmp -s $testroot/stdout.expected $testroot/stdout
292 ret=$?
293 if [ $ret -ne 0 ]; then
294 diff -u $testroot/stdout.expected $testroot/stdout
295 fi
296 test_done "$testroot" "$ret"
299 test_rm_directory() {
300 local testroot=`test_init rm_directory`
302 got checkout $testroot/repo $testroot/wt > /dev/null
303 ret=$?
304 if [ $ret -ne 0 ]; then
305 test_done "$testroot" "$ret"
306 return 1
307 fi
309 (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
310 ret=$?
311 echo "got: removing directories requires -R option" \
312 > $testroot/stderr.expected
313 cmp -s $testroot/stderr.expected $testroot/stderr
314 ret=$?
315 if [ $ret -ne 0 ]; then
316 diff -u $testroot/stderr.expected $testroot/stderr
317 test_done "$testroot" "$ret"
318 return 1
319 fi
321 echo -n > $testroot/stdout.expected
322 cmp -s $testroot/stdout.expected $testroot/stdout
323 ret=$?
324 if [ $ret -ne 0 ]; then
325 diff -u $testroot/stdout.expected $testroot/stdout
326 test_done "$testroot" "$ret"
327 return 1
328 fi
330 (cd $testroot/wt && got rm -R . > $testroot/stdout)
332 echo 'D alpha' > $testroot/stdout.expected
333 echo 'D beta' >> $testroot/stdout.expected
334 echo 'D epsilon/zeta' >> $testroot/stdout.expected
335 echo 'D gamma/delta' >> $testroot/stdout.expected
337 cmp -s $testroot/stdout.expected $testroot/stdout
338 ret=$?
339 if [ $ret -ne 0 ]; then
340 diff -u $testroot/stdout.expected $testroot/stdout
341 test_done "$testroot" "$ret"
342 return 1
343 fi
345 (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
347 echo -n '' > $testroot/stdout.expected
349 cmp -s $testroot/stdout.expected $testroot/stdout
350 ret=$?
351 if [ $ret -ne 0 ]; then
352 diff -u $testroot/stdout.expected $testroot/stdout
353 test_done "$testroot" "$ret"
354 return 1
355 fi
357 (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
359 echo -n '' > $testroot/stdout.expected
361 cmp -s $testroot/stdout.expected $testroot/stdout
362 ret=$?
363 if [ $ret -ne 0 ]; then
364 diff -u $testroot/stdout.expected $testroot/stdout
365 test_done "$testroot" "$ret"
366 return 1
367 fi
369 test_done "$testroot" "$ret"
372 test_rm_directory_keep_files() {
373 local testroot=`test_init rm_directory_keep_files`
375 got checkout $testroot/repo $testroot/wt > /dev/null
376 ret=$?
377 if [ $ret -ne 0 ]; then
378 test_done "$testroot" "$ret"
379 return 1
380 fi
382 (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
383 ret=$?
384 echo "got: removing directories requires -R option" \
385 > $testroot/stderr.expected
386 cmp -s $testroot/stderr.expected $testroot/stderr
387 ret=$?
388 if [ $ret -ne 0 ]; then
389 diff -u $testroot/stderr.expected $testroot/stderr
390 test_done "$testroot" "$ret"
391 return 1
392 fi
394 echo -n > $testroot/stdout.expected
395 cmp -s $testroot/stdout.expected $testroot/stdout
396 ret=$?
397 if [ $ret -ne 0 ]; then
398 diff -u $testroot/stdout.expected $testroot/stdout
399 test_done "$testroot" "$ret"
400 return 1
401 fi
403 (cd $testroot/wt && got rm -k -R . > $testroot/stdout)
405 echo 'D alpha' > $testroot/stdout.expected
406 echo 'D beta' >> $testroot/stdout.expected
407 echo 'D epsilon/zeta' >> $testroot/stdout.expected
408 echo 'D gamma/delta' >> $testroot/stdout.expected
410 cmp -s $testroot/stdout.expected $testroot/stdout
411 ret=$?
412 if [ $ret -ne 0 ]; then
413 diff -u $testroot/stdout.expected $testroot/stdout
414 test_done "$testroot" "$ret"
415 return 1
416 fi
418 (cd $testroot/wt && got st . > $testroot/stdout)
420 echo 'D alpha' > $testroot/stdout.expected
421 echo 'D beta' >> $testroot/stdout.expected
422 echo 'D epsilon/zeta' >> $testroot/stdout.expected
423 echo 'D gamma/delta' >> $testroot/stdout.expected
425 cmp -s $testroot/stdout.expected $testroot/stdout
426 ret=$?
427 if [ $ret -ne 0 ]; then
428 diff -u $testroot/stdout.expected $testroot/stdout
429 test_done "$testroot" "$ret"
430 return 1
431 fi
433 (cd $testroot/wt && got commit -m "keep" > /dev/null)
434 (cd $testroot/wt && got st . > $testroot/stdout)
436 echo '? alpha' > $testroot/stdout.expected
437 echo '? beta' >> $testroot/stdout.expected
438 echo '? epsilon/zeta' >> $testroot/stdout.expected
439 echo '? gamma/delta' >> $testroot/stdout.expected
441 cmp -s $testroot/stdout.expected $testroot/stdout
442 ret=$?
443 if [ $ret -ne 0 ]; then
444 diff -u $testroot/stdout.expected $testroot/stdout
445 test_done "$testroot" "$ret"
446 return 1
447 fi
449 test_done "$testroot" "$ret"
452 test_rm_subtree() {
453 local testroot=`test_init rm_subtree`
455 got checkout $testroot/repo $testroot/wt > /dev/null
456 ret=$?
457 if [ $ret -ne 0 ]; then
458 test_done "$testroot" "$ret"
459 return 1
460 fi
462 mkdir -p $testroot/wt/epsilon/foo/bar/baz
463 mkdir -p $testroot/wt/epsilon/foo/bar/bax
464 echo "new file" > $testroot/wt/epsilon/foo/a.o
465 echo "new file" > $testroot/wt/epsilon/foo/a.o
466 echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
467 echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
468 echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
469 echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
470 echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
471 echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
472 echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
473 echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
474 echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
475 echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
476 (cd $testroot/wt && got add -R epsilon >/dev/null)
477 (cd $testroot/wt && got commit -m "add subtree" >/dev/null)
479 # now delete and revert the entire subtree
480 (cd $testroot/wt && got rm -R epsilon/foo >/dev/null)
482 if [ -d $testroot/wt/epsilon/foo ]; then
483 echo "removed dir epsilon/foo still exists on disk" >&2
484 test_done "$testroot" "1"
485 return 1
486 fi
488 echo "D epsilon/foo/a.o" > $testroot/stdout.expected
489 echo "D epsilon/foo/bar/b.d" >> $testroot/stdout.expected
490 echo "D epsilon/foo/bar/b.o" >> $testroot/stdout.expected
491 echo "D epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
492 echo "D epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
493 echo "D epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
494 echo "D epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
495 echo "D epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
496 echo "D epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
497 echo "D epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
498 echo "D epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
500 (cd $testroot/wt && got status > $testroot/stdout)
502 cmp -s $testroot/stdout.expected $testroot/stdout
503 ret=$?
504 if [ $ret -ne 0 ]; then
505 diff -u $testroot/stdout.expected $testroot/stdout
506 fi
507 test_done "$testroot" "$ret"
510 test_rm_symlink() {
511 local testroot=`test_init rm_symlink`
513 (cd $testroot/repo && ln -s alpha alpha.link)
514 (cd $testroot/repo && ln -s epsilon epsilon.link)
515 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
516 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
517 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
518 (cd $testroot/repo && git add .)
519 git_commit $testroot/repo -m "add symlinks"
521 got checkout $testroot/repo $testroot/wt > /dev/null
522 ret=$?
523 if [ $ret -ne 0 ]; then
524 test_done "$testroot" "$ret"
525 return 1
526 fi
528 echo 'D alpha.link' > $testroot/stdout.expected
529 echo 'D epsilon/beta.link' >> $testroot/stdout.expected
530 echo 'D epsilon.link' >> $testroot/stdout.expected
531 echo 'D nonexistent.link' >> $testroot/stdout.expected
532 echo 'D passwd.link' >> $testroot/stdout.expected
533 (cd $testroot/wt && got rm alpha.link epsilon.link passwd.link \
534 epsilon/beta.link nonexistent.link > $testroot/stdout)
536 cmp -s $testroot/stdout.expected $testroot/stdout
537 ret=$?
538 if [ $ret -ne 0 ]; then
539 diff -u $testroot/stdout.expected $testroot/stdout
540 fi
541 test_done "$testroot" "$ret"
544 test_rm_status_code() {
545 local testroot=`test_init rm_status_code`
547 got checkout $testroot/repo $testroot/wt > /dev/null
548 ret=$?
549 if [ $ret -ne 0 ]; then
550 test_done "$testroot" "$ret"
551 return 1
552 fi
554 echo "modified beta" > $testroot/wt/beta
556 echo "got: invalid status code 'x'" > $testroot/stderr.expected
557 (cd $testroot/wt && got rm -s Mx beta 2>$testroot/stderr)
559 cmp -s $testroot/stderr.expected $testroot/stderr
560 ret=$?
561 if [ $ret -ne 0 ]; then
562 diff -u $testroot/stderr.expected $testroot/stderr
563 test_done "$testroot" "$ret"
564 return 1
565 fi
567 rm $testroot/wt/epsilon/zeta # put file into 'missing' status
569 echo 'D epsilon/zeta' > $testroot/stdout.expected
570 (cd $testroot/wt && got rm -R -s '!' . >$testroot/stdout)
572 cmp -s $testroot/stdout.expected $testroot/stdout
573 ret=$?
574 if [ $ret -ne 0 ]; then
575 diff -u $testroot/stdout.expected $testroot/stdout
576 fi
578 if [ ! -e $testroot/wt/beta ]; then
579 echo "file beta was unexpectedly removed from disk" >&2
580 test_done "$testroot" "1"
581 return 1
582 fi
584 # put file into 'missing' status again
585 (cd $testroot/wt && got revert epsilon/zeta > /dev/null)
586 rm $testroot/wt/epsilon/zeta
588 echo 'D beta' > $testroot/stdout.expected
589 echo 'D epsilon/zeta' >> $testroot/stdout.expected
590 (cd $testroot/wt && got rm -R -s 'M!' . >$testroot/stdout)
592 cmp -s $testroot/stdout.expected $testroot/stdout
593 ret=$?
594 if [ $ret -ne 0 ]; then
595 diff -u $testroot/stdout.expected $testroot/stdout
596 test_done "$testroot" "1"
597 return 1
598 fi
600 if [ -e $testroot/wt/beta ]; then
601 echo "removed file beta still exists on disk" >&2
602 test_done "$testroot" "1"
603 return 1
604 fi
606 echo 'D beta' > $testroot/stdout.expected
607 echo 'D epsilon/zeta' >> $testroot/stdout.expected
608 (cd $testroot/wt && got status > $testroot/stdout)
609 cmp -s $testroot/stdout.expected $testroot/stdout
610 ret=$?
611 if [ $ret -ne 0 ]; then
612 diff -u $testroot/stdout.expected $testroot/stdout
613 test_done "$testroot" "1"
614 return 1
615 fi
617 test_done "$testroot" "$ret"
620 test_rm_nonexistent_directory() {
621 local testroot=`test_init rm_nonexistent_directory`
623 got checkout $testroot/repo $testroot/wt > /dev/null
624 ret=$?
625 if [ $ret -ne 0 ]; then
626 test_done "$testroot" "$ret"
627 return 1
628 fi
630 rm -r $testroot/wt/epsilon
632 (cd $testroot/wt && got rm epsilon > $testroot/stdout \
633 2> $testroot/stderr)
634 ret=$?
635 if [ $ret -eq 0 ]; then
636 echo "got rm command succeeded unexpectedly" >&2
637 diff -u $testroot/stderr.expected $testroot/stderr
638 test_done "$testroot" "1"
639 return 1
640 fi
642 echo -n '' > $testroot/stdout.expected
643 cmp -s $testroot/stdout.expected $testroot/stdout
644 ret=$?
645 if [ $ret -ne 0 ]; then
646 diff -u $testroot/stdout.expected $testroot/stdout
647 test_done "$testroot" "$ret"
648 return 1
649 fi
651 echo "got: epsilon/zeta: No such file or directory" \
652 > $testroot/stderr.expected
653 cmp -s $testroot/stderr.expected $testroot/stderr
654 ret=$?
655 if [ $ret -ne 0 ]; then
656 diff -u $testroot/stderr.expected $testroot/stderr
657 test_done "$testroot" "$ret"
658 return 1
659 fi
661 (cd $testroot/wt && got rm -f epsilon > $testroot/stdout \
662 2> $testroot/stderr)
663 ret=$?
664 if [ $ret -ne 0 ]; then
665 echo "got rm command failed unexpectedly" >&2
666 diff -u $testroot/stderr.expected $testroot/stderr
667 test_done "$testroot" "$ret"
668 return 1
669 fi
671 echo 'D epsilon/zeta' > $testroot/stdout.expected
672 cmp -s $testroot/stdout.expected $testroot/stdout
673 ret=$?
674 if [ $ret -ne 0 ]; then
675 diff -u $testroot/stdout.expected $testroot/stdout
676 test_done "$testroot" "$ret"
677 return 1
678 fi
680 echo -n '' > $testroot/stderr.expected
681 cmp -s $testroot/stderr.expected $testroot/stderr
682 ret=$?
683 if [ $ret -ne 0 ]; then
684 diff -u $testroot/stderr.expected $testroot/stderr
685 test_done "$testroot" "$ret"
686 return 1
687 fi
689 test_done "$testroot" "$ret"
692 test_rm_empty_pwd() {
693 local testroot=`test_init rm_empty_pwd`
695 got checkout $testroot/repo $testroot/wt > /dev/null
696 ret=$?
697 if [ $ret -ne 0 ]; then
698 test_done "$testroot" "$ret"
699 return 1
700 fi
702 (cd $testroot/wt/epsilon && got rm * > /dev/null)
704 if [ ! -e $testroot/wt/epsilon ]; then
705 echo "epsilon directory doesn't exist" >&2
706 test_done "$testroot" "1"
707 return 1
708 fi
710 test_done "$testroot" "0"
713 test_parseargs "$@"
714 run_test test_rm_basic
715 run_test test_rm_with_local_mods
716 run_test test_double_rm
717 run_test test_rm_and_add_elsewhere
718 run_test test_rm_directory
719 run_test test_rm_directory_keep_files
720 run_test test_rm_subtree
721 run_test test_rm_symlink
722 run_test test_rm_status_code
723 run_test test_rm_nonexistent_directory
724 run_test test_rm_empty_pwd