Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
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.
8 #
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.
17 . ./common.sh
19 test_status_basic() {
20 local testroot=`test_init status_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret=$?
24 if [ $ret -ne 0 ]; then
25 test_done "$testroot" "$ret"
26 return 1
27 fi
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
47 ret=$?
48 if [ $ret -ne 0 ]; then
49 diff -u $testroot/stdout.expected $testroot/stdout
50 fi
51 chmod 700 $testroot/wt/bar
52 rmdir $testroot/wt/bar
53 test_done "$testroot" "$ret"
54 }
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
68 ret=$?
69 if [ $ret -ne 0 ]; then
70 test_done "$testroot" "$ret"
71 return 1
72 fi
74 touch $testroot/stdout.expected
76 # This used to erroneously print:
77 #
78 # ! Basic/Targets.cpp
79 # ? Basic/Targets.cpp
80 (cd $testroot/wt && got status > $testroot/stdout)
82 cmp -s $testroot/stdout.expected $testroot/stdout
83 ret=$?
84 if [ $ret -ne 0 ]; then
85 diff -u $testroot/stdout.expected $testroot/stdout
86 fi
87 test_done "$testroot" "$ret"
88 }
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
108 ret=$?
109 if [ $ret -ne 0 ]; then
110 test_done "$testroot" "$ret"
111 return 1
112 fi
114 touch $testroot/stdout.expected
116 # This used to erroneously print:
118 # ! AST/APValue.cpp
119 # ? AST/APValue.cpp
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
127 ret=$?
128 if [ $ret -ne 0 ]; then
129 diff -u $testroot/stdout.expected $testroot/stdout
130 fi
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
138 ret=$?
139 if [ $ret -ne 0 ]; then
140 test_done "$testroot" "$ret"
141 return 1
142 fi
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
152 ret=$?
153 if [ $ret -ne 0 ]; then
154 diff -u $testroot/stdout.expected $testroot/stdout
155 test_done "$testroot" "$ret"
156 return 1
157 fi
159 (cd $testroot/wt && got status epsilon/zeta > $testroot/stdout)
161 cmp -s $testroot/stdout.expected $testroot/stdout
162 ret=$?
163 if [ $ret -ne 0 ]; then
164 diff -u $testroot/stdout.expected $testroot/stdout
165 fi
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
184 ret=$?
185 if [ $ret -ne 0 ]; then
186 test_done "$testroot" "$ret"
187 return 1
188 fi
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
204 ret=$?
205 if [ $ret -ne 0 ]; then
206 diff -u $testroot/stdout.expected $testroot/stdout
207 test_done "$testroot" "$ret"
208 return 1
209 fi
211 echo 'M numbers' > $testroot/stdout.expected
213 (cd $testroot/wt && got status > $testroot/stdout)
215 cmp -s $testroot/stdout.expected $testroot/stdout
216 ret=$?
217 if [ $ret -ne 0 ]; then
218 diff -u $testroot/stdout.expected $testroot/stdout
219 fi
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
242 ret=$?
243 if [ $ret -ne 0 ]; then
244 test_done "$testroot" "$ret"
245 return 1
246 fi
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
264 ret=$?
265 if [ $ret -ne 0 ]; then
266 diff -u $testroot/stdout.expected $testroot/stdout
267 fi
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
283 ret=$?
284 if [ $ret -ne 0 ]; then
285 test_done "$testroot" "$ret"
286 return 1
287 fi
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
296 ret=$?
297 if [ $ret -ne 0 ]; then
298 diff -u $testroot/stdout.expected $testroot/stdout
299 test_done "$testroot" "$ret"
300 return 1
301 fi
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
322 ret=$?
323 if [ $ret -ne 0 ]; then
324 diff -u $testroot/stdout.expected $testroot/stdout
325 fi
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
339 ret=$?
340 if [ $ret -ne 0 ]; then
341 test_done "$testroot" "$ret"
342 return 1
343 fi
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
359 ret=$?
360 if [ $ret -ne 0 ]; then
361 diff -u $testroot/stdout.expected $testroot/stdout
362 test_done "$testroot" "$ret"
363 return 1
364 fi
366 echo -n > $testroot/stdout.expected
368 (cd $testroot/wt && got status > $testroot/stdout)
370 cmp -s $testroot/stdout.expected $testroot/stdout
371 ret=$?
372 if [ $ret -ne 0 ]; then
373 diff -u $testroot/stdout.expected $testroot/stdout
374 fi
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
393 ret=$?
394 if [ $ret -ne 0 ]; then
395 test_done "$testroot" "$ret"
396 return 1
397 fi
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
414 ret=$?
415 if [ $ret -ne 0 ]; then
416 diff -u $testroot/stdout.expected $testroot/stdout
417 test_done "$testroot" "$ret"
418 return 1
419 fi
421 echo 'C numbers' > $testroot/stdout.expected
423 (cd $testroot/wt && got status > $testroot/stdout)
425 cmp -s $testroot/stdout.expected $testroot/stdout
426 ret=$?
427 if [ $ret -ne 0 ]; then
428 diff -u $testroot/stdout.expected $testroot/stdout
429 fi
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
437 ret=$?
438 if [ $ret -ne 0 ]; then
439 test_done "$testroot" "$ret"
440 return 1
441 fi
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
450 ret=$?
451 if [ $ret -ne 0 ]; then
452 diff -u $testroot/stdout.expected $testroot/stdout
453 fi
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
461 ret=$?
462 if [ $ret -ne 0 ]; then
463 test_done "$testroot" "$ret"
464 return 1
465 fi
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
476 ret=$?
477 if [ $ret -ne 0 ]; then
478 diff -u $testroot/stdout.expected $testroot/stdout
479 fi
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
487 ret=$?
488 if [ $ret -ne 0 ]; then
489 test_done "$testroot" "$ret"
490 return 1
491 fi
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 . \
511 > $testroot/stdout)
513 cmp -s $testroot/stdout.expected $testroot/stdout
514 ret=$?
515 if [ $ret -ne 0 ]; then
516 diff -u $testroot/stdout.expected $testroot/stdout
517 fi
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
525 ret=$?
526 if [ $ret -ne 0 ]; then
527 test_done "$testroot" "$ret"
528 return 1
529 fi
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
551 ret=$?
552 if [ $ret -ne 0 ]; then
553 diff -u $testroot/stdout.expected $testroot/stdout
554 test_done "$testroot" "$ret"
555 return 1
556 fi
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
563 ret=$?
564 if [ $ret -ne 0 ]; then
565 diff -u $testroot/stdout.expected $testroot/stdout
566 test_done "$testroot" "$ret"
567 return 1
568 fi
570 echo -n '' > $testroot/stdout.expected
571 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
573 cmp -s $testroot/stdout.expected $testroot/stdout
574 ret=$?
575 if [ $ret -ne 0 ]; then
576 diff -u $testroot/stdout.expected $testroot/stdout
577 test_done "$testroot" "$ret"
578 return 1
579 fi
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
588 ret=$?
589 if [ $ret -ne 0 ]; then
590 diff -u $testroot/stdout.expected $testroot/stdout
591 test_done "$testroot" "$ret"
592 return 1
593 fi
595 cat > $testroot/stdout.expected <<EOF
596 ? .cvsignore
597 ? epsilon/.cvsignore
598 ? epsilon/bar
599 ? epsilon/boo
600 ? epsilon/foo
601 ? epsilon/moo
602 ? epsilon/new/foo
603 ? foo
604 ? foop
605 EOF
606 (cd $testroot/wt && got status -I > $testroot/stdout)
607 ret=$?
608 if [ $ret -ne 0 ]; then
609 echo "got status failed unexpectedly" >&2
610 test_done "$testroot" "1"
611 return 1
612 fi
614 cmp -s $testroot/stdout.expected $testroot/stdout
615 ret=$?
616 if [ $ret -ne 0 ]; then
617 diff -u $testroot/stdout.expected $testroot/stdout
618 fi
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
626 ret=$?
627 if [ $ret -ne 0 ]; then
628 test_done "$testroot" "$ret"
629 return 1
630 fi
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
652 ret=$?
653 if [ $ret -ne 0 ]; then
654 diff -u $testroot/stdout.expected $testroot/stdout
655 test_done "$testroot" "$ret"
656 return 1
657 fi
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
664 ret=$?
665 if [ $ret -ne 0 ]; then
666 diff -u $testroot/stdout.expected $testroot/stdout
667 test_done "$testroot" "$ret"
668 return 1
669 fi
671 cat > $testroot/stdout.expected <<EOF
672 ? .gitignore
673 ? a/b/c/foo
674 ? a/b/c/zoo
675 ? barp
676 ? epsilon/bar
677 ? epsilon/boo
678 ? epsilon/moo
679 ? foo
680 ? foop
681 EOF
682 (cd $testroot/wt && got status -I > $testroot/stdout)
683 ret=$?
684 if [ $ret -ne 0 ]; then
685 echo "got status failed unexpectedly" >&2
686 test_done "$testroot" "1"
687 return 1
688 fi
690 cmp -s $testroot/stdout.expected $testroot/stdout
691 ret=$?
692 if [ $ret -ne 0 ]; then
693 diff -u $testroot/stdout.expected $testroot/stdout
694 fi
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
702 ret=$?
703 if [ $ret -ne 0 ]; then
704 test_done "$testroot" "$ret"
705 return 1
706 fi
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)
718 ret=$?
719 if [ $ret -eq 0 ]; then
720 echo "status succeeded unexpectedly" >&2
721 test_done "$testroot" "1"
722 return 1
723 fi
725 echo "got: invalid status code 'x'" > $testroot/stderr.expected
726 cmp -s $testroot/stderr.expected $testroot/stderr
727 ret=$?
728 if [ $ret -ne 0 ]; then
729 diff -u $testroot/stderr.expected $testroot/stderr
730 test_done "$testroot" "$ret"
731 return 1
732 fi
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
737 ret=$?
738 if [ $ret -ne 0 ]; then
739 diff -u $testroot/stdout.expected $testroot/stdout
740 test_done "$testroot" "$ret"
741 return 1
742 fi
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
747 ret=$?
748 if [ $ret -ne 0 ]; then
749 diff -u $testroot/stdout.expected $testroot/stdout
750 test_done "$testroot" "$ret"
751 return 1
752 fi
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
758 ret=$?
759 if [ $ret -ne 0 ]; then
760 diff -u $testroot/stdout.expected $testroot/stdout
761 test_done "$testroot" "$ret"
762 return 1
763 fi
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
768 ret=$?
769 if [ $ret -ne 0 ]; then
770 diff -u $testroot/stdout.expected $testroot/stdout
771 test_done "$testroot" "$ret"
772 return 1
773 fi
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
780 ret=$?
781 if [ $ret -ne 0 ]; then
782 diff -u $testroot/stdout.expected $testroot/stdout
783 test_done "$testroot" "$ret"
784 return 1
785 fi
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
792 ret=$?
793 if [ $ret -ne 0 ]; then
794 diff -u $testroot/stdout.expected $testroot/stdout
795 test_done "$testroot" "$ret"
796 return 1
797 fi
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
803 ret=$?
804 if [ $ret -ne 0 ]; then
805 diff -u $testroot/stdout.expected $testroot/stdout
806 test_done "$testroot" "$ret"
807 return 1
808 fi
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
817 ret=$?
818 if [ $ret -ne 0 ]; then
819 test_done "$testroot" "$ret"
820 return 1
821 fi
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)
833 ret=$?
834 if [ $ret -eq 0 ]; then
835 echo "status succeeded unexpectedly" >&2
836 test_done "$testroot" "1"
837 return 1
838 fi
840 echo "got: -s and -S options are mutually exclusive" \
841 > $testroot/stderr.expected
842 cmp -s $testroot/stderr.expected $testroot/stderr
843 ret=$?
844 if [ $ret -ne 0 ]; then
845 diff -u $testroot/stderr.expected $testroot/stderr
846 test_done "$testroot" "$ret"
847 return 1
848 fi
850 (cd $testroot/wt && got status -s A -S M \
851 > $testroot/stdout 2> $testroot/stderr)
852 ret=$?
853 if [ $ret -eq 0 ]; then
854 echo "status succeeded unexpectedly" >&2
855 test_done "$testroot" "1"
856 return 1
857 fi
859 echo "got: -S and -s options are mutually exclusive" \
860 > $testroot/stderr.expected
861 cmp -s $testroot/stderr.expected $testroot/stderr
862 ret=$?
863 if [ $ret -ne 0 ]; then
864 diff -u $testroot/stderr.expected $testroot/stderr
865 test_done "$testroot" "$ret"
866 return 1
867 fi
869 (cd $testroot/wt && got status -S xDM \
870 > $testroot/stdout 2> $testroot/stderr)
871 ret=$?
872 if [ $ret -eq 0 ]; then
873 echo "status succeeded unexpectedly" >&2
874 test_done "$testroot" "1"
875 return 1
876 fi
878 echo "got: invalid status code 'x'" > $testroot/stderr.expected
879 cmp -s $testroot/stderr.expected $testroot/stderr
880 ret=$?
881 if [ $ret -ne 0 ]; then
882 diff -u $testroot/stderr.expected $testroot/stderr
883 test_done "$testroot" "$ret"
884 return 1
885 fi
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
890 ret=$?
891 if [ $ret -ne 0 ]; then
892 diff -u $testroot/stdout.expected $testroot/stdout
893 test_done "$testroot" "$ret"
894 return 1
895 fi
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
900 ret=$?
901 if [ $ret -ne 0 ]; then
902 diff -u $testroot/stdout.expected $testroot/stdout
903 test_done "$testroot" "$ret"
904 return 1
905 fi
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
911 ret=$?
912 if [ $ret -ne 0 ]; then
913 diff -u $testroot/stdout.expected $testroot/stdout
914 test_done "$testroot" "$ret"
915 return 1
916 fi
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
921 ret=$?
922 if [ $ret -ne 0 ]; then
923 diff -u $testroot/stdout.expected $testroot/stdout
924 test_done "$testroot" "$ret"
925 return 1
926 fi
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
933 ret=$?
934 if [ $ret -ne 0 ]; then
935 diff -u $testroot/stdout.expected $testroot/stdout
936 test_done "$testroot" "$ret"
937 return 1
938 fi
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
946 ret=$?
947 if [ $ret -ne 0 ]; then
948 diff -u $testroot/stdout.expected $testroot/stdout
949 test_done "$testroot" "$ret"
950 return 1
951 fi
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
956 ret=$?
957 if [ $ret -ne 0 ]; then
958 diff -u $testroot/stdout.expected $testroot/stdout
959 test_done "$testroot" "$ret"
960 return 1
961 fi
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
968 ret=$?
969 if [ $ret -ne 0 ]; then
970 diff -u $testroot/stdout.expected $testroot/stdout
971 test_done "$testroot" "$ret"
972 return 1
973 fi
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
982 ret=$?
983 if [ $ret -ne 0 ]; then
984 test_done "$testroot" "$ret"
985 return 1
986 fi
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
996 ret=$?
997 if [ $ret -ne 0 ]; then
998 diff -u $testroot/stdout.expected $testroot/stdout
999 test_done "$testroot" "$ret"
1000 return 1
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
1009 ret=$?
1010 if [ $ret -ne 0 ]; then
1011 diff -u $testroot/stdout.expected $testroot/stdout
1012 test_done "$testroot" "$ret"
1013 return 1
1016 # update the timestamp; this used to make the file show up as:
1017 # M empty
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
1025 ret=$?
1026 if [ $ret -ne 0 ]; then
1027 diff -u $testroot/stdout.expected $testroot/stdout
1029 test_done "$testroot" "$ret"
1032 test_parseargs "$@"
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