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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 jot 16384 > $testroot/repo/numbers
335 (cd $testroot/repo && git add numbers)
336 git_commit $testroot/repo -m "added numbers file"
338 got checkout $testroot/repo $testroot/wt > /dev/null
340 if [ $ret -ne 0 ]; then
341 test_done "$testroot" "$ret"
345 sed -i 's/2/22/' $testroot/repo/numbers
346 git_commit $testroot/repo -m "modified line 2"
348 # modify line 2 again; no local changes are left after merge
349 sed -i 's/2/22/' $testroot/wt/numbers
351 echo "G numbers" > $testroot/stdout.expected
352 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
353 git_show_head $testroot/repo >> $testroot/stdout.expected
354 echo >> $testroot/stdout.expected
356 (cd $testroot/wt && got update > $testroot/stdout)
358 cmp -s $testroot/stdout.expected $testroot/stdout
360 if [ $ret -ne 0 ]; then
361 diff -u $testroot/stdout.expected $testroot/stdout
362 test_done "$testroot" "$ret"
366 echo -n > $testroot/stdout.expected
368 (cd $testroot/wt && got status > $testroot/stdout)
370 cmp -s $testroot/stdout.expected $testroot/stdout
372 if [ $ret -ne 0 ]; then
373 diff -u $testroot/stdout.expected $testroot/stdout
375 test_done "$testroot" "$ret"
378 test_status_shows_conflict() {
379 local testroot=`test_init status_shows_conflict 1`
381 echo "1" > $testroot/repo/numbers
382 echo "2" >> $testroot/repo/numbers
383 echo "3" >> $testroot/repo/numbers
384 echo "4" >> $testroot/repo/numbers
385 echo "5" >> $testroot/repo/numbers
386 echo "6" >> $testroot/repo/numbers
387 echo "7" >> $testroot/repo/numbers
388 echo "8" >> $testroot/repo/numbers
389 (cd $testroot/repo && git add numbers)
390 git_commit $testroot/repo -m "added numbers file"
392 got checkout $testroot/repo $testroot/wt > /dev/null
394 if [ $ret -ne 0 ]; then
395 test_done "$testroot" "$ret"
399 sed -i 's/2/22/' $testroot/repo/numbers
400 git_commit $testroot/repo -m "modified line 2"
402 # modify line 2 in a conflicting way
403 sed -i 's/2/77/' $testroot/wt/numbers
405 echo "C numbers" > $testroot/stdout.expected
406 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
407 git_show_head $testroot/repo >> $testroot/stdout.expected
408 echo >> $testroot/stdout.expected
409 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
411 (cd $testroot/wt && got update > $testroot/stdout)
413 cmp -s $testroot/stdout.expected $testroot/stdout
415 if [ $ret -ne 0 ]; then
416 diff -u $testroot/stdout.expected $testroot/stdout
417 test_done "$testroot" "$ret"
421 echo 'C numbers' > $testroot/stdout.expected
423 (cd $testroot/wt && got status > $testroot/stdout)
425 cmp -s $testroot/stdout.expected $testroot/stdout
427 if [ $ret -ne 0 ]; then
428 diff -u $testroot/stdout.expected $testroot/stdout
430 test_done "$testroot" "$ret"
433 test_status_empty_dir() {
434 local testroot=`test_init status_empty_dir`
436 got checkout $testroot/repo $testroot/wt > /dev/null
438 if [ $ret -ne 0 ]; then
439 test_done "$testroot" "$ret"
443 rm $testroot/wt/epsilon/zeta
445 echo '! epsilon/zeta' > $testroot/stdout.expected
447 (cd $testroot/wt && got status epsilon > $testroot/stdout)
449 cmp -s $testroot/stdout.expected $testroot/stdout
451 if [ $ret -ne 0 ]; then
452 diff -u $testroot/stdout.expected $testroot/stdout
454 test_done "$testroot" "$ret"
457 test_status_empty_dir_unversioned_file() {
458 local testroot=`test_init status_empty_dir_unversioned_file`
460 got checkout $testroot/repo $testroot/wt > /dev/null
462 if [ $ret -ne 0 ]; then
463 test_done "$testroot" "$ret"
467 rm $testroot/wt/epsilon/zeta
468 touch $testroot/wt/epsilon/unversioned
470 echo '? epsilon/unversioned' > $testroot/stdout.expected
471 echo '! epsilon/zeta' >> $testroot/stdout.expected
473 (cd $testroot/wt && got status epsilon > $testroot/stdout)
475 cmp -s $testroot/stdout.expected $testroot/stdout
477 if [ $ret -ne 0 ]; then
478 diff -u $testroot/stdout.expected $testroot/stdout
480 test_done "$testroot" "$ret"
483 test_status_many_paths() {
484 local testroot=`test_init status_many_paths`
486 got checkout $testroot/repo $testroot/wt > /dev/null
488 if [ $ret -ne 0 ]; then
489 test_done "$testroot" "$ret"
493 echo "modified alpha" > $testroot/wt/alpha
494 (cd $testroot/wt && got rm beta >/dev/null)
495 echo "unversioned file" > $testroot/wt/foo
496 rm $testroot/wt/epsilon/zeta
497 touch $testroot/wt/beta
498 echo "new file" > $testroot/wt/new
499 mkdir $testroot/wt/newdir
500 (cd $testroot/wt && got add new >/dev/null)
502 (cd $testroot/wt && got status alpha > $testroot/stdout.expected)
503 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
504 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
505 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
506 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
507 (cd $testroot/wt && got status newdir >> $testroot/stdout.expected)
508 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
510 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
513 cmp -s $testroot/stdout.expected $testroot/stdout
515 if [ $ret -ne 0 ]; then
516 diff -u $testroot/stdout.expected $testroot/stdout
518 test_done "$testroot" "$ret"
521 test_status_cvsignore() {
522 local testroot=`test_init status_cvsignore`
524 got checkout $testroot/repo $testroot/wt > /dev/null
526 if [ $ret -ne 0 ]; then
527 test_done "$testroot" "$ret"
531 echo "unversioned file" > $testroot/wt/foo
532 echo "unversioned file" > $testroot/wt/foop
533 echo "unversioned file" > $testroot/wt/epsilon/foo
534 echo "unversioned file" > $testroot/wt/epsilon/bar
535 echo "unversioned file" > $testroot/wt/epsilon/boo
536 echo "unversioned file" > $testroot/wt/epsilon/moo
537 mkdir -p $testroot/wt/epsilon/new/
538 echo "unversioned file" > $testroot/wt/epsilon/new/foo
539 echo "**/foo" > $testroot/wt/.cvsignore
540 echo "**/gamma" >> $testroot/wt/.cvsignore
541 echo "bar" > $testroot/wt/epsilon/.cvsignore
542 echo "moo" >> $testroot/wt/epsilon/.cvsignore
544 echo '? .cvsignore' > $testroot/stdout.expected
545 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
546 echo '? epsilon/boo' >> $testroot/stdout.expected
547 echo '? foop' >> $testroot/stdout.expected
548 (cd $testroot/wt && got status > $testroot/stdout)
550 cmp -s $testroot/stdout.expected $testroot/stdout
552 if [ $ret -ne 0 ]; then
553 diff -u $testroot/stdout.expected $testroot/stdout
554 test_done "$testroot" "$ret"
558 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
559 echo '? epsilon/boo' >> $testroot/stdout.expected
560 (cd $testroot/wt && got status epsilon > $testroot/stdout)
562 cmp -s $testroot/stdout.expected $testroot/stdout
564 if [ $ret -ne 0 ]; then
565 diff -u $testroot/stdout.expected $testroot/stdout
566 test_done "$testroot" "$ret"
570 echo -n '' > $testroot/stdout.expected
571 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
573 cmp -s $testroot/stdout.expected $testroot/stdout
575 if [ $ret -ne 0 ]; then
576 diff -u $testroot/stdout.expected $testroot/stdout
577 test_done "$testroot" "$ret"
581 echo '? .cvsignore' > $testroot/stdout.expected
582 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
583 echo '? epsilon/boo' >> $testroot/stdout.expected
584 echo '? foop' >> $testroot/stdout.expected
585 (cd $testroot/wt/gamma && got status > $testroot/stdout)
587 cmp -s $testroot/stdout.expected $testroot/stdout
589 if [ $ret -ne 0 ]; then
590 diff -u $testroot/stdout.expected $testroot/stdout
591 test_done "$testroot" "$ret"
595 cat > $testroot/stdout.expected <<EOF
606 (cd $testroot/wt && got status -I > $testroot/stdout)
608 if [ $ret -ne 0 ]; then
609 echo "got status failed unexpectedly" >&2
610 test_done "$testroot" "1"
614 cmp -s $testroot/stdout.expected $testroot/stdout
616 if [ $ret -ne 0 ]; then
617 diff -u $testroot/stdout.expected $testroot/stdout
619 test_done "$testroot" "$ret"
622 test_status_gitignore() {
623 local testroot=`test_init status_gitignore`
625 got checkout $testroot/repo $testroot/wt > /dev/null
627 if [ $ret -ne 0 ]; then
628 test_done "$testroot" "$ret"
632 echo "unversioned file" > $testroot/wt/foo
633 echo "unversioned file" > $testroot/wt/foop
634 echo "unversioned file" > $testroot/wt/barp
635 echo "unversioned file" > $testroot/wt/epsilon/bar
636 echo "unversioned file" > $testroot/wt/epsilon/boo
637 echo "unversioned file" > $testroot/wt/epsilon/moo
638 mkdir -p $testroot/wt/a/b/c/
639 echo "unversioned file" > $testroot/wt/a/b/c/foo
640 echo "unversioned file" > $testroot/wt/a/b/c/zoo
641 echo "foo" > $testroot/wt/.gitignore
642 echo "bar*" >> $testroot/wt/.gitignore
643 echo "epsilon/**" >> $testroot/wt/.gitignore
644 echo "a/**/foo" >> $testroot/wt/.gitignore
645 echo "**/zoo" >> $testroot/wt/.gitignore
647 echo '? .gitignore' > $testroot/stdout.expected
648 echo '? foop' >> $testroot/stdout.expected
649 (cd $testroot/wt && got status > $testroot/stdout)
651 cmp -s $testroot/stdout.expected $testroot/stdout
653 if [ $ret -ne 0 ]; then
654 diff -u $testroot/stdout.expected $testroot/stdout
655 test_done "$testroot" "$ret"
659 echo '? .gitignore' > $testroot/stdout.expected
660 echo '? foop' >> $testroot/stdout.expected
661 (cd $testroot/wt/gamma && got status > $testroot/stdout)
663 cmp -s $testroot/stdout.expected $testroot/stdout
665 if [ $ret -ne 0 ]; then
666 diff -u $testroot/stdout.expected $testroot/stdout
667 test_done "$testroot" "$ret"
671 cat > $testroot/stdout.expected <<EOF
682 (cd $testroot/wt && got status -I > $testroot/stdout)
684 if [ $ret -ne 0 ]; then
685 echo "got status failed unexpectedly" >&2
686 test_done "$testroot" "1"
690 cmp -s $testroot/stdout.expected $testroot/stdout
692 if [ $ret -ne 0 ]; then
693 diff -u $testroot/stdout.expected $testroot/stdout
695 test_done "$testroot" "$ret"
698 test_status_status_code() {
699 local testroot=`test_init status_status_code`
701 got checkout $testroot/repo $testroot/wt > /dev/null
703 if [ $ret -ne 0 ]; then
704 test_done "$testroot" "$ret"
708 echo "modified alpha" > $testroot/wt/alpha
709 (cd $testroot/wt && got rm beta >/dev/null)
710 echo "unversioned file" > $testroot/wt/foo
711 rm $testroot/wt/epsilon/zeta
712 touch $testroot/wt/beta
713 echo "new file" > $testroot/wt/new
714 (cd $testroot/wt && got add new >/dev/null)
716 (cd $testroot/wt && got status -s xDM \
717 > $testroot/stdout 2> $testroot/stderr)
719 if [ $ret -eq 0 ]; then
720 echo "status succeeded unexpectedly" >&2
721 test_done "$testroot" "1"
725 echo "got: invalid status code 'x'" > $testroot/stderr.expected
726 cmp -s $testroot/stderr.expected $testroot/stderr
728 if [ $ret -ne 0 ]; then
729 diff -u $testroot/stderr.expected $testroot/stderr
730 test_done "$testroot" "$ret"
734 echo 'M alpha' > $testroot/stdout.expected
735 (cd $testroot/wt && got status -s M > $testroot/stdout)
736 cmp -s $testroot/stdout.expected $testroot/stdout
738 if [ $ret -ne 0 ]; then
739 diff -u $testroot/stdout.expected $testroot/stdout
740 test_done "$testroot" "$ret"
744 echo 'D beta' > $testroot/stdout.expected
745 (cd $testroot/wt && got status -s D > $testroot/stdout)
746 cmp -s $testroot/stdout.expected $testroot/stdout
748 if [ $ret -ne 0 ]; then
749 diff -u $testroot/stdout.expected $testroot/stdout
750 test_done "$testroot" "$ret"
754 echo '! epsilon/zeta' > $testroot/stdout.expected
755 echo '? foo' >> $testroot/stdout.expected
756 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
757 cmp -s $testroot/stdout.expected $testroot/stdout
759 if [ $ret -ne 0 ]; then
760 diff -u $testroot/stdout.expected $testroot/stdout
761 test_done "$testroot" "$ret"
765 echo 'A new' > $testroot/stdout.expected
766 (cd $testroot/wt && got status -s A > $testroot/stdout)
767 cmp -s $testroot/stdout.expected $testroot/stdout
769 if [ $ret -ne 0 ]; then
770 diff -u $testroot/stdout.expected $testroot/stdout
771 test_done "$testroot" "$ret"
775 (cd $testroot/wt && got stage new > $testroot/stdout)
777 echo ' A new' > $testroot/stdout.expected
778 (cd $testroot/wt && got status -s A > $testroot/stdout)
779 cmp -s $testroot/stdout.expected $testroot/stdout
781 if [ $ret -ne 0 ]; then
782 diff -u $testroot/stdout.expected $testroot/stdout
783 test_done "$testroot" "$ret"
787 echo 'changed file new' > $testroot/wt/new
789 echo 'MA new' > $testroot/stdout.expected
790 (cd $testroot/wt && got status -s A > $testroot/stdout)
791 cmp -s $testroot/stdout.expected $testroot/stdout
793 if [ $ret -ne 0 ]; then
794 diff -u $testroot/stdout.expected $testroot/stdout
795 test_done "$testroot" "$ret"
799 echo 'M alpha' > $testroot/stdout.expected
800 echo 'MA new' >> $testroot/stdout.expected
801 (cd $testroot/wt && got status -s M > $testroot/stdout)
802 cmp -s $testroot/stdout.expected $testroot/stdout
804 if [ $ret -ne 0 ]; then
805 diff -u $testroot/stdout.expected $testroot/stdout
806 test_done "$testroot" "$ret"
810 test_done "$testroot" "$ret"
813 test_status_suppress() {
814 local testroot=`test_init status_suppress`
816 got checkout $testroot/repo $testroot/wt > /dev/null
818 if [ $ret -ne 0 ]; then
819 test_done "$testroot" "$ret"
823 echo "modified alpha" > $testroot/wt/alpha
824 (cd $testroot/wt && got rm beta >/dev/null)
825 echo "unversioned file" > $testroot/wt/foo
826 rm $testroot/wt/epsilon/zeta
827 touch $testroot/wt/beta
828 echo "new file" > $testroot/wt/new
829 (cd $testroot/wt && got add new >/dev/null)
831 (cd $testroot/wt && got status -S A -s M \
832 > $testroot/stdout 2> $testroot/stderr)
834 if [ $ret -eq 0 ]; then
835 echo "status succeeded unexpectedly" >&2
836 test_done "$testroot" "1"
840 echo "got: -s and -S options are mutually exclusive" \
841 > $testroot/stderr.expected
842 cmp -s $testroot/stderr.expected $testroot/stderr
844 if [ $ret -ne 0 ]; then
845 diff -u $testroot/stderr.expected $testroot/stderr
846 test_done "$testroot" "$ret"
850 (cd $testroot/wt && got status -s A -S M \
851 > $testroot/stdout 2> $testroot/stderr)
853 if [ $ret -eq 0 ]; then
854 echo "status succeeded unexpectedly" >&2
855 test_done "$testroot" "1"
859 echo "got: -S and -s options are mutually exclusive" \
860 > $testroot/stderr.expected
861 cmp -s $testroot/stderr.expected $testroot/stderr
863 if [ $ret -ne 0 ]; then
864 diff -u $testroot/stderr.expected $testroot/stderr
865 test_done "$testroot" "$ret"
869 (cd $testroot/wt && got status -S xDM \
870 > $testroot/stdout 2> $testroot/stderr)
872 if [ $ret -eq 0 ]; then
873 echo "status succeeded unexpectedly" >&2
874 test_done "$testroot" "1"
878 echo "got: invalid status code 'x'" > $testroot/stderr.expected
879 cmp -s $testroot/stderr.expected $testroot/stderr
881 if [ $ret -ne 0 ]; then
882 diff -u $testroot/stderr.expected $testroot/stderr
883 test_done "$testroot" "$ret"
887 echo 'M alpha' > $testroot/stdout.expected
888 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
889 cmp -s $testroot/stdout.expected $testroot/stdout
891 if [ $ret -ne 0 ]; then
892 diff -u $testroot/stdout.expected $testroot/stdout
893 test_done "$testroot" "$ret"
897 echo 'D beta' > $testroot/stdout.expected
898 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
899 cmp -s $testroot/stdout.expected $testroot/stdout
901 if [ $ret -ne 0 ]; then
902 diff -u $testroot/stdout.expected $testroot/stdout
903 test_done "$testroot" "$ret"
907 echo '! epsilon/zeta' > $testroot/stdout.expected
908 echo '? foo' >> $testroot/stdout.expected
909 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
910 cmp -s $testroot/stdout.expected $testroot/stdout
912 if [ $ret -ne 0 ]; then
913 diff -u $testroot/stdout.expected $testroot/stdout
914 test_done "$testroot" "$ret"
918 echo 'A new' > $testroot/stdout.expected
919 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
920 cmp -s $testroot/stdout.expected $testroot/stdout
922 if [ $ret -ne 0 ]; then
923 diff -u $testroot/stdout.expected $testroot/stdout
924 test_done "$testroot" "$ret"
928 (cd $testroot/wt && got stage new > $testroot/stdout)
930 echo ' A new' > $testroot/stdout.expected
931 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
932 cmp -s $testroot/stdout.expected $testroot/stdout
934 if [ $ret -ne 0 ]; then
935 diff -u $testroot/stdout.expected $testroot/stdout
936 test_done "$testroot" "$ret"
940 echo 'changed file new' > $testroot/wt/new
942 echo 'M alpha' > $testroot/stdout.expected
943 echo 'MA new' >> $testroot/stdout.expected
944 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
945 cmp -s $testroot/stdout.expected $testroot/stdout
947 if [ $ret -ne 0 ]; then
948 diff -u $testroot/stdout.expected $testroot/stdout
949 test_done "$testroot" "$ret"
953 echo 'M alpha' > $testroot/stdout.expected
954 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
955 cmp -s $testroot/stdout.expected $testroot/stdout
957 if [ $ret -ne 0 ]; then
958 diff -u $testroot/stdout.expected $testroot/stdout
959 test_done "$testroot" "$ret"
963 rm $testroot/stdout.expected
964 touch $testroot/stdout.expected
966 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
967 cmp -s $testroot/stdout.expected $testroot/stdout
969 if [ $ret -ne 0 ]; then
970 diff -u $testroot/stdout.expected $testroot/stdout
971 test_done "$testroot" "$ret"
975 test_done "$testroot" "$ret"
978 test_status_empty_file() {
979 local testroot=`test_init status_empty_file`
981 got checkout $testroot/repo $testroot/wt > /dev/null
983 if [ $ret -ne 0 ]; then
984 test_done "$testroot" "$ret"
988 echo -n "" > $testroot/wt/empty
989 (cd $testroot/wt && got add empty >/dev/null)
991 echo 'A empty' > $testroot/stdout.expected
993 (cd $testroot/wt && got status > $testroot/stdout)
995 cmp -s $testroot/stdout.expected $testroot/stdout
997 if [ $ret -ne 0 ]; then
998 diff -u $testroot/stdout.expected $testroot/stdout
999 test_done "$testroot" "$ret"
1003 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1005 (cd $testroot/wt && got status > $testroot/stdout)
1007 echo -n > $testroot/stdout.expected
1008 cmp -s $testroot/stdout.expected $testroot/stdout
1010 if [ $ret -ne 0 ]; then
1011 diff -u $testroot/stdout.expected $testroot/stdout
1012 test_done "$testroot" "$ret"
1016 # update the timestamp; this used to make the file show up as:
1018 # which should not happen
1019 touch $testroot/wt/empty
1021 (cd $testroot/wt && got status > $testroot/stdout)
1023 echo -n > $testroot/stdout.expected
1024 cmp -s $testroot/stdout.expected $testroot/stdout
1026 if [ $ret -ne 0 ]; then
1027 diff -u $testroot/stdout.expected $testroot/stdout
1029 test_done "$testroot" "$ret"
1033 run_test test_status_basic
1034 run_test test_status_subdir_no_mods
1035 run_test test_status_subdir_no_mods2
1036 run_test test_status_obstructed
1037 run_test test_status_shows_local_mods_after_update
1038 run_test test_status_unversioned_subdirs
1039 run_test test_status_symlink
1040 run_test test_status_shows_no_mods_after_complete_merge
1041 run_test test_status_shows_conflict
1042 run_test test_status_empty_dir
1043 run_test test_status_empty_dir_unversioned_file
1044 run_test test_status_many_paths
1045 run_test test_status_cvsignore
1046 run_test test_status_gitignore
1047 run_test test_status_status_code
1048 run_test test_status_suppress
1049 run_test test_status_empty_file