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 ed
-s $testroot/repo
/numbers
<<-\EOF
194 git_commit $testroot/repo -m "modified line 2"
196 # modify line 7; both changes should merge cleanly
197 ed -s $testroot/wt/numbers <<-\
EOF
202 echo "G numbers" > $testroot/stdout.expected
203 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
204 git_show_head $testroot/repo >> $testroot/stdout.expected
205 echo >> $testroot/stdout.expected
207 (cd $testroot/wt && got update > $testroot/stdout)
209 cmp -s $testroot/stdout.expected $testroot/stdout
211 if [ $ret -ne 0 ]; then
212 diff -u $testroot/stdout.expected $testroot/stdout
213 test_done "$testroot" "$ret"
217 echo 'M numbers' > $testroot/stdout.expected
219 (cd $testroot/wt && got status > $testroot/stdout)
221 cmp -s $testroot/stdout.expected $testroot/stdout
223 if [ $ret -ne 0 ]; then
224 diff -u $testroot/stdout.expected $testroot/stdout
226 test_done "$testroot" "$ret"
229 test_status_unversioned_subdirs() {
230 local testroot=`test_init status_unversioned_subdirs 1`
232 mkdir $testroot/repo/cdfs/
233 touch $testroot/repo/cdfs/Makefile
234 mkdir $testroot/repo/common/
235 touch $testroot/repo/common/Makefile
236 mkdir $testroot/repo/iso/
237 touch $testroot/repo/iso/Makefile
238 mkdir $testroot/repo/ramdisk/
239 touch $testroot/repo/ramdisk/Makefile
240 touch $testroot/repo/ramdisk/list.local
241 mkdir $testroot/repo/ramdisk_cd/
242 touch $testroot/repo/ramdisk_cd/Makefile
243 touch $testroot/repo/ramdisk_cd/list.local
244 (cd $testroot/repo && git add .)
245 git_commit $testroot/repo -m "first commit"
247 got checkout $testroot/repo $testroot/wt > /dev/null
249 if [ $ret -ne 0 ]; then
250 test_done "$testroot" "$ret"
254 mkdir $testroot/wt/cdfs/obj
255 mkdir $testroot/wt/ramdisk/obj
256 mkdir $testroot/wt/ramdisk_cd/obj
257 mkdir $testroot/wt/iso/obj
259 echo -n > $testroot/stdout.expected
261 # This used to erroneously print:
263 # ! ramdisk_cd/Makefile
264 # ! ramdisk_cd/list.local
265 # ? ramdisk_cd/Makefile
266 # ? ramdisk_cd/list.local
267 (cd $testroot/wt && got status > $testroot/stdout)
269 cmp -s $testroot/stdout.expected $testroot/stdout
271 if [ $ret -ne 0 ]; then
272 diff -u $testroot/stdout.expected $testroot/stdout
274 test_done "$testroot" "$ret"
277 test_status_symlink() {
278 local testroot=`test_init status_symlink`
280 mkdir $testroot/repo/ramdisk/
281 touch $testroot/repo/ramdisk/Makefile
282 (cd $testroot/repo && ln -s alpha alpha.link)
283 (cd $testroot/repo && ln -s epsilon epsilon.link)
284 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
285 (cd $testroot/repo && git add .)
286 git_commit $testroot/repo -m "first commit"
288 got checkout $testroot/repo $testroot/wt > /dev/null
290 if [ $ret -ne 0 ]; then
291 test_done "$testroot" "$ret"
295 ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
297 echo "? ramdisk/obj" > $testroot/stdout.expected
299 (cd $testroot/wt && got status > $testroot/stdout)
301 cmp -s $testroot/stdout.expected $testroot/stdout
303 if [ $ret -ne 0 ]; then
304 diff -u $testroot/stdout.expected $testroot/stdout
305 test_done "$testroot" "$ret"
309 (cd $testroot/wt && ln -sf beta alpha.link)
310 (cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
312 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
313 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
314 (cd $testroot/wt && got add passwd.link epsilon/beta.link > /dev/null)
316 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
318 echo 'M alpha.link' > $testroot/stdout.expected
319 echo 'A epsilon/beta.link' >> $testroot/stdout.expected
320 echo 'M epsilon.link' >> $testroot/stdout.expected
321 echo 'D nonexistent.link' >> $testroot/stdout.expected
322 echo 'A passwd.link' >> $testroot/stdout.expected
323 echo "? ramdisk/obj" >> $testroot/stdout.expected
325 (cd $testroot/wt && got status > $testroot/stdout)
327 cmp -s $testroot/stdout.expected $testroot/stdout
329 if [ $ret -ne 0 ]; then
330 diff -u $testroot/stdout.expected $testroot/stdout
332 test_done "$testroot" "$ret"
335 test_status_shows_no_mods_after_complete_merge() {
336 local testroot=`test_init status_shows_no_mods_after_complete_merge 1`
338 # make this file larger than the usual blob buffer size of 8192
339 jot 16384 > $testroot/repo/numbers
341 (cd $testroot/repo && git add numbers)
342 git_commit $testroot/repo -m "added numbers file"
344 got checkout $testroot/repo $testroot/wt > /dev/null
346 if [ $ret -ne 0 ]; then
347 test_done "$testroot" "$ret"
351 ed -s $testroot/repo/numbers <<-\EOF
355 git_commit $testroot/repo -m "modified line 2"
357 # modify line 2 again; no local changes are left after merge
358 ed -s $testroot/wt/numbers <<-\EOF
363 echo "G numbers" > $testroot/stdout.expected
364 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
365 git_show_head $testroot/repo >> $testroot/stdout.expected
366 echo >> $testroot/stdout.expected
368 (cd $testroot/wt && got update > $testroot/stdout)
370 cmp -s $testroot/stdout.expected $testroot/stdout
372 if [ $ret -ne 0 ]; then
373 diff -u $testroot/stdout.expected $testroot/stdout
374 test_done "$testroot" "$ret"
378 echo -n > $testroot/stdout.expected
380 (cd $testroot/wt && got status > $testroot/stdout)
382 cmp -s $testroot/stdout.expected $testroot/stdout
384 if [ $ret -ne 0 ]; then
385 diff -u $testroot/stdout.expected $testroot/stdout
387 test_done "$testroot" "$ret"
390 test_status_shows_conflict() {
391 local testroot=`test_init status_shows_conflict 1`
393 echo "1" > $testroot/repo/numbers
394 echo "2" >> $testroot/repo/numbers
395 echo "3" >> $testroot/repo/numbers
396 echo "4" >> $testroot/repo/numbers
397 echo "5" >> $testroot/repo/numbers
398 echo "6" >> $testroot/repo/numbers
399 echo "7" >> $testroot/repo/numbers
400 echo "8" >> $testroot/repo/numbers
401 (cd $testroot/repo && git add numbers)
402 git_commit $testroot/repo -m "added numbers file"
404 got checkout $testroot/repo $testroot/wt > /dev/null
406 if [ $ret -ne 0 ]; then
407 test_done "$testroot" "$ret"
411 ed -s $testroot/repo/numbers <<-\EOF
415 git_commit $testroot/repo -m "modified line 2"
417 # modify line 2 in a conflicting way
418 ed -s $testroot/wt/numbers <<-\EOF
423 echo "C numbers" > $testroot/stdout.expected
424 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
425 git_show_head $testroot/repo >> $testroot/stdout.expected
426 echo >> $testroot/stdout.expected
427 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
429 (cd $testroot/wt && got update > $testroot/stdout)
431 cmp -s $testroot/stdout.expected $testroot/stdout
433 if [ $ret -ne 0 ]; then
434 diff -u $testroot/stdout.expected $testroot/stdout
435 test_done "$testroot" "$ret"
439 echo 'C numbers' > $testroot/stdout.expected
441 (cd $testroot/wt && got status > $testroot/stdout)
443 cmp -s $testroot/stdout.expected $testroot/stdout
445 if [ $ret -ne 0 ]; then
446 diff -u $testroot/stdout.expected $testroot/stdout
448 test_done "$testroot" "$ret"
451 test_status_empty_dir() {
452 local testroot=`test_init status_empty_dir`
454 got checkout $testroot/repo $testroot/wt > /dev/null
456 if [ $ret -ne 0 ]; then
457 test_done "$testroot" "$ret"
461 rm $testroot/wt/epsilon/zeta
463 echo '! epsilon/zeta' > $testroot/stdout.expected
465 (cd $testroot/wt && got status epsilon > $testroot/stdout)
467 cmp -s $testroot/stdout.expected $testroot/stdout
469 if [ $ret -ne 0 ]; then
470 diff -u $testroot/stdout.expected $testroot/stdout
472 test_done "$testroot" "$ret"
475 test_status_empty_dir_unversioned_file() {
476 local testroot=`test_init status_empty_dir_unversioned_file`
478 got checkout $testroot/repo $testroot/wt > /dev/null
480 if [ $ret -ne 0 ]; then
481 test_done "$testroot" "$ret"
485 rm $testroot/wt/epsilon/zeta
486 touch $testroot/wt/epsilon/unversioned
488 echo '? epsilon/unversioned' > $testroot/stdout.expected
489 echo '! epsilon/zeta' >> $testroot/stdout.expected
491 (cd $testroot/wt && got status epsilon > $testroot/stdout)
493 cmp -s $testroot/stdout.expected $testroot/stdout
495 if [ $ret -ne 0 ]; then
496 diff -u $testroot/stdout.expected $testroot/stdout
498 test_done "$testroot" "$ret"
501 test_status_many_paths() {
502 local testroot=`test_init status_many_paths`
504 got checkout $testroot/repo $testroot/wt > /dev/null
506 if [ $ret -ne 0 ]; then
507 test_done "$testroot" "$ret"
511 echo "modified alpha" > $testroot/wt/alpha
512 (cd $testroot/wt && got rm beta >/dev/null)
513 echo "unversioned file" > $testroot/wt/foo
514 rm $testroot/wt/epsilon/zeta
515 touch $testroot/wt/beta
516 echo "new file" > $testroot/wt/new
517 mkdir $testroot/wt/newdir
518 (cd $testroot/wt && got add new >/dev/null)
520 (cd $testroot/wt && got status alpha > $testroot/stdout.expected)
521 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
522 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
523 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
524 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
525 (cd $testroot/wt && got status newdir >> $testroot/stdout.expected)
526 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
528 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
531 cmp -s $testroot/stdout.expected $testroot/stdout
533 if [ $ret -ne 0 ]; then
534 diff -u $testroot/stdout.expected $testroot/stdout
536 test_done "$testroot" "$ret"
539 test_status_cvsignore() {
540 local testroot=`test_init status_cvsignore`
542 got checkout $testroot/repo $testroot/wt > /dev/null
544 if [ $ret -ne 0 ]; then
545 test_done "$testroot" "$ret"
549 echo "unversioned file" > $testroot/wt/foo
550 echo "unversioned file" > $testroot/wt/foop
551 echo "unversioned file" > $testroot/wt/epsilon/foo
552 echo "unversioned file" > $testroot/wt/epsilon/bar
553 echo "unversioned file" > $testroot/wt/epsilon/boo
554 echo "unversioned file" > $testroot/wt/epsilon/moo
555 mkdir -p $testroot/wt/epsilon/new/
556 echo "unversioned file" > $testroot/wt/epsilon/new/foo
557 echo "**/foo" > $testroot/wt/.cvsignore
558 echo "**/gamma" >> $testroot/wt/.cvsignore
559 echo "bar" > $testroot/wt/epsilon/.cvsignore
560 echo "moo" >> $testroot/wt/epsilon/.cvsignore
562 echo '? .cvsignore' > $testroot/stdout.expected
563 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
564 echo '? epsilon/boo' >> $testroot/stdout.expected
565 echo '? foop' >> $testroot/stdout.expected
566 (cd $testroot/wt && got status > $testroot/stdout)
568 cmp -s $testroot/stdout.expected $testroot/stdout
570 if [ $ret -ne 0 ]; then
571 diff -u $testroot/stdout.expected $testroot/stdout
572 test_done "$testroot" "$ret"
576 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
577 echo '? epsilon/boo' >> $testroot/stdout.expected
578 (cd $testroot/wt && got status epsilon > $testroot/stdout)
580 cmp -s $testroot/stdout.expected $testroot/stdout
582 if [ $ret -ne 0 ]; then
583 diff -u $testroot/stdout.expected $testroot/stdout
584 test_done "$testroot" "$ret"
588 echo -n '' > $testroot/stdout.expected
589 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
591 cmp -s $testroot/stdout.expected $testroot/stdout
593 if [ $ret -ne 0 ]; then
594 diff -u $testroot/stdout.expected $testroot/stdout
595 test_done "$testroot" "$ret"
599 echo '? .cvsignore' > $testroot/stdout.expected
600 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
601 echo '? epsilon/boo' >> $testroot/stdout.expected
602 echo '? foop' >> $testroot/stdout.expected
603 (cd $testroot/wt/gamma && got status > $testroot/stdout)
605 cmp -s $testroot/stdout.expected $testroot/stdout
607 if [ $ret -ne 0 ]; then
608 diff -u $testroot/stdout.expected $testroot/stdout
609 test_done "$testroot" "$ret"
613 cat > $testroot/stdout.expected <<EOF
624 (cd $testroot/wt && got status -I > $testroot/stdout)
626 if [ $ret -ne 0 ]; then
627 echo "got status failed unexpectedly" >&2
628 test_done "$testroot" "1"
632 cmp -s $testroot/stdout.expected $testroot/stdout
634 if [ $ret -ne 0 ]; then
635 diff -u $testroot/stdout.expected $testroot/stdout
637 test_done "$testroot" "$ret"
640 test_status_gitignore() {
641 local testroot=`test_init status_gitignore`
643 got checkout $testroot/repo $testroot/wt > /dev/null
645 if [ $ret -ne 0 ]; then
646 test_done "$testroot" "$ret"
650 echo "unversioned file" > $testroot/wt/foo
651 echo "unversioned file" > $testroot/wt/foop
652 echo "unversioned file" > $testroot/wt/barp
653 echo "unversioned file" > $testroot/wt/epsilon/bar
654 echo "unversioned file" > $testroot/wt/epsilon/boo
655 echo "unversioned file" > $testroot/wt/epsilon/moo
656 mkdir -p $testroot/wt/a/b/c/
657 echo "unversioned file" > $testroot/wt/a/b/c/foo
658 echo "unversioned file" > $testroot/wt/a/b/c/zoo
659 echo "foo" > $testroot/wt/.gitignore
660 echo "bar*" >> $testroot/wt/.gitignore
661 echo "epsilon/**" >> $testroot/wt/.gitignore
662 echo "a/**/foo" >> $testroot/wt/.gitignore
663 echo "**/zoo" >> $testroot/wt/.gitignore
665 echo '? .gitignore' > $testroot/stdout.expected
666 echo '? foop' >> $testroot/stdout.expected
667 (cd $testroot/wt && got status > $testroot/stdout)
669 cmp -s $testroot/stdout.expected $testroot/stdout
671 if [ $ret -ne 0 ]; then
672 diff -u $testroot/stdout.expected $testroot/stdout
673 test_done "$testroot" "$ret"
677 echo '? .gitignore' > $testroot/stdout.expected
678 echo '? foop' >> $testroot/stdout.expected
679 (cd $testroot/wt/gamma && got status > $testroot/stdout)
681 cmp -s $testroot/stdout.expected $testroot/stdout
683 if [ $ret -ne 0 ]; then
684 diff -u $testroot/stdout.expected $testroot/stdout
685 test_done "$testroot" "$ret"
689 cat > $testroot/stdout.expected <<EOF
700 (cd $testroot/wt && got status -I > $testroot/stdout)
702 if [ $ret -ne 0 ]; then
703 echo "got status failed unexpectedly" >&2
704 test_done "$testroot" "1"
708 cmp -s $testroot/stdout.expected $testroot/stdout
710 if [ $ret -ne 0 ]; then
711 diff -u $testroot/stdout.expected $testroot/stdout
713 test_done "$testroot" "$ret"
716 test_status_gitignore_trailing_slashes() {
717 local testroot=`test_init status_gitignore_trailing_slashes`
719 got checkout $testroot/repo $testroot/wt > /dev/null
721 if [ $ret -ne 0 ]; then
722 test_done "$testroot" "$ret"
726 echo "unversioned file" > $testroot/wt/foo
727 echo "unversioned file" > $testroot/wt/epsilon/bar
728 echo "unversioned file" > $testroot/wt/epsilon/boo
729 echo "unversioned file" > $testroot/wt/epsilon/moo
730 echo "unversioned file" > $testroot/wt/upsilon
732 # Match the directory epsilon but not the regular file upsilon
733 echo "*psilon/" > $testroot/wt/.gitignore
735 echo '? .gitignore' > $testroot/stdout.expected
736 echo '? foo' >> $testroot/stdout.expected
737 echo '? upsilon' >> $testroot/stdout.expected
738 (cd $testroot/wt && got status > $testroot/stdout)
740 cmp -s $testroot/stdout.expected $testroot/stdout
742 if [ $ret -ne 0 ]; then
743 diff -u $testroot/stdout.expected $testroot/stdout
745 test_done "$testroot" "$ret"
748 test_status_status_code() {
749 local testroot=`test_init status_status_code`
751 got checkout $testroot/repo $testroot/wt > /dev/null
753 if [ $ret -ne 0 ]; then
754 test_done "$testroot" "$ret"
758 echo "modified alpha" > $testroot/wt/alpha
759 (cd $testroot/wt && got rm beta >/dev/null)
760 echo "unversioned file" > $testroot/wt/foo
761 rm $testroot/wt/epsilon/zeta
762 touch $testroot/wt/beta
763 echo "new file" > $testroot/wt/new
764 (cd $testroot/wt && got add new >/dev/null)
766 (cd $testroot/wt && got status -s xDM \
767 > $testroot/stdout 2> $testroot/stderr)
769 if [ $ret -eq 0 ]; then
770 echo "status succeeded unexpectedly" >&2
771 test_done "$testroot" "1"
775 echo "got: invalid status code 'x'" > $testroot/stderr.expected
776 cmp -s $testroot/stderr.expected $testroot/stderr
778 if [ $ret -ne 0 ]; then
779 diff -u $testroot/stderr.expected $testroot/stderr
780 test_done "$testroot" "$ret"
784 echo 'M alpha' > $testroot/stdout.expected
785 (cd $testroot/wt && got status -s M > $testroot/stdout)
786 cmp -s $testroot/stdout.expected $testroot/stdout
788 if [ $ret -ne 0 ]; then
789 diff -u $testroot/stdout.expected $testroot/stdout
790 test_done "$testroot" "$ret"
794 echo 'D beta' > $testroot/stdout.expected
795 (cd $testroot/wt && got status -s D > $testroot/stdout)
796 cmp -s $testroot/stdout.expected $testroot/stdout
798 if [ $ret -ne 0 ]; then
799 diff -u $testroot/stdout.expected $testroot/stdout
800 test_done "$testroot" "$ret"
804 echo '! epsilon/zeta' > $testroot/stdout.expected
805 echo '? foo' >> $testroot/stdout.expected
806 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
807 cmp -s $testroot/stdout.expected $testroot/stdout
809 if [ $ret -ne 0 ]; then
810 diff -u $testroot/stdout.expected $testroot/stdout
811 test_done "$testroot" "$ret"
815 echo 'A new' > $testroot/stdout.expected
816 (cd $testroot/wt && got status -s A > $testroot/stdout)
817 cmp -s $testroot/stdout.expected $testroot/stdout
819 if [ $ret -ne 0 ]; then
820 diff -u $testroot/stdout.expected $testroot/stdout
821 test_done "$testroot" "$ret"
825 (cd $testroot/wt && got stage new > $testroot/stdout)
827 echo ' A new' > $testroot/stdout.expected
828 (cd $testroot/wt && got status -s A > $testroot/stdout)
829 cmp -s $testroot/stdout.expected $testroot/stdout
831 if [ $ret -ne 0 ]; then
832 diff -u $testroot/stdout.expected $testroot/stdout
833 test_done "$testroot" "$ret"
837 echo 'changed file new' > $testroot/wt/new
839 echo 'MA new' > $testroot/stdout.expected
840 (cd $testroot/wt && got status -s A > $testroot/stdout)
841 cmp -s $testroot/stdout.expected $testroot/stdout
843 if [ $ret -ne 0 ]; then
844 diff -u $testroot/stdout.expected $testroot/stdout
845 test_done "$testroot" "$ret"
849 echo 'M alpha' > $testroot/stdout.expected
850 echo 'MA new' >> $testroot/stdout.expected
851 (cd $testroot/wt && got status -s M > $testroot/stdout)
852 cmp -s $testroot/stdout.expected $testroot/stdout
854 if [ $ret -ne 0 ]; then
855 diff -u $testroot/stdout.expected $testroot/stdout
856 test_done "$testroot" "$ret"
860 test_done "$testroot" "$ret"
863 test_status_suppress() {
864 local testroot=`test_init status_suppress`
866 got checkout $testroot/repo $testroot/wt > /dev/null
868 if [ $ret -ne 0 ]; then
869 test_done "$testroot" "$ret"
873 echo "modified alpha" > $testroot/wt/alpha
874 (cd $testroot/wt && got rm beta >/dev/null)
875 echo "unversioned file" > $testroot/wt/foo
876 rm $testroot/wt/epsilon/zeta
877 touch $testroot/wt/beta
878 echo "new file" > $testroot/wt/new
879 (cd $testroot/wt && got add new >/dev/null)
881 (cd $testroot/wt && got status -S A -s M \
882 > $testroot/stdout 2> $testroot/stderr)
884 if [ $ret -eq 0 ]; then
885 echo "status succeeded unexpectedly" >&2
886 test_done "$testroot" "1"
890 echo "got: -s and -S options are mutually exclusive" \
891 > $testroot/stderr.expected
892 cmp -s $testroot/stderr.expected $testroot/stderr
894 if [ $ret -ne 0 ]; then
895 diff -u $testroot/stderr.expected $testroot/stderr
896 test_done "$testroot" "$ret"
900 (cd $testroot/wt && got status -s A -S M \
901 > $testroot/stdout 2> $testroot/stderr)
903 if [ $ret -eq 0 ]; then
904 echo "status succeeded unexpectedly" >&2
905 test_done "$testroot" "1"
909 echo "got: -S and -s options are mutually exclusive" \
910 > $testroot/stderr.expected
911 cmp -s $testroot/stderr.expected $testroot/stderr
913 if [ $ret -ne 0 ]; then
914 diff -u $testroot/stderr.expected $testroot/stderr
915 test_done "$testroot" "$ret"
919 (cd $testroot/wt && got status -S xDM \
920 > $testroot/stdout 2> $testroot/stderr)
922 if [ $ret -eq 0 ]; then
923 echo "status succeeded unexpectedly" >&2
924 test_done "$testroot" "1"
928 echo "got: invalid status code 'x'" > $testroot/stderr.expected
929 cmp -s $testroot/stderr.expected $testroot/stderr
931 if [ $ret -ne 0 ]; then
932 diff -u $testroot/stderr.expected $testroot/stderr
933 test_done "$testroot" "$ret"
937 echo 'M alpha' > $testroot/stdout.expected
938 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
939 cmp -s $testroot/stdout.expected $testroot/stdout
941 if [ $ret -ne 0 ]; then
942 diff -u $testroot/stdout.expected $testroot/stdout
943 test_done "$testroot" "$ret"
947 echo 'D beta' > $testroot/stdout.expected
948 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
949 cmp -s $testroot/stdout.expected $testroot/stdout
951 if [ $ret -ne 0 ]; then
952 diff -u $testroot/stdout.expected $testroot/stdout
953 test_done "$testroot" "$ret"
957 echo '! epsilon/zeta' > $testroot/stdout.expected
958 echo '? foo' >> $testroot/stdout.expected
959 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
960 cmp -s $testroot/stdout.expected $testroot/stdout
962 if [ $ret -ne 0 ]; then
963 diff -u $testroot/stdout.expected $testroot/stdout
964 test_done "$testroot" "$ret"
968 echo 'A new' > $testroot/stdout.expected
969 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
970 cmp -s $testroot/stdout.expected $testroot/stdout
972 if [ $ret -ne 0 ]; then
973 diff -u $testroot/stdout.expected $testroot/stdout
974 test_done "$testroot" "$ret"
978 (cd $testroot/wt && got stage new > $testroot/stdout)
980 echo ' A new' > $testroot/stdout.expected
981 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
982 cmp -s $testroot/stdout.expected $testroot/stdout
984 if [ $ret -ne 0 ]; then
985 diff -u $testroot/stdout.expected $testroot/stdout
986 test_done "$testroot" "$ret"
990 echo 'changed file new' > $testroot/wt/new
992 echo 'M alpha' > $testroot/stdout.expected
993 echo 'MA new' >> $testroot/stdout.expected
994 (cd $testroot/wt && got status -S D\?! > $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 echo 'M alpha' > $testroot/stdout.expected
1004 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
1005 cmp -s $testroot/stdout.expected $testroot/stdout
1007 if [ $ret -ne 0 ]; then
1008 diff -u $testroot/stdout.expected $testroot/stdout
1009 test_done "$testroot" "$ret"
1013 rm $testroot/stdout.expected
1014 touch $testroot/stdout.expected
1016 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
1017 cmp -s $testroot/stdout.expected $testroot/stdout
1019 if [ $ret -ne 0 ]; then
1020 diff -u $testroot/stdout.expected $testroot/stdout
1021 test_done "$testroot" "$ret"
1025 test_done "$testroot" "$ret"
1028 test_status_empty_file() {
1029 local testroot=`test_init status_empty_file`
1031 got checkout $testroot/repo $testroot/wt > /dev/null
1033 if [ $ret -ne 0 ]; then
1034 test_done "$testroot" "$ret"
1038 echo -n "" > $testroot/wt/empty
1039 (cd $testroot/wt && got add empty >/dev/null)
1041 echo 'A empty' > $testroot/stdout.expected
1043 (cd $testroot/wt && got status > $testroot/stdout)
1045 cmp -s $testroot/stdout.expected $testroot/stdout
1047 if [ $ret -ne 0 ]; then
1048 diff -u $testroot/stdout.expected $testroot/stdout
1049 test_done "$testroot" "$ret"
1053 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1055 (cd $testroot/wt && got status > $testroot/stdout)
1057 echo -n > $testroot/stdout.expected
1058 cmp -s $testroot/stdout.expected $testroot/stdout
1060 if [ $ret -ne 0 ]; then
1061 diff -u $testroot/stdout.expected $testroot/stdout
1062 test_done "$testroot" "$ret"
1066 # update the timestamp; this used to make the file show up as:
1068 # which should not happen
1069 touch $testroot/wt/empty
1071 (cd $testroot/wt && got status > $testroot/stdout)
1073 echo -n > $testroot/stdout.expected
1074 cmp -s $testroot/stdout.expected $testroot/stdout
1076 if [ $ret -ne 0 ]; then
1077 diff -u $testroot/stdout.expected $testroot/stdout
1079 test_done "$testroot" "$ret"
1082 test_status_in_repo() {
1083 local testroot=`test_init status_in_repo`
1085 (cd $testroot/repo && got status > $testroot/stdout \
1086 2> $testroot/stderr)
1088 cat > $testroot/stderr.expected <<EOF
1089 got: 'got status' needs a work tree in addition to a git repository
1090 Work trees can be checked out from this Git repository with 'got checkout'.
1091 The got(1) manual page contains more information.
1093 cmp -s $testroot/stderr.expected $testroot/stderr
1095 if [ $ret -ne 0 ]; then
1096 diff -u $testroot/stderr.expected $testroot/stderr
1098 test_done "$testroot" "$ret"
1102 run_test test_status_basic
1103 run_test test_status_subdir_no_mods
1104 run_test test_status_subdir_no_mods2
1105 run_test test_status_obstructed
1106 run_test test_status_shows_local_mods_after_update
1107 run_test test_status_unversioned_subdirs
1108 run_test test_status_symlink
1109 run_test test_status_shows_no_mods_after_complete_merge
1110 run_test test_status_shows_conflict
1111 run_test test_status_empty_dir
1112 run_test test_status_empty_dir_unversioned_file
1113 run_test test_status_many_paths
1114 run_test test_status_cvsignore
1115 run_test test_status_gitignore
1116 run_test test_status_gitignore_trailing_slashes
1117 run_test test_status_status_code
1118 run_test test_status_suppress
1119 run_test test_status_empty_file
1120 run_test test_status_in_repo