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_gitignore_trailing_slashes() {
699 local testroot=`test_init status_gitignore_trailing_slashes`
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 "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 "unversioned file" > $testroot/wt/upsilon
714 # Match the directory epsilon but not the regular file upsilon
715 echo "*psilon/" > $testroot/wt/.gitignore
717 echo '? .gitignore' > $testroot/stdout.expected
718 echo '? foo' >> $testroot/stdout.expected
719 echo '? upsilon' >> $testroot/stdout.expected
720 (cd $testroot/wt && got status > $testroot/stdout)
722 cmp -s $testroot/stdout.expected $testroot/stdout
723 ret=$?
724 if [ $ret -ne 0 ]; then
725 diff -u $testroot/stdout.expected $testroot/stdout
726 fi
727 test_done "$testroot" "$ret"
730 test_status_status_code() {
731 local testroot=`test_init status_status_code`
733 got checkout $testroot/repo $testroot/wt > /dev/null
734 ret=$?
735 if [ $ret -ne 0 ]; then
736 test_done "$testroot" "$ret"
737 return 1
738 fi
740 echo "modified alpha" > $testroot/wt/alpha
741 (cd $testroot/wt && got rm beta >/dev/null)
742 echo "unversioned file" > $testroot/wt/foo
743 rm $testroot/wt/epsilon/zeta
744 touch $testroot/wt/beta
745 echo "new file" > $testroot/wt/new
746 (cd $testroot/wt && got add new >/dev/null)
748 (cd $testroot/wt && got status -s xDM \
749 > $testroot/stdout 2> $testroot/stderr)
750 ret=$?
751 if [ $ret -eq 0 ]; then
752 echo "status succeeded unexpectedly" >&2
753 test_done "$testroot" "1"
754 return 1
755 fi
757 echo "got: invalid status code 'x'" > $testroot/stderr.expected
758 cmp -s $testroot/stderr.expected $testroot/stderr
759 ret=$?
760 if [ $ret -ne 0 ]; then
761 diff -u $testroot/stderr.expected $testroot/stderr
762 test_done "$testroot" "$ret"
763 return 1
764 fi
766 echo 'M alpha' > $testroot/stdout.expected
767 (cd $testroot/wt && got status -s M > $testroot/stdout)
768 cmp -s $testroot/stdout.expected $testroot/stdout
769 ret=$?
770 if [ $ret -ne 0 ]; then
771 diff -u $testroot/stdout.expected $testroot/stdout
772 test_done "$testroot" "$ret"
773 return 1
774 fi
776 echo 'D beta' > $testroot/stdout.expected
777 (cd $testroot/wt && got status -s D > $testroot/stdout)
778 cmp -s $testroot/stdout.expected $testroot/stdout
779 ret=$?
780 if [ $ret -ne 0 ]; then
781 diff -u $testroot/stdout.expected $testroot/stdout
782 test_done "$testroot" "$ret"
783 return 1
784 fi
786 echo '! epsilon/zeta' > $testroot/stdout.expected
787 echo '? foo' >> $testroot/stdout.expected
788 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
789 cmp -s $testroot/stdout.expected $testroot/stdout
790 ret=$?
791 if [ $ret -ne 0 ]; then
792 diff -u $testroot/stdout.expected $testroot/stdout
793 test_done "$testroot" "$ret"
794 return 1
795 fi
797 echo 'A new' > $testroot/stdout.expected
798 (cd $testroot/wt && got status -s A > $testroot/stdout)
799 cmp -s $testroot/stdout.expected $testroot/stdout
800 ret=$?
801 if [ $ret -ne 0 ]; then
802 diff -u $testroot/stdout.expected $testroot/stdout
803 test_done "$testroot" "$ret"
804 return 1
805 fi
807 (cd $testroot/wt && got stage new > $testroot/stdout)
809 echo ' A new' > $testroot/stdout.expected
810 (cd $testroot/wt && got status -s A > $testroot/stdout)
811 cmp -s $testroot/stdout.expected $testroot/stdout
812 ret=$?
813 if [ $ret -ne 0 ]; then
814 diff -u $testroot/stdout.expected $testroot/stdout
815 test_done "$testroot" "$ret"
816 return 1
817 fi
819 echo 'changed file new' > $testroot/wt/new
821 echo 'MA new' > $testroot/stdout.expected
822 (cd $testroot/wt && got status -s A > $testroot/stdout)
823 cmp -s $testroot/stdout.expected $testroot/stdout
824 ret=$?
825 if [ $ret -ne 0 ]; then
826 diff -u $testroot/stdout.expected $testroot/stdout
827 test_done "$testroot" "$ret"
828 return 1
829 fi
831 echo 'M alpha' > $testroot/stdout.expected
832 echo 'MA new' >> $testroot/stdout.expected
833 (cd $testroot/wt && got status -s M > $testroot/stdout)
834 cmp -s $testroot/stdout.expected $testroot/stdout
835 ret=$?
836 if [ $ret -ne 0 ]; then
837 diff -u $testroot/stdout.expected $testroot/stdout
838 test_done "$testroot" "$ret"
839 return 1
840 fi
842 test_done "$testroot" "$ret"
845 test_status_suppress() {
846 local testroot=`test_init status_suppress`
848 got checkout $testroot/repo $testroot/wt > /dev/null
849 ret=$?
850 if [ $ret -ne 0 ]; then
851 test_done "$testroot" "$ret"
852 return 1
853 fi
855 echo "modified alpha" > $testroot/wt/alpha
856 (cd $testroot/wt && got rm beta >/dev/null)
857 echo "unversioned file" > $testroot/wt/foo
858 rm $testroot/wt/epsilon/zeta
859 touch $testroot/wt/beta
860 echo "new file" > $testroot/wt/new
861 (cd $testroot/wt && got add new >/dev/null)
863 (cd $testroot/wt && got status -S A -s M \
864 > $testroot/stdout 2> $testroot/stderr)
865 ret=$?
866 if [ $ret -eq 0 ]; then
867 echo "status succeeded unexpectedly" >&2
868 test_done "$testroot" "1"
869 return 1
870 fi
872 echo "got: -s and -S options are mutually exclusive" \
873 > $testroot/stderr.expected
874 cmp -s $testroot/stderr.expected $testroot/stderr
875 ret=$?
876 if [ $ret -ne 0 ]; then
877 diff -u $testroot/stderr.expected $testroot/stderr
878 test_done "$testroot" "$ret"
879 return 1
880 fi
882 (cd $testroot/wt && got status -s A -S M \
883 > $testroot/stdout 2> $testroot/stderr)
884 ret=$?
885 if [ $ret -eq 0 ]; then
886 echo "status succeeded unexpectedly" >&2
887 test_done "$testroot" "1"
888 return 1
889 fi
891 echo "got: -S and -s options are mutually exclusive" \
892 > $testroot/stderr.expected
893 cmp -s $testroot/stderr.expected $testroot/stderr
894 ret=$?
895 if [ $ret -ne 0 ]; then
896 diff -u $testroot/stderr.expected $testroot/stderr
897 test_done "$testroot" "$ret"
898 return 1
899 fi
901 (cd $testroot/wt && got status -S xDM \
902 > $testroot/stdout 2> $testroot/stderr)
903 ret=$?
904 if [ $ret -eq 0 ]; then
905 echo "status succeeded unexpectedly" >&2
906 test_done "$testroot" "1"
907 return 1
908 fi
910 echo "got: invalid status code 'x'" > $testroot/stderr.expected
911 cmp -s $testroot/stderr.expected $testroot/stderr
912 ret=$?
913 if [ $ret -ne 0 ]; then
914 diff -u $testroot/stderr.expected $testroot/stderr
915 test_done "$testroot" "$ret"
916 return 1
917 fi
919 echo 'M alpha' > $testroot/stdout.expected
920 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
921 cmp -s $testroot/stdout.expected $testroot/stdout
922 ret=$?
923 if [ $ret -ne 0 ]; then
924 diff -u $testroot/stdout.expected $testroot/stdout
925 test_done "$testroot" "$ret"
926 return 1
927 fi
929 echo 'D beta' > $testroot/stdout.expected
930 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
931 cmp -s $testroot/stdout.expected $testroot/stdout
932 ret=$?
933 if [ $ret -ne 0 ]; then
934 diff -u $testroot/stdout.expected $testroot/stdout
935 test_done "$testroot" "$ret"
936 return 1
937 fi
939 echo '! epsilon/zeta' > $testroot/stdout.expected
940 echo '? foo' >> $testroot/stdout.expected
941 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
942 cmp -s $testroot/stdout.expected $testroot/stdout
943 ret=$?
944 if [ $ret -ne 0 ]; then
945 diff -u $testroot/stdout.expected $testroot/stdout
946 test_done "$testroot" "$ret"
947 return 1
948 fi
950 echo 'A new' > $testroot/stdout.expected
951 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
952 cmp -s $testroot/stdout.expected $testroot/stdout
953 ret=$?
954 if [ $ret -ne 0 ]; then
955 diff -u $testroot/stdout.expected $testroot/stdout
956 test_done "$testroot" "$ret"
957 return 1
958 fi
960 (cd $testroot/wt && got stage new > $testroot/stdout)
962 echo ' A new' > $testroot/stdout.expected
963 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
964 cmp -s $testroot/stdout.expected $testroot/stdout
965 ret=$?
966 if [ $ret -ne 0 ]; then
967 diff -u $testroot/stdout.expected $testroot/stdout
968 test_done "$testroot" "$ret"
969 return 1
970 fi
972 echo 'changed file new' > $testroot/wt/new
974 echo 'M alpha' > $testroot/stdout.expected
975 echo 'MA new' >> $testroot/stdout.expected
976 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
977 cmp -s $testroot/stdout.expected $testroot/stdout
978 ret=$?
979 if [ $ret -ne 0 ]; then
980 diff -u $testroot/stdout.expected $testroot/stdout
981 test_done "$testroot" "$ret"
982 return 1
983 fi
985 echo 'M alpha' > $testroot/stdout.expected
986 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
987 cmp -s $testroot/stdout.expected $testroot/stdout
988 ret=$?
989 if [ $ret -ne 0 ]; then
990 diff -u $testroot/stdout.expected $testroot/stdout
991 test_done "$testroot" "$ret"
992 return 1
993 fi
995 rm $testroot/stdout.expected
996 touch $testroot/stdout.expected
998 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
999 cmp -s $testroot/stdout.expected $testroot/stdout
1000 ret=$?
1001 if [ $ret -ne 0 ]; then
1002 diff -u $testroot/stdout.expected $testroot/stdout
1003 test_done "$testroot" "$ret"
1004 return 1
1007 test_done "$testroot" "$ret"
1010 test_status_empty_file() {
1011 local testroot=`test_init status_empty_file`
1013 got checkout $testroot/repo $testroot/wt > /dev/null
1014 ret=$?
1015 if [ $ret -ne 0 ]; then
1016 test_done "$testroot" "$ret"
1017 return 1
1020 echo -n "" > $testroot/wt/empty
1021 (cd $testroot/wt && got add empty >/dev/null)
1023 echo 'A empty' > $testroot/stdout.expected
1025 (cd $testroot/wt && got status > $testroot/stdout)
1027 cmp -s $testroot/stdout.expected $testroot/stdout
1028 ret=$?
1029 if [ $ret -ne 0 ]; then
1030 diff -u $testroot/stdout.expected $testroot/stdout
1031 test_done "$testroot" "$ret"
1032 return 1
1035 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1037 (cd $testroot/wt && got status > $testroot/stdout)
1039 echo -n > $testroot/stdout.expected
1040 cmp -s $testroot/stdout.expected $testroot/stdout
1041 ret=$?
1042 if [ $ret -ne 0 ]; then
1043 diff -u $testroot/stdout.expected $testroot/stdout
1044 test_done "$testroot" "$ret"
1045 return 1
1048 # update the timestamp; this used to make the file show up as:
1049 # M empty
1050 # which should not happen
1051 touch $testroot/wt/empty
1053 (cd $testroot/wt && got status > $testroot/stdout)
1055 echo -n > $testroot/stdout.expected
1056 cmp -s $testroot/stdout.expected $testroot/stdout
1057 ret=$?
1058 if [ $ret -ne 0 ]; then
1059 diff -u $testroot/stdout.expected $testroot/stdout
1061 test_done "$testroot" "$ret"
1064 test_parseargs "$@"
1065 run_test test_status_basic
1066 run_test test_status_subdir_no_mods
1067 run_test test_status_subdir_no_mods2
1068 run_test test_status_obstructed
1069 run_test test_status_shows_local_mods_after_update
1070 run_test test_status_unversioned_subdirs
1071 run_test test_status_symlink
1072 run_test test_status_shows_no_mods_after_complete_merge
1073 run_test test_status_shows_conflict
1074 run_test test_status_empty_dir
1075 run_test test_status_empty_dir_unversioned_file
1076 run_test test_status_many_paths
1077 run_test test_status_cvsignore
1078 run_test test_status_gitignore
1079 run_test test_status_gitignore_trailing_slashes
1080 run_test test_status_status_code
1081 run_test test_status_suppress
1082 run_test test_status_empty_file