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"
349 # modify line 2 again; no local changes are left after merge
350 sed -i 's/2/22/' $testroot/wt/numbers
352 echo "G numbers" > $testroot/stdout.expected
353 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
354 git_show_head $testroot/repo >> $testroot/stdout.expected
355 echo >> $testroot/stdout.expected
357 (cd $testroot/wt && got update > $testroot/stdout)
359 cmp -s $testroot/stdout.expected $testroot/stdout
361 if [ $ret -ne 0 ]; then
362 diff -u $testroot/stdout.expected $testroot/stdout
363 test_done "$testroot" "$ret"
367 echo -n > $testroot/stdout.expected
369 (cd $testroot/wt && got status > $testroot/stdout)
371 cmp -s $testroot/stdout.expected $testroot/stdout
373 if [ $ret -ne 0 ]; then
374 diff -u $testroot/stdout.expected $testroot/stdout
376 test_done "$testroot" "$ret"
379 test_status_shows_conflict() {
380 local testroot=`test_init status_shows_conflict 1`
382 echo "1" > $testroot/repo/numbers
383 echo "2" >> $testroot/repo/numbers
384 echo "3" >> $testroot/repo/numbers
385 echo "4" >> $testroot/repo/numbers
386 echo "5" >> $testroot/repo/numbers
387 echo "6" >> $testroot/repo/numbers
388 echo "7" >> $testroot/repo/numbers
389 echo "8" >> $testroot/repo/numbers
390 (cd $testroot/repo && git add numbers)
391 git_commit $testroot/repo -m "added numbers file"
393 got checkout $testroot/repo $testroot/wt > /dev/null
395 if [ $ret -ne 0 ]; then
396 test_done "$testroot" "$ret"
400 sed -i 's/2/22/' $testroot/repo/numbers
401 git_commit $testroot/repo -m "modified line 2"
403 # modify line 2 in a conflicting way
404 sed -i 's/2/77/' $testroot/wt/numbers
406 echo "C numbers" > $testroot/stdout.expected
407 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
408 git_show_head $testroot/repo >> $testroot/stdout.expected
409 echo >> $testroot/stdout.expected
410 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
412 (cd $testroot/wt && got update > $testroot/stdout)
414 cmp -s $testroot/stdout.expected $testroot/stdout
416 if [ $ret -ne 0 ]; then
417 diff -u $testroot/stdout.expected $testroot/stdout
418 test_done "$testroot" "$ret"
422 echo 'C numbers' > $testroot/stdout.expected
424 (cd $testroot/wt && got status > $testroot/stdout)
426 cmp -s $testroot/stdout.expected $testroot/stdout
428 if [ $ret -ne 0 ]; then
429 diff -u $testroot/stdout.expected $testroot/stdout
431 test_done "$testroot" "$ret"
434 test_status_empty_dir() {
435 local testroot=`test_init status_empty_dir`
437 got checkout $testroot/repo $testroot/wt > /dev/null
439 if [ $ret -ne 0 ]; then
440 test_done "$testroot" "$ret"
444 rm $testroot/wt/epsilon/zeta
446 echo '! epsilon/zeta' > $testroot/stdout.expected
448 (cd $testroot/wt && got status epsilon > $testroot/stdout)
450 cmp -s $testroot/stdout.expected $testroot/stdout
452 if [ $ret -ne 0 ]; then
453 diff -u $testroot/stdout.expected $testroot/stdout
455 test_done "$testroot" "$ret"
458 test_status_empty_dir_unversioned_file() {
459 local testroot=`test_init status_empty_dir_unversioned_file`
461 got checkout $testroot/repo $testroot/wt > /dev/null
463 if [ $ret -ne 0 ]; then
464 test_done "$testroot" "$ret"
468 rm $testroot/wt/epsilon/zeta
469 touch $testroot/wt/epsilon/unversioned
471 echo '? epsilon/unversioned' > $testroot/stdout.expected
472 echo '! epsilon/zeta' >> $testroot/stdout.expected
474 (cd $testroot/wt && got status epsilon > $testroot/stdout)
476 cmp -s $testroot/stdout.expected $testroot/stdout
478 if [ $ret -ne 0 ]; then
479 diff -u $testroot/stdout.expected $testroot/stdout
481 test_done "$testroot" "$ret"
484 test_status_many_paths() {
485 local testroot=`test_init status_many_paths`
487 got checkout $testroot/repo $testroot/wt > /dev/null
489 if [ $ret -ne 0 ]; then
490 test_done "$testroot" "$ret"
494 echo "modified alpha" > $testroot/wt/alpha
495 (cd $testroot/wt && got rm beta >/dev/null)
496 echo "unversioned file" > $testroot/wt/foo
497 rm $testroot/wt/epsilon/zeta
498 touch $testroot/wt/beta
499 echo "new file" > $testroot/wt/new
500 mkdir $testroot/wt/newdir
501 (cd $testroot/wt && got add new >/dev/null)
503 (cd $testroot/wt && got status alpha > $testroot/stdout.expected)
504 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
505 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
506 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
507 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
508 (cd $testroot/wt && got status newdir >> $testroot/stdout.expected)
509 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
511 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
514 cmp -s $testroot/stdout.expected $testroot/stdout
516 if [ $ret -ne 0 ]; then
517 diff -u $testroot/stdout.expected $testroot/stdout
519 test_done "$testroot" "$ret"
522 test_status_cvsignore() {
523 local testroot=`test_init status_cvsignore`
525 got checkout $testroot/repo $testroot/wt > /dev/null
527 if [ $ret -ne 0 ]; then
528 test_done "$testroot" "$ret"
532 echo "unversioned file" > $testroot/wt/foo
533 echo "unversioned file" > $testroot/wt/foop
534 echo "unversioned file" > $testroot/wt/epsilon/foo
535 echo "unversioned file" > $testroot/wt/epsilon/bar
536 echo "unversioned file" > $testroot/wt/epsilon/boo
537 echo "unversioned file" > $testroot/wt/epsilon/moo
538 mkdir -p $testroot/wt/epsilon/new/
539 echo "unversioned file" > $testroot/wt/epsilon/new/foo
540 echo "**/foo" > $testroot/wt/.cvsignore
541 echo "**/gamma" >> $testroot/wt/.cvsignore
542 echo "bar" > $testroot/wt/epsilon/.cvsignore
543 echo "moo" >> $testroot/wt/epsilon/.cvsignore
545 echo '? .cvsignore' > $testroot/stdout.expected
546 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
547 echo '? epsilon/boo' >> $testroot/stdout.expected
548 echo '? foop' >> $testroot/stdout.expected
549 (cd $testroot/wt && got status > $testroot/stdout)
551 cmp -s $testroot/stdout.expected $testroot/stdout
553 if [ $ret -ne 0 ]; then
554 diff -u $testroot/stdout.expected $testroot/stdout
555 test_done "$testroot" "$ret"
559 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
560 echo '? epsilon/boo' >> $testroot/stdout.expected
561 (cd $testroot/wt && got status epsilon > $testroot/stdout)
563 cmp -s $testroot/stdout.expected $testroot/stdout
565 if [ $ret -ne 0 ]; then
566 diff -u $testroot/stdout.expected $testroot/stdout
567 test_done "$testroot" "$ret"
571 echo -n '' > $testroot/stdout.expected
572 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
574 cmp -s $testroot/stdout.expected $testroot/stdout
576 if [ $ret -ne 0 ]; then
577 diff -u $testroot/stdout.expected $testroot/stdout
578 test_done "$testroot" "$ret"
582 echo '? .cvsignore' > $testroot/stdout.expected
583 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
584 echo '? epsilon/boo' >> $testroot/stdout.expected
585 echo '? foop' >> $testroot/stdout.expected
586 (cd $testroot/wt/gamma && got status > $testroot/stdout)
588 cmp -s $testroot/stdout.expected $testroot/stdout
590 if [ $ret -ne 0 ]; then
591 diff -u $testroot/stdout.expected $testroot/stdout
592 test_done "$testroot" "$ret"
596 cat > $testroot/stdout.expected <<EOF
607 (cd $testroot/wt && got status -I > $testroot/stdout)
609 if [ $ret -ne 0 ]; then
610 echo "got status failed unexpectedly" >&2
611 test_done "$testroot" "1"
615 cmp -s $testroot/stdout.expected $testroot/stdout
617 if [ $ret -ne 0 ]; then
618 diff -u $testroot/stdout.expected $testroot/stdout
620 test_done "$testroot" "$ret"
623 test_status_gitignore() {
624 local testroot=`test_init status_gitignore`
626 got checkout $testroot/repo $testroot/wt > /dev/null
628 if [ $ret -ne 0 ]; then
629 test_done "$testroot" "$ret"
633 echo "unversioned file" > $testroot/wt/foo
634 echo "unversioned file" > $testroot/wt/foop
635 echo "unversioned file" > $testroot/wt/barp
636 echo "unversioned file" > $testroot/wt/epsilon/bar
637 echo "unversioned file" > $testroot/wt/epsilon/boo
638 echo "unversioned file" > $testroot/wt/epsilon/moo
639 mkdir -p $testroot/wt/a/b/c/
640 echo "unversioned file" > $testroot/wt/a/b/c/foo
641 echo "unversioned file" > $testroot/wt/a/b/c/zoo
642 echo "foo" > $testroot/wt/.gitignore
643 echo "bar*" >> $testroot/wt/.gitignore
644 echo "epsilon/**" >> $testroot/wt/.gitignore
645 echo "a/**/foo" >> $testroot/wt/.gitignore
646 echo "**/zoo" >> $testroot/wt/.gitignore
648 echo '? .gitignore' > $testroot/stdout.expected
649 echo '? foop' >> $testroot/stdout.expected
650 (cd $testroot/wt && got status > $testroot/stdout)
652 cmp -s $testroot/stdout.expected $testroot/stdout
654 if [ $ret -ne 0 ]; then
655 diff -u $testroot/stdout.expected $testroot/stdout
656 test_done "$testroot" "$ret"
660 echo '? .gitignore' > $testroot/stdout.expected
661 echo '? foop' >> $testroot/stdout.expected
662 (cd $testroot/wt/gamma && got status > $testroot/stdout)
664 cmp -s $testroot/stdout.expected $testroot/stdout
666 if [ $ret -ne 0 ]; then
667 diff -u $testroot/stdout.expected $testroot/stdout
668 test_done "$testroot" "$ret"
672 cat > $testroot/stdout.expected <<EOF
683 (cd $testroot/wt && got status -I > $testroot/stdout)
685 if [ $ret -ne 0 ]; then
686 echo "got status failed unexpectedly" >&2
687 test_done "$testroot" "1"
691 cmp -s $testroot/stdout.expected $testroot/stdout
693 if [ $ret -ne 0 ]; then
694 diff -u $testroot/stdout.expected $testroot/stdout
696 test_done "$testroot" "$ret"
699 test_status_status_code() {
700 local testroot=`test_init status_status_code`
702 got checkout $testroot/repo $testroot/wt > /dev/null
704 if [ $ret -ne 0 ]; then
705 test_done "$testroot" "$ret"
709 echo "modified alpha" > $testroot/wt/alpha
710 (cd $testroot/wt && got rm beta >/dev/null)
711 echo "unversioned file" > $testroot/wt/foo
712 rm $testroot/wt/epsilon/zeta
713 touch $testroot/wt/beta
714 echo "new file" > $testroot/wt/new
715 (cd $testroot/wt && got add new >/dev/null)
717 (cd $testroot/wt && got status -s xDM \
718 > $testroot/stdout 2> $testroot/stderr)
720 if [ $ret -eq 0 ]; then
721 echo "status succeeded unexpectedly" >&2
722 test_done "$testroot" "1"
726 echo "got: invalid status code 'x'" > $testroot/stderr.expected
727 cmp -s $testroot/stderr.expected $testroot/stderr
729 if [ $ret -ne 0 ]; then
730 diff -u $testroot/stderr.expected $testroot/stderr
731 test_done "$testroot" "$ret"
735 echo 'M alpha' > $testroot/stdout.expected
736 (cd $testroot/wt && got status -s M > $testroot/stdout)
737 cmp -s $testroot/stdout.expected $testroot/stdout
739 if [ $ret -ne 0 ]; then
740 diff -u $testroot/stdout.expected $testroot/stdout
741 test_done "$testroot" "$ret"
745 echo 'D beta' > $testroot/stdout.expected
746 (cd $testroot/wt && got status -s D > $testroot/stdout)
747 cmp -s $testroot/stdout.expected $testroot/stdout
749 if [ $ret -ne 0 ]; then
750 diff -u $testroot/stdout.expected $testroot/stdout
751 test_done "$testroot" "$ret"
755 echo '! epsilon/zeta' > $testroot/stdout.expected
756 echo '? foo' >> $testroot/stdout.expected
757 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
758 cmp -s $testroot/stdout.expected $testroot/stdout
760 if [ $ret -ne 0 ]; then
761 diff -u $testroot/stdout.expected $testroot/stdout
762 test_done "$testroot" "$ret"
766 echo 'A new' > $testroot/stdout.expected
767 (cd $testroot/wt && got status -s A > $testroot/stdout)
768 cmp -s $testroot/stdout.expected $testroot/stdout
770 if [ $ret -ne 0 ]; then
771 diff -u $testroot/stdout.expected $testroot/stdout
772 test_done "$testroot" "$ret"
776 (cd $testroot/wt && got stage new > $testroot/stdout)
778 echo ' A new' > $testroot/stdout.expected
779 (cd $testroot/wt && got status -s A > $testroot/stdout)
780 cmp -s $testroot/stdout.expected $testroot/stdout
782 if [ $ret -ne 0 ]; then
783 diff -u $testroot/stdout.expected $testroot/stdout
784 test_done "$testroot" "$ret"
788 echo 'changed file new' > $testroot/wt/new
790 echo 'MA new' > $testroot/stdout.expected
791 (cd $testroot/wt && got status -s A > $testroot/stdout)
792 cmp -s $testroot/stdout.expected $testroot/stdout
794 if [ $ret -ne 0 ]; then
795 diff -u $testroot/stdout.expected $testroot/stdout
796 test_done "$testroot" "$ret"
800 echo 'M alpha' > $testroot/stdout.expected
801 echo 'MA new' >> $testroot/stdout.expected
802 (cd $testroot/wt && got status -s M > $testroot/stdout)
803 cmp -s $testroot/stdout.expected $testroot/stdout
805 if [ $ret -ne 0 ]; then
806 diff -u $testroot/stdout.expected $testroot/stdout
807 test_done "$testroot" "$ret"
811 test_done "$testroot" "$ret"
814 test_status_suppress() {
815 local testroot=`test_init status_suppress`
817 got checkout $testroot/repo $testroot/wt > /dev/null
819 if [ $ret -ne 0 ]; then
820 test_done "$testroot" "$ret"
824 echo "modified alpha" > $testroot/wt/alpha
825 (cd $testroot/wt && got rm beta >/dev/null)
826 echo "unversioned file" > $testroot/wt/foo
827 rm $testroot/wt/epsilon/zeta
828 touch $testroot/wt/beta
829 echo "new file" > $testroot/wt/new
830 (cd $testroot/wt && got add new >/dev/null)
832 (cd $testroot/wt && got status -S A -s M \
833 > $testroot/stdout 2> $testroot/stderr)
835 if [ $ret -eq 0 ]; then
836 echo "status succeeded unexpectedly" >&2
837 test_done "$testroot" "1"
841 echo "got: -s and -S options are mutually exclusive" \
842 > $testroot/stderr.expected
843 cmp -s $testroot/stderr.expected $testroot/stderr
845 if [ $ret -ne 0 ]; then
846 diff -u $testroot/stderr.expected $testroot/stderr
847 test_done "$testroot" "$ret"
851 (cd $testroot/wt && got status -s A -S M \
852 > $testroot/stdout 2> $testroot/stderr)
854 if [ $ret -eq 0 ]; then
855 echo "status succeeded unexpectedly" >&2
856 test_done "$testroot" "1"
860 echo "got: -S and -s options are mutually exclusive" \
861 > $testroot/stderr.expected
862 cmp -s $testroot/stderr.expected $testroot/stderr
864 if [ $ret -ne 0 ]; then
865 diff -u $testroot/stderr.expected $testroot/stderr
866 test_done "$testroot" "$ret"
870 (cd $testroot/wt && got status -S xDM \
871 > $testroot/stdout 2> $testroot/stderr)
873 if [ $ret -eq 0 ]; then
874 echo "status succeeded unexpectedly" >&2
875 test_done "$testroot" "1"
879 echo "got: invalid status code 'x'" > $testroot/stderr.expected
880 cmp -s $testroot/stderr.expected $testroot/stderr
882 if [ $ret -ne 0 ]; then
883 diff -u $testroot/stderr.expected $testroot/stderr
884 test_done "$testroot" "$ret"
888 echo 'M alpha' > $testroot/stdout.expected
889 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
890 cmp -s $testroot/stdout.expected $testroot/stdout
892 if [ $ret -ne 0 ]; then
893 diff -u $testroot/stdout.expected $testroot/stdout
894 test_done "$testroot" "$ret"
898 echo 'D beta' > $testroot/stdout.expected
899 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
900 cmp -s $testroot/stdout.expected $testroot/stdout
902 if [ $ret -ne 0 ]; then
903 diff -u $testroot/stdout.expected $testroot/stdout
904 test_done "$testroot" "$ret"
908 echo '! epsilon/zeta' > $testroot/stdout.expected
909 echo '? foo' >> $testroot/stdout.expected
910 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
911 cmp -s $testroot/stdout.expected $testroot/stdout
913 if [ $ret -ne 0 ]; then
914 diff -u $testroot/stdout.expected $testroot/stdout
915 test_done "$testroot" "$ret"
919 echo 'A new' > $testroot/stdout.expected
920 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
921 cmp -s $testroot/stdout.expected $testroot/stdout
923 if [ $ret -ne 0 ]; then
924 diff -u $testroot/stdout.expected $testroot/stdout
925 test_done "$testroot" "$ret"
929 (cd $testroot/wt && got stage new > $testroot/stdout)
931 echo ' A new' > $testroot/stdout.expected
932 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
933 cmp -s $testroot/stdout.expected $testroot/stdout
935 if [ $ret -ne 0 ]; then
936 diff -u $testroot/stdout.expected $testroot/stdout
937 test_done "$testroot" "$ret"
941 echo 'changed file new' > $testroot/wt/new
943 echo 'M alpha' > $testroot/stdout.expected
944 echo 'MA new' >> $testroot/stdout.expected
945 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
946 cmp -s $testroot/stdout.expected $testroot/stdout
948 if [ $ret -ne 0 ]; then
949 diff -u $testroot/stdout.expected $testroot/stdout
950 test_done "$testroot" "$ret"
954 echo 'M alpha' > $testroot/stdout.expected
955 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
956 cmp -s $testroot/stdout.expected $testroot/stdout
958 if [ $ret -ne 0 ]; then
959 diff -u $testroot/stdout.expected $testroot/stdout
960 test_done "$testroot" "$ret"
964 rm $testroot/stdout.expected
965 touch $testroot/stdout.expected
967 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
968 cmp -s $testroot/stdout.expected $testroot/stdout
970 if [ $ret -ne 0 ]; then
971 diff -u $testroot/stdout.expected $testroot/stdout
972 test_done "$testroot" "$ret"
976 test_done "$testroot" "$ret"
979 test_status_empty_file() {
980 local testroot=`test_init status_empty_file`
982 got checkout $testroot/repo $testroot/wt > /dev/null
984 if [ $ret -ne 0 ]; then
985 test_done "$testroot" "$ret"
989 echo -n "" > $testroot/wt/empty
990 (cd $testroot/wt && got add empty >/dev/null)
992 echo 'A empty' > $testroot/stdout.expected
994 (cd $testroot/wt && got status > $testroot/stdout)
996 cmp -s $testroot/stdout.expected $testroot/stdout
998 if [ $ret -ne 0 ]; then
999 diff -u $testroot/stdout.expected $testroot/stdout
1000 test_done "$testroot" "$ret"
1004 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1006 (cd $testroot/wt && got status > $testroot/stdout)
1008 echo -n > $testroot/stdout.expected
1009 cmp -s $testroot/stdout.expected $testroot/stdout
1011 if [ $ret -ne 0 ]; then
1012 diff -u $testroot/stdout.expected $testroot/stdout
1013 test_done "$testroot" "$ret"
1017 # update the timestamp; this used to make the file show up as:
1019 # which should not happen
1020 touch $testroot/wt/empty
1022 (cd $testroot/wt && got status > $testroot/stdout)
1024 echo -n > $testroot/stdout.expected
1025 cmp -s $testroot/stdout.expected $testroot/stdout
1027 if [ $ret -ne 0 ]; then
1028 diff -u $testroot/stdout.expected $testroot/stdout
1030 test_done "$testroot" "$ret"
1034 run_test test_status_basic
1035 run_test test_status_subdir_no_mods
1036 run_test test_status_subdir_no_mods2
1037 run_test test_status_obstructed
1038 run_test test_status_shows_local_mods_after_update
1039 run_test test_status_unversioned_subdirs
1040 run_test test_status_symlink
1041 run_test test_status_shows_no_mods_after_complete_merge
1042 run_test test_status_shows_conflict
1043 run_test test_status_empty_dir
1044 run_test test_status_empty_dir_unversioned_file
1045 run_test test_status_many_paths
1046 run_test test_status_cvsignore
1047 run_test test_status_gitignore
1048 run_test test_status_status_code
1049 run_test test_status_suppress
1050 run_test test_status_empty_file