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 '' -e '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 '' -e '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 -sfT 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 '' -e '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 '' -e '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 '' -e '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 '' -e '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_gitignore_trailing_slashes() {
699 local testroot=`test_init status_gitignore_trailing_slashes`
701 got checkout $testroot/repo $testroot/wt > /dev/null
703 if [ $ret -ne 0 ]; then
704 test_done "$testroot" "$ret"
708 echo "unversioned file" > $testroot/wt/foo
709 echo "unversioned file" > $testroot/wt/epsilon/bar
710 echo "unversioned file" > $testroot/wt/epsilon/boo
711 echo "unversioned file" > $testroot/wt/epsilon/moo
712 echo "epsilon/" > $testroot/wt/.gitignore
714 echo '? .gitignore' > $testroot/stdout.expected
715 echo '? foo' >> $testroot/stdout.expected
716 (cd $testroot/wt && got status > $testroot/stdout)
718 cmp -s $testroot/stdout.expected $testroot/stdout
720 if [ $ret -ne 0 ]; then
721 diff -u $testroot/stdout.expected $testroot/stdout
722 test_done "$testroot" "xfail trailing slashes"
725 test_done "$testroot" "$ret"
728 test_status_status_code() {
729 local testroot=`test_init status_status_code`
731 got checkout $testroot/repo $testroot/wt > /dev/null
733 if [ $ret -ne 0 ]; then
734 test_done "$testroot" "$ret"
738 echo "modified alpha" > $testroot/wt/alpha
739 (cd $testroot/wt && got rm beta >/dev/null)
740 echo "unversioned file" > $testroot/wt/foo
741 rm $testroot/wt/epsilon/zeta
742 touch $testroot/wt/beta
743 echo "new file" > $testroot/wt/new
744 (cd $testroot/wt && got add new >/dev/null)
746 (cd $testroot/wt && got status -s xDM \
747 > $testroot/stdout 2> $testroot/stderr)
749 if [ $ret -eq 0 ]; then
750 echo "status succeeded unexpectedly" >&2
751 test_done "$testroot" "1"
755 echo "got: invalid status code 'x'" > $testroot/stderr.expected
756 cmp -s $testroot/stderr.expected $testroot/stderr
758 if [ $ret -ne 0 ]; then
759 diff -u $testroot/stderr.expected $testroot/stderr
760 test_done "$testroot" "$ret"
764 echo 'M alpha' > $testroot/stdout.expected
765 (cd $testroot/wt && got status -s M > $testroot/stdout)
766 cmp -s $testroot/stdout.expected $testroot/stdout
768 if [ $ret -ne 0 ]; then
769 diff -u $testroot/stdout.expected $testroot/stdout
770 test_done "$testroot" "$ret"
774 echo 'D beta' > $testroot/stdout.expected
775 (cd $testroot/wt && got status -s D > $testroot/stdout)
776 cmp -s $testroot/stdout.expected $testroot/stdout
778 if [ $ret -ne 0 ]; then
779 diff -u $testroot/stdout.expected $testroot/stdout
780 test_done "$testroot" "$ret"
784 echo '! epsilon/zeta' > $testroot/stdout.expected
785 echo '? foo' >> $testroot/stdout.expected
786 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
787 cmp -s $testroot/stdout.expected $testroot/stdout
789 if [ $ret -ne 0 ]; then
790 diff -u $testroot/stdout.expected $testroot/stdout
791 test_done "$testroot" "$ret"
795 echo 'A new' > $testroot/stdout.expected
796 (cd $testroot/wt && got status -s A > $testroot/stdout)
797 cmp -s $testroot/stdout.expected $testroot/stdout
799 if [ $ret -ne 0 ]; then
800 diff -u $testroot/stdout.expected $testroot/stdout
801 test_done "$testroot" "$ret"
805 (cd $testroot/wt && got stage new > $testroot/stdout)
807 echo ' A new' > $testroot/stdout.expected
808 (cd $testroot/wt && got status -s A > $testroot/stdout)
809 cmp -s $testroot/stdout.expected $testroot/stdout
811 if [ $ret -ne 0 ]; then
812 diff -u $testroot/stdout.expected $testroot/stdout
813 test_done "$testroot" "$ret"
817 echo 'changed file new' > $testroot/wt/new
819 echo 'MA new' > $testroot/stdout.expected
820 (cd $testroot/wt && got status -s A > $testroot/stdout)
821 cmp -s $testroot/stdout.expected $testroot/stdout
823 if [ $ret -ne 0 ]; then
824 diff -u $testroot/stdout.expected $testroot/stdout
825 test_done "$testroot" "$ret"
829 echo 'M alpha' > $testroot/stdout.expected
830 echo 'MA new' >> $testroot/stdout.expected
831 (cd $testroot/wt && got status -s M > $testroot/stdout)
832 cmp -s $testroot/stdout.expected $testroot/stdout
834 if [ $ret -ne 0 ]; then
835 diff -u $testroot/stdout.expected $testroot/stdout
836 test_done "$testroot" "$ret"
840 test_done "$testroot" "$ret"
843 test_status_suppress() {
844 local testroot=`test_init status_suppress`
846 got checkout $testroot/repo $testroot/wt > /dev/null
848 if [ $ret -ne 0 ]; then
849 test_done "$testroot" "$ret"
853 echo "modified alpha" > $testroot/wt/alpha
854 (cd $testroot/wt && got rm beta >/dev/null)
855 echo "unversioned file" > $testroot/wt/foo
856 rm $testroot/wt/epsilon/zeta
857 touch $testroot/wt/beta
858 echo "new file" > $testroot/wt/new
859 (cd $testroot/wt && got add new >/dev/null)
861 (cd $testroot/wt && got status -S A -s M \
862 > $testroot/stdout 2> $testroot/stderr)
864 if [ $ret -eq 0 ]; then
865 echo "status succeeded unexpectedly" >&2
866 test_done "$testroot" "1"
870 echo "got: -s and -S options are mutually exclusive" \
871 > $testroot/stderr.expected
872 cmp -s $testroot/stderr.expected $testroot/stderr
874 if [ $ret -ne 0 ]; then
875 diff -u $testroot/stderr.expected $testroot/stderr
876 test_done "$testroot" "$ret"
880 (cd $testroot/wt && got status -s A -S M \
881 > $testroot/stdout 2> $testroot/stderr)
883 if [ $ret -eq 0 ]; then
884 echo "status succeeded unexpectedly" >&2
885 test_done "$testroot" "1"
889 echo "got: -S and -s options are mutually exclusive" \
890 > $testroot/stderr.expected
891 cmp -s $testroot/stderr.expected $testroot/stderr
893 if [ $ret -ne 0 ]; then
894 diff -u $testroot/stderr.expected $testroot/stderr
895 test_done "$testroot" "$ret"
899 (cd $testroot/wt && got status -S xDM \
900 > $testroot/stdout 2> $testroot/stderr)
902 if [ $ret -eq 0 ]; then
903 echo "status succeeded unexpectedly" >&2
904 test_done "$testroot" "1"
908 echo "got: invalid status code 'x'" > $testroot/stderr.expected
909 cmp -s $testroot/stderr.expected $testroot/stderr
911 if [ $ret -ne 0 ]; then
912 diff -u $testroot/stderr.expected $testroot/stderr
913 test_done "$testroot" "$ret"
917 echo 'M alpha' > $testroot/stdout.expected
918 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
919 cmp -s $testroot/stdout.expected $testroot/stdout
921 if [ $ret -ne 0 ]; then
922 diff -u $testroot/stdout.expected $testroot/stdout
923 test_done "$testroot" "$ret"
927 echo 'D beta' > $testroot/stdout.expected
928 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
929 cmp -s $testroot/stdout.expected $testroot/stdout
931 if [ $ret -ne 0 ]; then
932 diff -u $testroot/stdout.expected $testroot/stdout
933 test_done "$testroot" "$ret"
937 echo '! epsilon/zeta' > $testroot/stdout.expected
938 echo '? foo' >> $testroot/stdout.expected
939 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
940 cmp -s $testroot/stdout.expected $testroot/stdout
942 if [ $ret -ne 0 ]; then
943 diff -u $testroot/stdout.expected $testroot/stdout
944 test_done "$testroot" "$ret"
948 echo 'A new' > $testroot/stdout.expected
949 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
950 cmp -s $testroot/stdout.expected $testroot/stdout
952 if [ $ret -ne 0 ]; then
953 diff -u $testroot/stdout.expected $testroot/stdout
954 test_done "$testroot" "$ret"
958 (cd $testroot/wt && got stage new > $testroot/stdout)
960 echo ' A new' > $testroot/stdout.expected
961 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
962 cmp -s $testroot/stdout.expected $testroot/stdout
964 if [ $ret -ne 0 ]; then
965 diff -u $testroot/stdout.expected $testroot/stdout
966 test_done "$testroot" "$ret"
970 echo 'changed file new' > $testroot/wt/new
972 echo 'M alpha' > $testroot/stdout.expected
973 echo 'MA new' >> $testroot/stdout.expected
974 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
975 cmp -s $testroot/stdout.expected $testroot/stdout
977 if [ $ret -ne 0 ]; then
978 diff -u $testroot/stdout.expected $testroot/stdout
979 test_done "$testroot" "$ret"
983 echo 'M alpha' > $testroot/stdout.expected
984 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
985 cmp -s $testroot/stdout.expected $testroot/stdout
987 if [ $ret -ne 0 ]; then
988 diff -u $testroot/stdout.expected $testroot/stdout
989 test_done "$testroot" "$ret"
993 rm $testroot/stdout.expected
994 touch $testroot/stdout.expected
996 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
997 cmp -s $testroot/stdout.expected $testroot/stdout
999 if [ $ret -ne 0 ]; then
1000 diff -u $testroot/stdout.expected $testroot/stdout
1001 test_done "$testroot" "$ret"
1005 test_done "$testroot" "$ret"
1008 test_status_empty_file() {
1009 local testroot=`test_init status_empty_file`
1011 got checkout $testroot/repo $testroot/wt > /dev/null
1013 if [ $ret -ne 0 ]; then
1014 test_done "$testroot" "$ret"
1018 echo -n "" > $testroot/wt/empty
1019 (cd $testroot/wt && got add empty >/dev/null)
1021 echo 'A empty' > $testroot/stdout.expected
1023 (cd $testroot/wt && got status > $testroot/stdout)
1025 cmp -s $testroot/stdout.expected $testroot/stdout
1027 if [ $ret -ne 0 ]; then
1028 diff -u $testroot/stdout.expected $testroot/stdout
1029 test_done "$testroot" "$ret"
1033 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1035 (cd $testroot/wt && got status > $testroot/stdout)
1037 echo -n > $testroot/stdout.expected
1038 cmp -s $testroot/stdout.expected $testroot/stdout
1040 if [ $ret -ne 0 ]; then
1041 diff -u $testroot/stdout.expected $testroot/stdout
1042 test_done "$testroot" "$ret"
1046 # update the timestamp; this used to make the file show up as:
1048 # which should not happen
1049 touch $testroot/wt/empty
1051 (cd $testroot/wt && got status > $testroot/stdout)
1053 echo -n > $testroot/stdout.expected
1054 cmp -s $testroot/stdout.expected $testroot/stdout
1056 if [ $ret -ne 0 ]; then
1057 diff -u $testroot/stdout.expected $testroot/stdout
1059 test_done "$testroot" "$ret"
1063 run_test test_status_basic
1064 run_test test_status_subdir_no_mods
1065 run_test test_status_subdir_no_mods2
1066 run_test test_status_obstructed
1067 run_test test_status_shows_local_mods_after_update
1068 run_test test_status_unversioned_subdirs
1069 run_test test_status_symlink
1070 run_test test_status_shows_no_mods_after_complete_merge
1071 run_test test_status_shows_conflict
1072 run_test test_status_empty_dir
1073 run_test test_status_empty_dir_unversioned_file
1074 run_test test_status_many_paths
1075 run_test test_status_cvsignore
1076 run_test test_status_gitignore
1077 run_test test_status_gitignore_trailing_slashes
1078 run_test test_status_status_code
1079 run_test test_status_suppress
1080 run_test test_status_empty_file