3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
20 local testroot=`test_init status_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
29 echo "modified alpha" > $testroot/wt/alpha
30 (cd $testroot/wt && got rm beta >/dev/null)
31 echo "unversioned file" > $testroot/wt/foo
32 rm $testroot/wt/epsilon/zeta
33 touch $testroot/wt/beta
34 echo "new file" > $testroot/wt/new
35 (cd $testroot/wt && got add new >/dev/null)
36 mkdir -m 0000 $testroot/wt/bar
38 echo 'M alpha' > $testroot/stdout.expected
39 echo 'D beta' >> $testroot/stdout.expected
40 echo '! epsilon/zeta' >> $testroot/stdout.expected
41 echo '? foo' >> $testroot/stdout.expected
42 echo 'A new' >> $testroot/stdout.expected
44 (cd $testroot/wt && got status > $testroot/stdout)
46 cmp -s $testroot/stdout.expected $testroot/stdout
48 if [ "$ret" != "0" ]; then
49 diff -u $testroot/stdout.expected $testroot/stdout
51 chmod 700 $testroot/wt/bar
52 rmdir $testroot/wt/bar
53 test_done "$testroot" "$ret"
56 test_status_subdir_no_mods() {
57 local testroot=`test_init status_subdir_no_mods 1`
59 mkdir $testroot/repo/Basic/
60 mkdir $testroot/repo/Basic/Targets/
61 touch $testroot/repo/Basic/Targets/AArch64.cpp
62 touch $testroot/repo/Basic/Targets.cpp
63 touch $testroot/repo/Basic/Targets.h
64 (cd $testroot/repo && git add .)
65 git_commit $testroot/repo -m "add subdir with files"
67 got checkout $testroot/repo $testroot/wt > /dev/null
69 if [ "$ret" != "0" ]; then
70 test_done "$testroot" "$ret"
74 touch $testroot/stdout.expected
76 # This used to erroneously print:
80 (cd $testroot/wt && got status > $testroot/stdout)
82 cmp -s $testroot/stdout.expected $testroot/stdout
84 if [ "$ret" != "0" ]; then
85 diff -u $testroot/stdout.expected $testroot/stdout
87 test_done "$testroot" "$ret"
90 test_status_subdir_no_mods2() {
91 local testroot=`test_init status_subdir_no_mods2 1`
93 mkdir $testroot/repo/AST
94 touch $testroot/repo/AST/APValue.cpp
95 mkdir $testroot/repo/ASTMatchers
96 touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
97 mkdir $testroot/repo/Frontend
98 touch $testroot/repo/Frontend/ASTConsumers.cpp
99 mkdir $testroot/repo/Frontend/Rewrite
100 touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
101 mkdir $testroot/repo/FrontendTool
102 touch $testroot/repo/FrontendTool/CMakeLists.txt
103 touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
104 (cd $testroot/repo && git add .)
105 git_commit $testroot/repo -m "add subdir with files"
107 got checkout $testroot/repo $testroot/wt > /dev/null
109 if [ "$ret" != "0" ]; then
110 test_done "$testroot" "$ret"
114 touch $testroot/stdout.expected
116 # This used to erroneously print:
120 # ! Frontend/ASTConsumers.cpp
121 # ! Frontend/Rewrite/CMakeLists.txt
122 # ? Frontend/ASTConsumers.cpp
123 # ? Frontend/Rewrite/CMakeLists.txt
124 (cd $testroot/wt && got status > $testroot/stdout)
126 cmp -s $testroot/stdout.expected $testroot/stdout
128 if [ "$ret" != "0" ]; then
129 diff -u $testroot/stdout.expected $testroot/stdout
131 test_done "$testroot" "$ret"
134 test_status_obstructed() {
135 local testroot=`test_init status_obstructed`
137 got checkout $testroot/repo $testroot/wt > /dev/null
139 if [ "$ret" != "0" ]; then
140 test_done "$testroot" "$ret"
144 rm $testroot/wt/epsilon/zeta
145 mkdir $testroot/wt/epsilon/zeta
147 echo '~ epsilon/zeta' > $testroot/stdout.expected
149 (cd $testroot/wt && got status > $testroot/stdout)
151 cmp -s $testroot/stdout.expected $testroot/stdout
153 if [ "$ret" != "0" ]; then
154 diff -u $testroot/stdout.expected $testroot/stdout
155 test_done "$testroot" "$ret"
159 (cd $testroot/wt && got status epsilon/zeta > $testroot/stdout)
161 cmp -s $testroot/stdout.expected $testroot/stdout
163 if [ "$ret" != "0" ]; then
164 diff -u $testroot/stdout.expected $testroot/stdout
166 test_done "$testroot" "$ret"
169 test_status_shows_local_mods_after_update() {
170 local testroot=`test_init status_shows_local_mods_after_update 1`
172 echo "1" > $testroot/repo/numbers
173 echo "2" >> $testroot/repo/numbers
174 echo "3" >> $testroot/repo/numbers
175 echo "4" >> $testroot/repo/numbers
176 echo "5" >> $testroot/repo/numbers
177 echo "6" >> $testroot/repo/numbers
178 echo "7" >> $testroot/repo/numbers
179 echo "8" >> $testroot/repo/numbers
180 (cd $testroot/repo && git add numbers)
181 git_commit $testroot/repo -m "added numbers file"
183 got checkout $testroot/repo $testroot/wt > /dev/null
185 if [ "$ret" != "0" ]; then
186 test_done "$testroot" "$ret"
190 sed -i 's/2/22/' $testroot/repo/numbers
191 git_commit $testroot/repo -m "modified line 2"
193 # modify line 7; both changes should merge cleanly
194 sed -i 's/7/77/' $testroot/wt/numbers
196 echo "G numbers" > $testroot/stdout.expected
197 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
198 git_show_head $testroot/repo >> $testroot/stdout.expected
199 echo >> $testroot/stdout.expected
201 (cd $testroot/wt && got update > $testroot/stdout)
203 cmp -s $testroot/stdout.expected $testroot/stdout
205 if [ "$ret" != "0" ]; then
206 diff -u $testroot/stdout.expected $testroot/stdout
207 test_done "$testroot" "$ret"
211 echo 'M numbers' > $testroot/stdout.expected
213 (cd $testroot/wt && got status > $testroot/stdout)
215 cmp -s $testroot/stdout.expected $testroot/stdout
217 if [ "$ret" != "0" ]; then
218 diff -u $testroot/stdout.expected $testroot/stdout
220 test_done "$testroot" "$ret"
223 test_status_unversioned_subdirs() {
224 local testroot=`test_init status_unversioned_subdirs 1`
226 mkdir $testroot/repo/cdfs/
227 touch $testroot/repo/cdfs/Makefile
228 mkdir $testroot/repo/common/
229 touch $testroot/repo/common/Makefile
230 mkdir $testroot/repo/iso/
231 touch $testroot/repo/iso/Makefile
232 mkdir $testroot/repo/ramdisk/
233 touch $testroot/repo/ramdisk/Makefile
234 touch $testroot/repo/ramdisk/list.local
235 mkdir $testroot/repo/ramdisk_cd/
236 touch $testroot/repo/ramdisk_cd/Makefile
237 touch $testroot/repo/ramdisk_cd/list.local
238 (cd $testroot/repo && git add .)
239 git_commit $testroot/repo -m "first commit"
241 got checkout $testroot/repo $testroot/wt > /dev/null
243 if [ "$ret" != "0" ]; then
244 test_done "$testroot" "$ret"
248 mkdir $testroot/wt/cdfs/obj
249 mkdir $testroot/wt/ramdisk/obj
250 mkdir $testroot/wt/ramdisk_cd/obj
251 mkdir $testroot/wt/iso/obj
253 echo -n > $testroot/stdout.expected
255 # This used to erroneously print:
257 # ! ramdisk_cd/Makefile
258 # ! ramdisk_cd/list.local
259 # ? ramdisk_cd/Makefile
260 # ? ramdisk_cd/list.local
261 (cd $testroot/wt && got status > $testroot/stdout)
263 cmp -s $testroot/stdout.expected $testroot/stdout
265 if [ "$ret" != "0" ]; then
266 diff -u $testroot/stdout.expected $testroot/stdout
268 test_done "$testroot" "$ret"
271 test_status_symlink() {
272 local testroot=`test_init status_symlink`
274 mkdir $testroot/repo/ramdisk/
275 touch $testroot/repo/ramdisk/Makefile
276 (cd $testroot/repo && ln -s alpha alpha.link)
277 (cd $testroot/repo && ln -s epsilon epsilon.link)
278 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
279 (cd $testroot/repo && git add .)
280 git_commit $testroot/repo -m "first commit"
282 got checkout $testroot/repo $testroot/wt > /dev/null
284 if [ "$ret" != "0" ]; then
285 test_done "$testroot" "$ret"
289 ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
291 echo "? ramdisk/obj" > $testroot/stdout.expected
293 (cd $testroot/wt && got status > $testroot/stdout)
295 cmp -s $testroot/stdout.expected $testroot/stdout
297 if [ "$ret" != "0" ]; then
298 diff -u $testroot/stdout.expected $testroot/stdout
299 test_done "$testroot" "$ret"
303 (cd $testroot/wt && ln -sf beta alpha.link)
304 (cd $testroot/wt && ln -sfh gamma epsilon.link)
306 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
307 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
308 (cd $testroot/wt && got add passwd.link epsilon/beta.link > /dev/null)
310 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
312 echo 'M alpha.link' > $testroot/stdout.expected
313 echo 'A epsilon/beta.link' >> $testroot/stdout.expected
314 echo 'M epsilon.link' >> $testroot/stdout.expected
315 echo 'D nonexistent.link' >> $testroot/stdout.expected
316 echo 'A passwd.link' >> $testroot/stdout.expected
317 echo "? ramdisk/obj" >> $testroot/stdout.expected
319 (cd $testroot/wt && got status > $testroot/stdout)
321 cmp -s $testroot/stdout.expected $testroot/stdout
323 if [ "$ret" != "0" ]; then
324 diff -u $testroot/stdout.expected $testroot/stdout
326 test_done "$testroot" "$ret"
329 test_status_shows_no_mods_after_complete_merge() {
330 local testroot=`test_init status_shows_no_mods_after_complete_merge 1`
332 # make this file larger than the usual blob buffer size of 8192
333 echo -n > $testroot/repo/numbers
334 for i in `jot 16384`; do
335 echo "$i" >> $testroot/repo/numbers
338 (cd $testroot/repo && git add numbers)
339 git_commit $testroot/repo -m "added numbers file"
341 got checkout $testroot/repo $testroot/wt > /dev/null
343 if [ "$ret" != "0" ]; then
344 test_done "$testroot" "$ret"
348 sed -i 's/2/22/' $testroot/repo/numbers
349 git_commit $testroot/repo -m "modified line 2"
352 # modify line 2 again; no local changes are left after merge
353 sed -i 's/2/22/' $testroot/wt/numbers
355 echo "G numbers" > $testroot/stdout.expected
356 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
357 git_show_head $testroot/repo >> $testroot/stdout.expected
358 echo >> $testroot/stdout.expected
360 (cd $testroot/wt && got update > $testroot/stdout)
362 cmp -s $testroot/stdout.expected $testroot/stdout
364 if [ "$ret" != "0" ]; then
365 diff -u $testroot/stdout.expected $testroot/stdout
366 test_done "$testroot" "$ret"
370 echo -n > $testroot/stdout.expected
372 (cd $testroot/wt && got status > $testroot/stdout)
374 cmp -s $testroot/stdout.expected $testroot/stdout
376 if [ "$ret" != "0" ]; then
377 diff -u $testroot/stdout.expected $testroot/stdout
379 test_done "$testroot" "$ret"
382 test_status_shows_conflict() {
383 local testroot=`test_init status_shows_conflict 1`
385 echo "1" > $testroot/repo/numbers
386 echo "2" >> $testroot/repo/numbers
387 echo "3" >> $testroot/repo/numbers
388 echo "4" >> $testroot/repo/numbers
389 echo "5" >> $testroot/repo/numbers
390 echo "6" >> $testroot/repo/numbers
391 echo "7" >> $testroot/repo/numbers
392 echo "8" >> $testroot/repo/numbers
393 (cd $testroot/repo && git add numbers)
394 git_commit $testroot/repo -m "added numbers file"
396 got checkout $testroot/repo $testroot/wt > /dev/null
398 if [ "$ret" != "0" ]; then
399 test_done "$testroot" "$ret"
403 sed -i 's/2/22/' $testroot/repo/numbers
404 git_commit $testroot/repo -m "modified line 2"
406 # modify line 2 in a conflicting way
407 sed -i 's/2/77/' $testroot/wt/numbers
409 echo "C numbers" > $testroot/stdout.expected
410 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
411 git_show_head $testroot/repo >> $testroot/stdout.expected
412 echo >> $testroot/stdout.expected
413 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
415 (cd $testroot/wt && got update > $testroot/stdout)
417 cmp -s $testroot/stdout.expected $testroot/stdout
419 if [ "$ret" != "0" ]; then
420 diff -u $testroot/stdout.expected $testroot/stdout
421 test_done "$testroot" "$ret"
425 echo 'C numbers' > $testroot/stdout.expected
427 (cd $testroot/wt && got status > $testroot/stdout)
429 cmp -s $testroot/stdout.expected $testroot/stdout
431 if [ "$ret" != "0" ]; then
432 diff -u $testroot/stdout.expected $testroot/stdout
434 test_done "$testroot" "$ret"
437 test_status_empty_dir() {
438 local testroot=`test_init status_empty_dir`
440 got checkout $testroot/repo $testroot/wt > /dev/null
442 if [ "$ret" != "0" ]; then
443 test_done "$testroot" "$ret"
447 rm $testroot/wt/epsilon/zeta
449 echo '! epsilon/zeta' > $testroot/stdout.expected
451 (cd $testroot/wt && got status epsilon > $testroot/stdout)
453 cmp -s $testroot/stdout.expected $testroot/stdout
455 if [ "$ret" != "0" ]; then
456 diff -u $testroot/stdout.expected $testroot/stdout
458 test_done "$testroot" "$ret"
461 test_status_empty_dir_unversioned_file() {
462 local testroot=`test_init status_empty_dir_unversioned_file`
464 got checkout $testroot/repo $testroot/wt > /dev/null
466 if [ "$ret" != "0" ]; then
467 test_done "$testroot" "$ret"
471 rm $testroot/wt/epsilon/zeta
472 touch $testroot/wt/epsilon/unversioned
474 echo '? epsilon/unversioned' > $testroot/stdout.expected
475 echo '! epsilon/zeta' >> $testroot/stdout.expected
477 (cd $testroot/wt && got status epsilon > $testroot/stdout)
479 cmp -s $testroot/stdout.expected $testroot/stdout
481 if [ "$ret" != "0" ]; then
482 diff -u $testroot/stdout.expected $testroot/stdout
484 test_done "$testroot" "$ret"
487 test_status_many_paths() {
488 local testroot=`test_init status_many_paths`
490 got checkout $testroot/repo $testroot/wt > /dev/null
492 if [ "$ret" != "0" ]; then
493 test_done "$testroot" "$ret"
497 echo "modified alpha" > $testroot/wt/alpha
498 (cd $testroot/wt && got rm beta >/dev/null)
499 echo "unversioned file" > $testroot/wt/foo
500 rm $testroot/wt/epsilon/zeta
501 touch $testroot/wt/beta
502 echo "new file" > $testroot/wt/new
503 mkdir $testroot/wt/newdir
504 (cd $testroot/wt && got add new >/dev/null)
506 (cd $testroot/wt && got status alpha > $testroot/stdout.expected)
507 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
508 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
509 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
510 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
511 (cd $testroot/wt && got status newdir >> $testroot/stdout.expected)
512 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
514 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
517 cmp -s $testroot/stdout.expected $testroot/stdout
519 if [ "$ret" != "0" ]; then
520 diff -u $testroot/stdout.expected $testroot/stdout
522 test_done "$testroot" "$ret"
525 test_status_cvsignore() {
526 local testroot=`test_init status_cvsignore`
528 got checkout $testroot/repo $testroot/wt > /dev/null
530 if [ "$ret" != "0" ]; then
531 test_done "$testroot" "$ret"
535 echo "unversioned file" > $testroot/wt/foo
536 echo "unversioned file" > $testroot/wt/foop
537 echo "unversioned file" > $testroot/wt/epsilon/foo
538 echo "unversioned file" > $testroot/wt/epsilon/bar
539 echo "unversioned file" > $testroot/wt/epsilon/boo
540 echo "unversioned file" > $testroot/wt/epsilon/moo
541 mkdir -p $testroot/wt/epsilon/new/
542 echo "unversioned file" > $testroot/wt/epsilon/new/foo
543 echo "**/foo" > $testroot/wt/.cvsignore
544 echo "**/gamma" >> $testroot/wt/.cvsignore
545 echo "bar" > $testroot/wt/epsilon/.cvsignore
546 echo "moo" >> $testroot/wt/epsilon/.cvsignore
548 echo '? .cvsignore' > $testroot/stdout.expected
549 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
550 echo '? epsilon/boo' >> $testroot/stdout.expected
551 echo '? foop' >> $testroot/stdout.expected
552 (cd $testroot/wt && got status > $testroot/stdout)
554 cmp -s $testroot/stdout.expected $testroot/stdout
556 if [ "$ret" != "0" ]; then
557 diff -u $testroot/stdout.expected $testroot/stdout
558 test_done "$testroot" "$ret"
562 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
563 echo '? epsilon/boo' >> $testroot/stdout.expected
564 (cd $testroot/wt && got status epsilon > $testroot/stdout)
566 cmp -s $testroot/stdout.expected $testroot/stdout
568 if [ "$ret" != "0" ]; then
569 diff -u $testroot/stdout.expected $testroot/stdout
570 test_done "$testroot" "$ret"
574 echo -n '' > $testroot/stdout.expected
575 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
577 cmp -s $testroot/stdout.expected $testroot/stdout
579 if [ "$ret" != "0" ]; then
580 diff -u $testroot/stdout.expected $testroot/stdout
581 test_done "$testroot" "$ret"
585 echo '? .cvsignore' > $testroot/stdout.expected
586 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
587 echo '? epsilon/boo' >> $testroot/stdout.expected
588 echo '? foop' >> $testroot/stdout.expected
589 (cd $testroot/wt/gamma && got status > $testroot/stdout)
591 cmp -s $testroot/stdout.expected $testroot/stdout
593 if [ "$ret" != "0" ]; then
594 diff -u $testroot/stdout.expected $testroot/stdout
595 test_done "$testroot" "$ret"
599 cat > $testroot/stdout.expected <<EOF
610 (cd $testroot/wt && got status -I > $testroot/stdout)
612 if [ "$ret" != "0" ]; then
613 echo "got status failed unexpectedly" >&2
614 test_done "$testroot" "1"
618 cmp -s $testroot/stdout.expected $testroot/stdout
620 if [ "$ret" != "0" ]; then
621 diff -u $testroot/stdout.expected $testroot/stdout
623 test_done "$testroot" "$ret"
626 test_status_gitignore() {
627 local testroot=`test_init status_gitignore`
629 got checkout $testroot/repo $testroot/wt > /dev/null
631 if [ "$ret" != "0" ]; then
632 test_done "$testroot" "$ret"
636 echo "unversioned file" > $testroot/wt/foo
637 echo "unversioned file" > $testroot/wt/foop
638 echo "unversioned file" > $testroot/wt/barp
639 echo "unversioned file" > $testroot/wt/epsilon/bar
640 echo "unversioned file" > $testroot/wt/epsilon/boo
641 echo "unversioned file" > $testroot/wt/epsilon/moo
642 mkdir -p $testroot/wt/a/b/c/
643 echo "unversioned file" > $testroot/wt/a/b/c/foo
644 echo "unversioned file" > $testroot/wt/a/b/c/zoo
645 echo "foo" > $testroot/wt/.gitignore
646 echo "bar*" >> $testroot/wt/.gitignore
647 echo "epsilon/**" >> $testroot/wt/.gitignore
648 echo "a/**/foo" >> $testroot/wt/.gitignore
649 echo "**/zoo" >> $testroot/wt/.gitignore
651 echo '? .gitignore' > $testroot/stdout.expected
652 echo '? foop' >> $testroot/stdout.expected
653 (cd $testroot/wt && got status > $testroot/stdout)
655 cmp -s $testroot/stdout.expected $testroot/stdout
657 if [ "$ret" != "0" ]; then
658 diff -u $testroot/stdout.expected $testroot/stdout
659 test_done "$testroot" "$ret"
663 echo '? .gitignore' > $testroot/stdout.expected
664 echo '? foop' >> $testroot/stdout.expected
665 (cd $testroot/wt/gamma && got status > $testroot/stdout)
667 cmp -s $testroot/stdout.expected $testroot/stdout
669 if [ "$ret" != "0" ]; then
670 diff -u $testroot/stdout.expected $testroot/stdout
671 test_done "$testroot" "$ret"
675 cat > $testroot/stdout.expected <<EOF
686 (cd $testroot/wt && got status -I > $testroot/stdout)
688 if [ "$ret" != "0" ]; then
689 echo "got status failed unexpectedly" >&2
690 test_done "$testroot" "1"
694 cmp -s $testroot/stdout.expected $testroot/stdout
696 if [ "$ret" != "0" ]; then
697 diff -u $testroot/stdout.expected $testroot/stdout
699 test_done "$testroot" "$ret"
702 test_status_status_code() {
703 local testroot=`test_init status_status_code`
705 got checkout $testroot/repo $testroot/wt > /dev/null
707 if [ "$ret" != "0" ]; then
708 test_done "$testroot" "$ret"
712 echo "modified alpha" > $testroot/wt/alpha
713 (cd $testroot/wt && got rm beta >/dev/null)
714 echo "unversioned file" > $testroot/wt/foo
715 rm $testroot/wt/epsilon/zeta
716 touch $testroot/wt/beta
717 echo "new file" > $testroot/wt/new
718 (cd $testroot/wt && got add new >/dev/null)
720 (cd $testroot/wt && got status -s xDM \
721 > $testroot/stdout 2> $testroot/stderr)
723 if [ "$ret" = "0" ]; then
724 echo "status succeeded unexpectedly" >&2
725 test_done "$testroot" "1"
729 echo "got: invalid status code 'x'" > $testroot/stderr.expected
730 cmp -s $testroot/stderr.expected $testroot/stderr
732 if [ "$ret" != "0" ]; then
733 diff -u $testroot/stderr.expected $testroot/stderr
734 test_done "$testroot" "$ret"
738 echo 'M alpha' > $testroot/stdout.expected
739 (cd $testroot/wt && got status -s M > $testroot/stdout)
740 cmp -s $testroot/stdout.expected $testroot/stdout
742 if [ "$ret" != "0" ]; then
743 diff -u $testroot/stdout.expected $testroot/stdout
744 test_done "$testroot" "$ret"
748 echo 'D beta' > $testroot/stdout.expected
749 (cd $testroot/wt && got status -s D > $testroot/stdout)
750 cmp -s $testroot/stdout.expected $testroot/stdout
752 if [ "$ret" != "0" ]; then
753 diff -u $testroot/stdout.expected $testroot/stdout
754 test_done "$testroot" "$ret"
758 echo '! epsilon/zeta' > $testroot/stdout.expected
759 echo '? foo' >> $testroot/stdout.expected
760 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
761 cmp -s $testroot/stdout.expected $testroot/stdout
763 if [ "$ret" != "0" ]; then
764 diff -u $testroot/stdout.expected $testroot/stdout
765 test_done "$testroot" "$ret"
769 echo 'A new' > $testroot/stdout.expected
770 (cd $testroot/wt && got status -s A > $testroot/stdout)
771 cmp -s $testroot/stdout.expected $testroot/stdout
773 if [ "$ret" != "0" ]; then
774 diff -u $testroot/stdout.expected $testroot/stdout
775 test_done "$testroot" "$ret"
779 (cd $testroot/wt && got stage new > $testroot/stdout)
781 echo ' A new' > $testroot/stdout.expected
782 (cd $testroot/wt && got status -s A > $testroot/stdout)
783 cmp -s $testroot/stdout.expected $testroot/stdout
785 if [ "$ret" != "0" ]; then
786 diff -u $testroot/stdout.expected $testroot/stdout
787 test_done "$testroot" "$ret"
791 echo 'changed file new' > $testroot/wt/new
793 echo 'MA new' > $testroot/stdout.expected
794 (cd $testroot/wt && got status -s A > $testroot/stdout)
795 cmp -s $testroot/stdout.expected $testroot/stdout
797 if [ "$ret" != "0" ]; then
798 diff -u $testroot/stdout.expected $testroot/stdout
799 test_done "$testroot" "$ret"
803 echo 'M alpha' > $testroot/stdout.expected
804 echo 'MA new' >> $testroot/stdout.expected
805 (cd $testroot/wt && got status -s M > $testroot/stdout)
806 cmp -s $testroot/stdout.expected $testroot/stdout
808 if [ "$ret" != "0" ]; then
809 diff -u $testroot/stdout.expected $testroot/stdout
810 test_done "$testroot" "$ret"
814 test_done "$testroot" "$ret"
817 test_status_suppress() {
818 local testroot=`test_init status_suppress`
820 got checkout $testroot/repo $testroot/wt > /dev/null
822 if [ "$ret" != "0" ]; then
823 test_done "$testroot" "$ret"
827 echo "modified alpha" > $testroot/wt/alpha
828 (cd $testroot/wt && got rm beta >/dev/null)
829 echo "unversioned file" > $testroot/wt/foo
830 rm $testroot/wt/epsilon/zeta
831 touch $testroot/wt/beta
832 echo "new file" > $testroot/wt/new
833 (cd $testroot/wt && got add new >/dev/null)
835 (cd $testroot/wt && got status -S A -s M \
836 > $testroot/stdout 2> $testroot/stderr)
838 if [ "$ret" = "0" ]; then
839 echo "status succeeded unexpectedly" >&2
840 test_done "$testroot" "1"
844 echo "got: -s and -S options are mutually exclusive" \
845 > $testroot/stderr.expected
846 cmp -s $testroot/stderr.expected $testroot/stderr
848 if [ "$ret" != "0" ]; then
849 diff -u $testroot/stderr.expected $testroot/stderr
850 test_done "$testroot" "$ret"
854 (cd $testroot/wt && got status -s A -S M \
855 > $testroot/stdout 2> $testroot/stderr)
857 if [ "$ret" = "0" ]; then
858 echo "status succeeded unexpectedly" >&2
859 test_done "$testroot" "1"
863 echo "got: -S and -s options are mutually exclusive" \
864 > $testroot/stderr.expected
865 cmp -s $testroot/stderr.expected $testroot/stderr
867 if [ "$ret" != "0" ]; then
868 diff -u $testroot/stderr.expected $testroot/stderr
869 test_done "$testroot" "$ret"
873 (cd $testroot/wt && got status -S xDM \
874 > $testroot/stdout 2> $testroot/stderr)
876 if [ "$ret" = "0" ]; then
877 echo "status succeeded unexpectedly" >&2
878 test_done "$testroot" "1"
882 echo "got: invalid status code 'x'" > $testroot/stderr.expected
883 cmp -s $testroot/stderr.expected $testroot/stderr
885 if [ "$ret" != "0" ]; then
886 diff -u $testroot/stderr.expected $testroot/stderr
887 test_done "$testroot" "$ret"
891 echo 'M alpha' > $testroot/stdout.expected
892 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
893 cmp -s $testroot/stdout.expected $testroot/stdout
895 if [ "$ret" != "0" ]; then
896 diff -u $testroot/stdout.expected $testroot/stdout
897 test_done "$testroot" "$ret"
901 echo 'D beta' > $testroot/stdout.expected
902 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
903 cmp -s $testroot/stdout.expected $testroot/stdout
905 if [ "$ret" != "0" ]; then
906 diff -u $testroot/stdout.expected $testroot/stdout
907 test_done "$testroot" "$ret"
911 echo '! epsilon/zeta' > $testroot/stdout.expected
912 echo '? foo' >> $testroot/stdout.expected
913 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
914 cmp -s $testroot/stdout.expected $testroot/stdout
916 if [ "$ret" != "0" ]; then
917 diff -u $testroot/stdout.expected $testroot/stdout
918 test_done "$testroot" "$ret"
922 echo 'A new' > $testroot/stdout.expected
923 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
924 cmp -s $testroot/stdout.expected $testroot/stdout
926 if [ "$ret" != "0" ]; then
927 diff -u $testroot/stdout.expected $testroot/stdout
928 test_done "$testroot" "$ret"
932 (cd $testroot/wt && got stage new > $testroot/stdout)
934 echo ' A new' > $testroot/stdout.expected
935 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
936 cmp -s $testroot/stdout.expected $testroot/stdout
938 if [ "$ret" != "0" ]; then
939 diff -u $testroot/stdout.expected $testroot/stdout
940 test_done "$testroot" "$ret"
944 echo 'changed file new' > $testroot/wt/new
946 echo 'M alpha' > $testroot/stdout.expected
947 echo 'MA new' >> $testroot/stdout.expected
948 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
949 cmp -s $testroot/stdout.expected $testroot/stdout
951 if [ "$ret" != "0" ]; then
952 diff -u $testroot/stdout.expected $testroot/stdout
953 test_done "$testroot" "$ret"
957 echo 'M alpha' > $testroot/stdout.expected
958 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
959 cmp -s $testroot/stdout.expected $testroot/stdout
961 if [ "$ret" != "0" ]; then
962 diff -u $testroot/stdout.expected $testroot/stdout
963 test_done "$testroot" "$ret"
967 rm $testroot/stdout.expected
968 touch $testroot/stdout.expected
970 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
971 cmp -s $testroot/stdout.expected $testroot/stdout
973 if [ "$ret" != "0" ]; then
974 diff -u $testroot/stdout.expected $testroot/stdout
975 test_done "$testroot" "$ret"
979 test_done "$testroot" "$ret"
982 test_status_empty_file() {
983 local testroot=`test_init status_empty_file`
985 got checkout $testroot/repo $testroot/wt > /dev/null
987 if [ "$ret" != "0" ]; then
988 test_done "$testroot" "$ret"
992 echo -n "" > $testroot/wt/empty
993 (cd $testroot/wt && got add empty >/dev/null)
995 echo 'A empty' > $testroot/stdout.expected
997 (cd $testroot/wt && got status > $testroot/stdout)
999 cmp -s $testroot/stdout.expected $testroot/stdout
1001 if [ "$ret" != "0" ]; then
1002 diff -u $testroot/stdout.expected $testroot/stdout
1003 test_done "$testroot" "$ret"
1007 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1009 (cd $testroot/wt && got status > $testroot/stdout)
1011 echo -n > $testroot/stdout.expected
1012 cmp -s $testroot/stdout.expected $testroot/stdout
1014 if [ "$ret" != "0" ]; then
1015 diff -u $testroot/stdout.expected $testroot/stdout
1016 test_done "$testroot" "$ret"
1020 # update the timestamp; this used to make the file show up as:
1022 # which should not happen
1023 touch $testroot/wt/empty
1025 (cd $testroot/wt && got status > $testroot/stdout)
1027 echo -n > $testroot/stdout.expected
1028 cmp -s $testroot/stdout.expected $testroot/stdout
1030 if [ "$ret" != "0" ]; then
1031 diff -u $testroot/stdout.expected $testroot/stdout
1033 test_done "$testroot" "$ret"
1037 run_test test_status_basic
1038 run_test test_status_subdir_no_mods
1039 run_test test_status_subdir_no_mods2
1040 run_test test_status_obstructed
1041 run_test test_status_shows_local_mods_after_update
1042 run_test test_status_unversioned_subdirs
1043 run_test test_status_symlink
1044 run_test test_status_shows_no_mods_after_complete_merge
1045 run_test test_status_shows_conflict
1046 run_test test_status_empty_dir
1047 run_test test_status_empty_dir_unversioned_file
1048 run_test test_status_many_paths
1049 run_test test_status_cvsignore
1050 run_test test_status_gitignore
1051 run_test test_status_status_code
1052 run_test test_status_suppress
1053 run_test test_status_empty_file