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 '' -e 's/2/22/' $testroot/repo/numbers
191 git_commit $testroot/repo -m "modified line 2"
193 # modify line 7; both changes should merge cleanly
194 sed -i '' -e 's/7/77/' $testroot/wt/numbers
196 echo "G numbers" > $testroot/stdout.expected
197 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
198 git_show_head $testroot/repo >> $testroot/stdout.expected
199 echo >> $testroot/stdout.expected
201 (cd $testroot/wt && got update > $testroot/stdout)
203 cmp -s $testroot/stdout.expected $testroot/stdout
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 -sfT gamma epsilon.link)
306 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
307 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
308 (cd $testroot/wt && got add passwd.link epsilon/beta.link > /dev/null)
310 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
312 echo 'M alpha.link' > $testroot/stdout.expected
313 echo 'A epsilon/beta.link' >> $testroot/stdout.expected
314 echo 'M epsilon.link' >> $testroot/stdout.expected
315 echo 'D nonexistent.link' >> $testroot/stdout.expected
316 echo 'A passwd.link' >> $testroot/stdout.expected
317 echo "? ramdisk/obj" >> $testroot/stdout.expected
319 (cd $testroot/wt && got status > $testroot/stdout)
321 cmp -s $testroot/stdout.expected $testroot/stdout
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 '' -e 's/2/22/' $testroot/repo/numbers
346 git_commit $testroot/repo -m "modified line 2"
348 # modify line 2 again; no local changes are left after merge
349 sed -i '' -e 's/2/22/' $testroot/wt/numbers
351 echo "G numbers" > $testroot/stdout.expected
352 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
353 git_show_head $testroot/repo >> $testroot/stdout.expected
354 echo >> $testroot/stdout.expected
356 (cd $testroot/wt && got update > $testroot/stdout)
358 cmp -s $testroot/stdout.expected $testroot/stdout
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 '' -e 's/2/22/' $testroot/repo/numbers
400 git_commit $testroot/repo -m "modified line 2"
402 # modify line 2 in a conflicting way
403 sed -i '' -e 's/2/77/' $testroot/wt/numbers
405 echo "C numbers" > $testroot/stdout.expected
406 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
407 git_show_head $testroot/repo >> $testroot/stdout.expected
408 echo >> $testroot/stdout.expected
409 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
411 (cd $testroot/wt && got update > $testroot/stdout)
413 cmp -s $testroot/stdout.expected $testroot/stdout
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 "epsilon/" > $testroot/wt/.gitignore
714 echo '? .gitignore' > $testroot/stdout.expected
715 echo '? foo' >> $testroot/stdout.expected
716 (cd $testroot/wt && got status > $testroot/stdout)
718 cmp -s $testroot/stdout.expected $testroot/stdout
719 ret=$?
720 if [ $ret -ne 0 ]; then
721 diff -u $testroot/stdout.expected $testroot/stdout
722 test_done "$testroot" "xfail trailing slashes"
723 return 1
724 fi
725 test_done "$testroot" "$ret"
728 test_status_status_code() {
729 local testroot=`test_init status_status_code`
731 got checkout $testroot/repo $testroot/wt > /dev/null
732 ret=$?
733 if [ $ret -ne 0 ]; then
734 test_done "$testroot" "$ret"
735 return 1
736 fi
738 echo "modified alpha" > $testroot/wt/alpha
739 (cd $testroot/wt && got rm beta >/dev/null)
740 echo "unversioned file" > $testroot/wt/foo
741 rm $testroot/wt/epsilon/zeta
742 touch $testroot/wt/beta
743 echo "new file" > $testroot/wt/new
744 (cd $testroot/wt && got add new >/dev/null)
746 (cd $testroot/wt && got status -s xDM \
747 > $testroot/stdout 2> $testroot/stderr)
748 ret=$?
749 if [ $ret -eq 0 ]; then
750 echo "status succeeded unexpectedly" >&2
751 test_done "$testroot" "1"
752 return 1
753 fi
755 echo "got: invalid status code 'x'" > $testroot/stderr.expected
756 cmp -s $testroot/stderr.expected $testroot/stderr
757 ret=$?
758 if [ $ret -ne 0 ]; then
759 diff -u $testroot/stderr.expected $testroot/stderr
760 test_done "$testroot" "$ret"
761 return 1
762 fi
764 echo 'M alpha' > $testroot/stdout.expected
765 (cd $testroot/wt && got status -s M > $testroot/stdout)
766 cmp -s $testroot/stdout.expected $testroot/stdout
767 ret=$?
768 if [ $ret -ne 0 ]; then
769 diff -u $testroot/stdout.expected $testroot/stdout
770 test_done "$testroot" "$ret"
771 return 1
772 fi
774 echo 'D beta' > $testroot/stdout.expected
775 (cd $testroot/wt && got status -s D > $testroot/stdout)
776 cmp -s $testroot/stdout.expected $testroot/stdout
777 ret=$?
778 if [ $ret -ne 0 ]; then
779 diff -u $testroot/stdout.expected $testroot/stdout
780 test_done "$testroot" "$ret"
781 return 1
782 fi
784 echo '! epsilon/zeta' > $testroot/stdout.expected
785 echo '? foo' >> $testroot/stdout.expected
786 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
787 cmp -s $testroot/stdout.expected $testroot/stdout
788 ret=$?
789 if [ $ret -ne 0 ]; then
790 diff -u $testroot/stdout.expected $testroot/stdout
791 test_done "$testroot" "$ret"
792 return 1
793 fi
795 echo 'A new' > $testroot/stdout.expected
796 (cd $testroot/wt && got status -s A > $testroot/stdout)
797 cmp -s $testroot/stdout.expected $testroot/stdout
798 ret=$?
799 if [ $ret -ne 0 ]; then
800 diff -u $testroot/stdout.expected $testroot/stdout
801 test_done "$testroot" "$ret"
802 return 1
803 fi
805 (cd $testroot/wt && got stage new > $testroot/stdout)
807 echo ' A new' > $testroot/stdout.expected
808 (cd $testroot/wt && got status -s A > $testroot/stdout)
809 cmp -s $testroot/stdout.expected $testroot/stdout
810 ret=$?
811 if [ $ret -ne 0 ]; then
812 diff -u $testroot/stdout.expected $testroot/stdout
813 test_done "$testroot" "$ret"
814 return 1
815 fi
817 echo 'changed file new' > $testroot/wt/new
819 echo 'MA new' > $testroot/stdout.expected
820 (cd $testroot/wt && got status -s A > $testroot/stdout)
821 cmp -s $testroot/stdout.expected $testroot/stdout
822 ret=$?
823 if [ $ret -ne 0 ]; then
824 diff -u $testroot/stdout.expected $testroot/stdout
825 test_done "$testroot" "$ret"
826 return 1
827 fi
829 echo 'M alpha' > $testroot/stdout.expected
830 echo 'MA new' >> $testroot/stdout.expected
831 (cd $testroot/wt && got status -s M > $testroot/stdout)
832 cmp -s $testroot/stdout.expected $testroot/stdout
833 ret=$?
834 if [ $ret -ne 0 ]; then
835 diff -u $testroot/stdout.expected $testroot/stdout
836 test_done "$testroot" "$ret"
837 return 1
838 fi
840 test_done "$testroot" "$ret"
843 test_status_suppress() {
844 local testroot=`test_init status_suppress`
846 got checkout $testroot/repo $testroot/wt > /dev/null
847 ret=$?
848 if [ $ret -ne 0 ]; then
849 test_done "$testroot" "$ret"
850 return 1
851 fi
853 echo "modified alpha" > $testroot/wt/alpha
854 (cd $testroot/wt && got rm beta >/dev/null)
855 echo "unversioned file" > $testroot/wt/foo
856 rm $testroot/wt/epsilon/zeta
857 touch $testroot/wt/beta
858 echo "new file" > $testroot/wt/new
859 (cd $testroot/wt && got add new >/dev/null)
861 (cd $testroot/wt && got status -S A -s M \
862 > $testroot/stdout 2> $testroot/stderr)
863 ret=$?
864 if [ $ret -eq 0 ]; then
865 echo "status succeeded unexpectedly" >&2
866 test_done "$testroot" "1"
867 return 1
868 fi
870 echo "got: -s and -S options are mutually exclusive" \
871 > $testroot/stderr.expected
872 cmp -s $testroot/stderr.expected $testroot/stderr
873 ret=$?
874 if [ $ret -ne 0 ]; then
875 diff -u $testroot/stderr.expected $testroot/stderr
876 test_done "$testroot" "$ret"
877 return 1
878 fi
880 (cd $testroot/wt && got status -s A -S M \
881 > $testroot/stdout 2> $testroot/stderr)
882 ret=$?
883 if [ $ret -eq 0 ]; then
884 echo "status succeeded unexpectedly" >&2
885 test_done "$testroot" "1"
886 return 1
887 fi
889 echo "got: -S and -s options are mutually exclusive" \
890 > $testroot/stderr.expected
891 cmp -s $testroot/stderr.expected $testroot/stderr
892 ret=$?
893 if [ $ret -ne 0 ]; then
894 diff -u $testroot/stderr.expected $testroot/stderr
895 test_done "$testroot" "$ret"
896 return 1
897 fi
899 (cd $testroot/wt && got status -S xDM \
900 > $testroot/stdout 2> $testroot/stderr)
901 ret=$?
902 if [ $ret -eq 0 ]; then
903 echo "status succeeded unexpectedly" >&2
904 test_done "$testroot" "1"
905 return 1
906 fi
908 echo "got: invalid status code 'x'" > $testroot/stderr.expected
909 cmp -s $testroot/stderr.expected $testroot/stderr
910 ret=$?
911 if [ $ret -ne 0 ]; then
912 diff -u $testroot/stderr.expected $testroot/stderr
913 test_done "$testroot" "$ret"
914 return 1
915 fi
917 echo 'M alpha' > $testroot/stdout.expected
918 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
919 cmp -s $testroot/stdout.expected $testroot/stdout
920 ret=$?
921 if [ $ret -ne 0 ]; then
922 diff -u $testroot/stdout.expected $testroot/stdout
923 test_done "$testroot" "$ret"
924 return 1
925 fi
927 echo 'D beta' > $testroot/stdout.expected
928 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
929 cmp -s $testroot/stdout.expected $testroot/stdout
930 ret=$?
931 if [ $ret -ne 0 ]; then
932 diff -u $testroot/stdout.expected $testroot/stdout
933 test_done "$testroot" "$ret"
934 return 1
935 fi
937 echo '! epsilon/zeta' > $testroot/stdout.expected
938 echo '? foo' >> $testroot/stdout.expected
939 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
940 cmp -s $testroot/stdout.expected $testroot/stdout
941 ret=$?
942 if [ $ret -ne 0 ]; then
943 diff -u $testroot/stdout.expected $testroot/stdout
944 test_done "$testroot" "$ret"
945 return 1
946 fi
948 echo 'A new' > $testroot/stdout.expected
949 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
950 cmp -s $testroot/stdout.expected $testroot/stdout
951 ret=$?
952 if [ $ret -ne 0 ]; then
953 diff -u $testroot/stdout.expected $testroot/stdout
954 test_done "$testroot" "$ret"
955 return 1
956 fi
958 (cd $testroot/wt && got stage new > $testroot/stdout)
960 echo ' A new' > $testroot/stdout.expected
961 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
962 cmp -s $testroot/stdout.expected $testroot/stdout
963 ret=$?
964 if [ $ret -ne 0 ]; then
965 diff -u $testroot/stdout.expected $testroot/stdout
966 test_done "$testroot" "$ret"
967 return 1
968 fi
970 echo 'changed file new' > $testroot/wt/new
972 echo 'M alpha' > $testroot/stdout.expected
973 echo 'MA new' >> $testroot/stdout.expected
974 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
975 cmp -s $testroot/stdout.expected $testroot/stdout
976 ret=$?
977 if [ $ret -ne 0 ]; then
978 diff -u $testroot/stdout.expected $testroot/stdout
979 test_done "$testroot" "$ret"
980 return 1
981 fi
983 echo 'M alpha' > $testroot/stdout.expected
984 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
985 cmp -s $testroot/stdout.expected $testroot/stdout
986 ret=$?
987 if [ $ret -ne 0 ]; then
988 diff -u $testroot/stdout.expected $testroot/stdout
989 test_done "$testroot" "$ret"
990 return 1
991 fi
993 rm $testroot/stdout.expected
994 touch $testroot/stdout.expected
996 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
997 cmp -s $testroot/stdout.expected $testroot/stdout
998 ret=$?
999 if [ $ret -ne 0 ]; then
1000 diff -u $testroot/stdout.expected $testroot/stdout
1001 test_done "$testroot" "$ret"
1002 return 1
1005 test_done "$testroot" "$ret"
1008 test_status_empty_file() {
1009 local testroot=`test_init status_empty_file`
1011 got checkout $testroot/repo $testroot/wt > /dev/null
1012 ret=$?
1013 if [ $ret -ne 0 ]; then
1014 test_done "$testroot" "$ret"
1015 return 1
1018 echo -n "" > $testroot/wt/empty
1019 (cd $testroot/wt && got add empty >/dev/null)
1021 echo 'A empty' > $testroot/stdout.expected
1023 (cd $testroot/wt && got status > $testroot/stdout)
1025 cmp -s $testroot/stdout.expected $testroot/stdout
1026 ret=$?
1027 if [ $ret -ne 0 ]; then
1028 diff -u $testroot/stdout.expected $testroot/stdout
1029 test_done "$testroot" "$ret"
1030 return 1
1033 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1035 (cd $testroot/wt && got status > $testroot/stdout)
1037 echo -n > $testroot/stdout.expected
1038 cmp -s $testroot/stdout.expected $testroot/stdout
1039 ret=$?
1040 if [ $ret -ne 0 ]; then
1041 diff -u $testroot/stdout.expected $testroot/stdout
1042 test_done "$testroot" "$ret"
1043 return 1
1046 # update the timestamp; this used to make the file show up as:
1047 # M empty
1048 # which should not happen
1049 touch $testroot/wt/empty
1051 (cd $testroot/wt && got status > $testroot/stdout)
1053 echo -n > $testroot/stdout.expected
1054 cmp -s $testroot/stdout.expected $testroot/stdout
1055 ret=$?
1056 if [ $ret -ne 0 ]; then
1057 diff -u $testroot/stdout.expected $testroot/stdout
1059 test_done "$testroot" "$ret"
1062 test_parseargs "$@"
1063 run_test test_status_basic
1064 run_test test_status_subdir_no_mods
1065 run_test test_status_subdir_no_mods2
1066 run_test test_status_obstructed
1067 run_test test_status_shows_local_mods_after_update
1068 run_test test_status_unversioned_subdirs
1069 run_test test_status_symlink
1070 run_test test_status_shows_no_mods_after_complete_merge
1071 run_test test_status_shows_conflict
1072 run_test test_status_empty_dir
1073 run_test test_status_empty_dir_unversioned_file
1074 run_test test_status_many_paths
1075 run_test test_status_cvsignore
1076 run_test test_status_gitignore
1077 run_test test_status_gitignore_trailing_slashes
1078 run_test test_status_status_code
1079 run_test test_status_suppress
1080 run_test test_status_empty_file