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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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" != "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 echo -n > $testroot/repo/numbers
334 for i in `jot 16384`; do
335 echo "$i" >> $testroot/repo/numbers
336 done
338 (cd $testroot/repo && git add numbers)
339 git_commit $testroot/repo -m "added numbers file"
341 got checkout $testroot/repo $testroot/wt > /dev/null
342 ret="$?"
343 if [ "$ret" != "0" ]; then
344 test_done "$testroot" "$ret"
345 return 1
346 fi
348 sed -i '' -e 's/2/22/' $testroot/repo/numbers
349 git_commit $testroot/repo -m "modified line 2"
351 sleep 1
352 # modify line 2 again; no local changes are left after merge
353 sed -i '' -e 's/2/22/' $testroot/wt/numbers
355 echo "G numbers" > $testroot/stdout.expected
356 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
357 git_show_head $testroot/repo >> $testroot/stdout.expected
358 echo >> $testroot/stdout.expected
360 (cd $testroot/wt && got update > $testroot/stdout)
362 cmp -s $testroot/stdout.expected $testroot/stdout
363 ret="$?"
364 if [ "$ret" != "0" ]; then
365 diff -u $testroot/stdout.expected $testroot/stdout
366 test_done "$testroot" "$ret"
367 return 1
368 fi
370 echo -n > $testroot/stdout.expected
372 (cd $testroot/wt && got status > $testroot/stdout)
374 cmp -s $testroot/stdout.expected $testroot/stdout
375 ret="$?"
376 if [ "$ret" != "0" ]; then
377 diff -u $testroot/stdout.expected $testroot/stdout
378 fi
379 test_done "$testroot" "$ret"
382 test_status_shows_conflict() {
383 local testroot=`test_init status_shows_conflict 1`
385 echo "1" > $testroot/repo/numbers
386 echo "2" >> $testroot/repo/numbers
387 echo "3" >> $testroot/repo/numbers
388 echo "4" >> $testroot/repo/numbers
389 echo "5" >> $testroot/repo/numbers
390 echo "6" >> $testroot/repo/numbers
391 echo "7" >> $testroot/repo/numbers
392 echo "8" >> $testroot/repo/numbers
393 (cd $testroot/repo && git add numbers)
394 git_commit $testroot/repo -m "added numbers file"
396 got checkout $testroot/repo $testroot/wt > /dev/null
397 ret="$?"
398 if [ "$ret" != "0" ]; then
399 test_done "$testroot" "$ret"
400 return 1
401 fi
403 sed -i '' -e 's/2/22/' $testroot/repo/numbers
404 git_commit $testroot/repo -m "modified line 2"
406 # modify line 2 in a conflicting way
407 sed -i '' -e 's/2/77/' $testroot/wt/numbers
409 echo "C numbers" > $testroot/stdout.expected
410 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
411 git_show_head $testroot/repo >> $testroot/stdout.expected
412 echo >> $testroot/stdout.expected
413 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
415 (cd $testroot/wt && got update > $testroot/stdout)
417 cmp -s $testroot/stdout.expected $testroot/stdout
418 ret="$?"
419 if [ "$ret" != "0" ]; then
420 diff -u $testroot/stdout.expected $testroot/stdout
421 test_done "$testroot" "$ret"
422 return 1
423 fi
425 echo 'C numbers' > $testroot/stdout.expected
427 (cd $testroot/wt && got status > $testroot/stdout)
429 cmp -s $testroot/stdout.expected $testroot/stdout
430 ret="$?"
431 if [ "$ret" != "0" ]; then
432 diff -u $testroot/stdout.expected $testroot/stdout
433 fi
434 test_done "$testroot" "$ret"
437 test_status_empty_dir() {
438 local testroot=`test_init status_empty_dir`
440 got checkout $testroot/repo $testroot/wt > /dev/null
441 ret="$?"
442 if [ "$ret" != "0" ]; then
443 test_done "$testroot" "$ret"
444 return 1
445 fi
447 rm $testroot/wt/epsilon/zeta
449 echo '! epsilon/zeta' > $testroot/stdout.expected
451 (cd $testroot/wt && got status epsilon > $testroot/stdout)
453 cmp -s $testroot/stdout.expected $testroot/stdout
454 ret="$?"
455 if [ "$ret" != "0" ]; then
456 diff -u $testroot/stdout.expected $testroot/stdout
457 fi
458 test_done "$testroot" "$ret"
461 test_status_empty_dir_unversioned_file() {
462 local testroot=`test_init status_empty_dir_unversioned_file`
464 got checkout $testroot/repo $testroot/wt > /dev/null
465 ret="$?"
466 if [ "$ret" != "0" ]; then
467 test_done "$testroot" "$ret"
468 return 1
469 fi
471 rm $testroot/wt/epsilon/zeta
472 touch $testroot/wt/epsilon/unversioned
474 echo '? epsilon/unversioned' > $testroot/stdout.expected
475 echo '! epsilon/zeta' >> $testroot/stdout.expected
477 (cd $testroot/wt && got status epsilon > $testroot/stdout)
479 cmp -s $testroot/stdout.expected $testroot/stdout
480 ret="$?"
481 if [ "$ret" != "0" ]; then
482 diff -u $testroot/stdout.expected $testroot/stdout
483 fi
484 test_done "$testroot" "$ret"
487 test_status_many_paths() {
488 local testroot=`test_init status_many_paths`
490 got checkout $testroot/repo $testroot/wt > /dev/null
491 ret="$?"
492 if [ "$ret" != "0" ]; then
493 test_done "$testroot" "$ret"
494 return 1
495 fi
497 echo "modified alpha" > $testroot/wt/alpha
498 (cd $testroot/wt && got rm beta >/dev/null)
499 echo "unversioned file" > $testroot/wt/foo
500 rm $testroot/wt/epsilon/zeta
501 touch $testroot/wt/beta
502 echo "new file" > $testroot/wt/new
503 mkdir $testroot/wt/newdir
504 (cd $testroot/wt && got add new >/dev/null)
506 (cd $testroot/wt && got status alpha > $testroot/stdout.expected)
507 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
508 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
509 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
510 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
511 (cd $testroot/wt && got status newdir >> $testroot/stdout.expected)
512 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
514 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
515 > $testroot/stdout)
517 cmp -s $testroot/stdout.expected $testroot/stdout
518 ret="$?"
519 if [ "$ret" != "0" ]; then
520 diff -u $testroot/stdout.expected $testroot/stdout
521 fi
522 test_done "$testroot" "$ret"
525 test_status_cvsignore() {
526 local testroot=`test_init status_cvsignore`
528 got checkout $testroot/repo $testroot/wt > /dev/null
529 ret="$?"
530 if [ "$ret" != "0" ]; then
531 test_done "$testroot" "$ret"
532 return 1
533 fi
535 echo "unversioned file" > $testroot/wt/foo
536 echo "unversioned file" > $testroot/wt/foop
537 echo "unversioned file" > $testroot/wt/epsilon/foo
538 echo "unversioned file" > $testroot/wt/epsilon/bar
539 echo "unversioned file" > $testroot/wt/epsilon/boo
540 echo "unversioned file" > $testroot/wt/epsilon/moo
541 mkdir -p $testroot/wt/epsilon/new/
542 echo "unversioned file" > $testroot/wt/epsilon/new/foo
543 echo "**/foo" > $testroot/wt/.cvsignore
544 echo "**/gamma" >> $testroot/wt/.cvsignore
545 echo "bar" > $testroot/wt/epsilon/.cvsignore
546 echo "moo" >> $testroot/wt/epsilon/.cvsignore
548 echo '? .cvsignore' > $testroot/stdout.expected
549 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
550 echo '? epsilon/boo' >> $testroot/stdout.expected
551 echo '? foop' >> $testroot/stdout.expected
552 (cd $testroot/wt && got status > $testroot/stdout)
554 cmp -s $testroot/stdout.expected $testroot/stdout
555 ret="$?"
556 if [ "$ret" != "0" ]; then
557 diff -u $testroot/stdout.expected $testroot/stdout
558 test_done "$testroot" "$ret"
559 return 1
560 fi
562 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
563 echo '? epsilon/boo' >> $testroot/stdout.expected
564 (cd $testroot/wt && got status epsilon > $testroot/stdout)
566 cmp -s $testroot/stdout.expected $testroot/stdout
567 ret="$?"
568 if [ "$ret" != "0" ]; then
569 diff -u $testroot/stdout.expected $testroot/stdout
570 test_done "$testroot" "$ret"
571 return 1
572 fi
574 echo -n '' > $testroot/stdout.expected
575 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
577 cmp -s $testroot/stdout.expected $testroot/stdout
578 ret="$?"
579 if [ "$ret" != "0" ]; then
580 diff -u $testroot/stdout.expected $testroot/stdout
581 test_done "$testroot" "$ret"
582 return 1
583 fi
585 echo '? .cvsignore' > $testroot/stdout.expected
586 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
587 echo '? epsilon/boo' >> $testroot/stdout.expected
588 echo '? foop' >> $testroot/stdout.expected
589 (cd $testroot/wt/gamma && got status > $testroot/stdout)
591 cmp -s $testroot/stdout.expected $testroot/stdout
592 ret="$?"
593 if [ "$ret" != "0" ]; then
594 diff -u $testroot/stdout.expected $testroot/stdout
595 test_done "$testroot" "$ret"
596 return 1
597 fi
599 cat > $testroot/stdout.expected <<EOF
600 ? .cvsignore
601 ? epsilon/.cvsignore
602 ? epsilon/bar
603 ? epsilon/boo
604 ? epsilon/foo
605 ? epsilon/moo
606 ? epsilon/new/foo
607 ? foo
608 ? foop
609 EOF
610 (cd $testroot/wt && got status -I > $testroot/stdout)
611 ret="$?"
612 if [ "$ret" != "0" ]; then
613 echo "got status failed unexpectedly" >&2
614 test_done "$testroot" "1"
615 return 1
616 fi
618 cmp -s $testroot/stdout.expected $testroot/stdout
619 ret="$?"
620 if [ "$ret" != "0" ]; then
621 diff -u $testroot/stdout.expected $testroot/stdout
622 fi
623 test_done "$testroot" "$ret"
626 test_status_gitignore() {
627 local testroot=`test_init status_gitignore`
629 got checkout $testroot/repo $testroot/wt > /dev/null
630 ret="$?"
631 if [ "$ret" != "0" ]; then
632 test_done "$testroot" "$ret"
633 return 1
634 fi
636 echo "unversioned file" > $testroot/wt/foo
637 echo "unversioned file" > $testroot/wt/foop
638 echo "unversioned file" > $testroot/wt/barp
639 echo "unversioned file" > $testroot/wt/epsilon/bar
640 echo "unversioned file" > $testroot/wt/epsilon/boo
641 echo "unversioned file" > $testroot/wt/epsilon/moo
642 mkdir -p $testroot/wt/a/b/c/
643 echo "unversioned file" > $testroot/wt/a/b/c/foo
644 echo "unversioned file" > $testroot/wt/a/b/c/zoo
645 echo "foo" > $testroot/wt/.gitignore
646 echo "bar*" >> $testroot/wt/.gitignore
647 echo "epsilon/**" >> $testroot/wt/.gitignore
648 echo "a/**/foo" >> $testroot/wt/.gitignore
649 echo "**/zoo" >> $testroot/wt/.gitignore
651 echo '? .gitignore' > $testroot/stdout.expected
652 echo '? foop' >> $testroot/stdout.expected
653 (cd $testroot/wt && got status > $testroot/stdout)
655 cmp -s $testroot/stdout.expected $testroot/stdout
656 ret="$?"
657 if [ "$ret" != "0" ]; then
658 diff -u $testroot/stdout.expected $testroot/stdout
659 test_done "$testroot" "$ret"
660 return 1
661 fi
663 echo '? .gitignore' > $testroot/stdout.expected
664 echo '? foop' >> $testroot/stdout.expected
665 (cd $testroot/wt/gamma && got status > $testroot/stdout)
667 cmp -s $testroot/stdout.expected $testroot/stdout
668 ret="$?"
669 if [ "$ret" != "0" ]; then
670 diff -u $testroot/stdout.expected $testroot/stdout
671 test_done "$testroot" "$ret"
672 return 1
673 fi
675 cat > $testroot/stdout.expected <<EOF
676 ? .gitignore
677 ? a/b/c/foo
678 ? a/b/c/zoo
679 ? barp
680 ? epsilon/bar
681 ? epsilon/boo
682 ? epsilon/moo
683 ? foo
684 ? foop
685 EOF
686 (cd $testroot/wt && got status -I > $testroot/stdout)
687 ret="$?"
688 if [ "$ret" != "0" ]; then
689 echo "got status failed unexpectedly" >&2
690 test_done "$testroot" "1"
691 return 1
692 fi
694 cmp -s $testroot/stdout.expected $testroot/stdout
695 ret="$?"
696 if [ "$ret" != "0" ]; then
697 diff -u $testroot/stdout.expected $testroot/stdout
698 fi
699 test_done "$testroot" "$ret"
702 test_status_status_code() {
703 local testroot=`test_init status_status_code`
705 got checkout $testroot/repo $testroot/wt > /dev/null
706 ret="$?"
707 if [ "$ret" != "0" ]; then
708 test_done "$testroot" "$ret"
709 return 1
710 fi
712 echo "modified alpha" > $testroot/wt/alpha
713 (cd $testroot/wt && got rm beta >/dev/null)
714 echo "unversioned file" > $testroot/wt/foo
715 rm $testroot/wt/epsilon/zeta
716 touch $testroot/wt/beta
717 echo "new file" > $testroot/wt/new
718 (cd $testroot/wt && got add new >/dev/null)
720 (cd $testroot/wt && got status -s xDM \
721 > $testroot/stdout 2> $testroot/stderr)
722 ret="$?"
723 if [ "$ret" = "0" ]; then
724 echo "status succeeded unexpectedly" >&2
725 test_done "$testroot" "1"
726 return 1
727 fi
729 echo "got: invalid status code 'x'" > $testroot/stderr.expected
730 cmp -s $testroot/stderr.expected $testroot/stderr
731 ret="$?"
732 if [ "$ret" != "0" ]; then
733 diff -u $testroot/stderr.expected $testroot/stderr
734 test_done "$testroot" "$ret"
735 return 1
736 fi
738 echo 'M alpha' > $testroot/stdout.expected
739 (cd $testroot/wt && got status -s M > $testroot/stdout)
740 cmp -s $testroot/stdout.expected $testroot/stdout
741 ret="$?"
742 if [ "$ret" != "0" ]; then
743 diff -u $testroot/stdout.expected $testroot/stdout
744 test_done "$testroot" "$ret"
745 return 1
746 fi
748 echo 'D beta' > $testroot/stdout.expected
749 (cd $testroot/wt && got status -s D > $testroot/stdout)
750 cmp -s $testroot/stdout.expected $testroot/stdout
751 ret="$?"
752 if [ "$ret" != "0" ]; then
753 diff -u $testroot/stdout.expected $testroot/stdout
754 test_done "$testroot" "$ret"
755 return 1
756 fi
758 echo '! epsilon/zeta' > $testroot/stdout.expected
759 echo '? foo' >> $testroot/stdout.expected
760 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
761 cmp -s $testroot/stdout.expected $testroot/stdout
762 ret="$?"
763 if [ "$ret" != "0" ]; then
764 diff -u $testroot/stdout.expected $testroot/stdout
765 test_done "$testroot" "$ret"
766 return 1
767 fi
769 echo 'A new' > $testroot/stdout.expected
770 (cd $testroot/wt && got status -s A > $testroot/stdout)
771 cmp -s $testroot/stdout.expected $testroot/stdout
772 ret="$?"
773 if [ "$ret" != "0" ]; then
774 diff -u $testroot/stdout.expected $testroot/stdout
775 test_done "$testroot" "$ret"
776 return 1
777 fi
779 (cd $testroot/wt && got stage new > $testroot/stdout)
781 echo ' A new' > $testroot/stdout.expected
782 (cd $testroot/wt && got status -s A > $testroot/stdout)
783 cmp -s $testroot/stdout.expected $testroot/stdout
784 ret="$?"
785 if [ "$ret" != "0" ]; then
786 diff -u $testroot/stdout.expected $testroot/stdout
787 test_done "$testroot" "$ret"
788 return 1
789 fi
791 echo 'changed file new' > $testroot/wt/new
793 echo 'MA new' > $testroot/stdout.expected
794 (cd $testroot/wt && got status -s A > $testroot/stdout)
795 cmp -s $testroot/stdout.expected $testroot/stdout
796 ret="$?"
797 if [ "$ret" != "0" ]; then
798 diff -u $testroot/stdout.expected $testroot/stdout
799 test_done "$testroot" "$ret"
800 return 1
801 fi
803 echo 'M alpha' > $testroot/stdout.expected
804 echo 'MA new' >> $testroot/stdout.expected
805 (cd $testroot/wt && got status -s M > $testroot/stdout)
806 cmp -s $testroot/stdout.expected $testroot/stdout
807 ret="$?"
808 if [ "$ret" != "0" ]; then
809 diff -u $testroot/stdout.expected $testroot/stdout
810 test_done "$testroot" "$ret"
811 return 1
812 fi
814 test_done "$testroot" "$ret"
817 test_status_suppress() {
818 local testroot=`test_init status_suppress`
820 got checkout $testroot/repo $testroot/wt > /dev/null
821 ret="$?"
822 if [ "$ret" != "0" ]; then
823 test_done "$testroot" "$ret"
824 return 1
825 fi
827 echo "modified alpha" > $testroot/wt/alpha
828 (cd $testroot/wt && got rm beta >/dev/null)
829 echo "unversioned file" > $testroot/wt/foo
830 rm $testroot/wt/epsilon/zeta
831 touch $testroot/wt/beta
832 echo "new file" > $testroot/wt/new
833 (cd $testroot/wt && got add new >/dev/null)
835 (cd $testroot/wt && got status -S A -s M \
836 > $testroot/stdout 2> $testroot/stderr)
837 ret="$?"
838 if [ "$ret" = "0" ]; then
839 echo "status succeeded unexpectedly" >&2
840 test_done "$testroot" "1"
841 return 1
842 fi
844 echo "got: -s and -S options are mutually exclusive" \
845 > $testroot/stderr.expected
846 cmp -s $testroot/stderr.expected $testroot/stderr
847 ret="$?"
848 if [ "$ret" != "0" ]; then
849 diff -u $testroot/stderr.expected $testroot/stderr
850 test_done "$testroot" "$ret"
851 return 1
852 fi
854 (cd $testroot/wt && got status -s A -S M \
855 > $testroot/stdout 2> $testroot/stderr)
856 ret="$?"
857 if [ "$ret" = "0" ]; then
858 echo "status succeeded unexpectedly" >&2
859 test_done "$testroot" "1"
860 return 1
861 fi
863 echo "got: -S and -s options are mutually exclusive" \
864 > $testroot/stderr.expected
865 cmp -s $testroot/stderr.expected $testroot/stderr
866 ret="$?"
867 if [ "$ret" != "0" ]; then
868 diff -u $testroot/stderr.expected $testroot/stderr
869 test_done "$testroot" "$ret"
870 return 1
871 fi
873 (cd $testroot/wt && got status -S xDM \
874 > $testroot/stdout 2> $testroot/stderr)
875 ret="$?"
876 if [ "$ret" = "0" ]; then
877 echo "status succeeded unexpectedly" >&2
878 test_done "$testroot" "1"
879 return 1
880 fi
882 echo "got: invalid status code 'x'" > $testroot/stderr.expected
883 cmp -s $testroot/stderr.expected $testroot/stderr
884 ret="$?"
885 if [ "$ret" != "0" ]; then
886 diff -u $testroot/stderr.expected $testroot/stderr
887 test_done "$testroot" "$ret"
888 return 1
889 fi
891 echo 'M alpha' > $testroot/stdout.expected
892 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
893 cmp -s $testroot/stdout.expected $testroot/stdout
894 ret="$?"
895 if [ "$ret" != "0" ]; then
896 diff -u $testroot/stdout.expected $testroot/stdout
897 test_done "$testroot" "$ret"
898 return 1
899 fi
901 echo 'D beta' > $testroot/stdout.expected
902 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
903 cmp -s $testroot/stdout.expected $testroot/stdout
904 ret="$?"
905 if [ "$ret" != "0" ]; then
906 diff -u $testroot/stdout.expected $testroot/stdout
907 test_done "$testroot" "$ret"
908 return 1
909 fi
911 echo '! epsilon/zeta' > $testroot/stdout.expected
912 echo '? foo' >> $testroot/stdout.expected
913 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
914 cmp -s $testroot/stdout.expected $testroot/stdout
915 ret="$?"
916 if [ "$ret" != "0" ]; then
917 diff -u $testroot/stdout.expected $testroot/stdout
918 test_done "$testroot" "$ret"
919 return 1
920 fi
922 echo 'A new' > $testroot/stdout.expected
923 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
924 cmp -s $testroot/stdout.expected $testroot/stdout
925 ret="$?"
926 if [ "$ret" != "0" ]; then
927 diff -u $testroot/stdout.expected $testroot/stdout
928 test_done "$testroot" "$ret"
929 return 1
930 fi
932 (cd $testroot/wt && got stage new > $testroot/stdout)
934 echo ' A new' > $testroot/stdout.expected
935 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
936 cmp -s $testroot/stdout.expected $testroot/stdout
937 ret="$?"
938 if [ "$ret" != "0" ]; then
939 diff -u $testroot/stdout.expected $testroot/stdout
940 test_done "$testroot" "$ret"
941 return 1
942 fi
944 echo 'changed file new' > $testroot/wt/new
946 echo 'M alpha' > $testroot/stdout.expected
947 echo 'MA new' >> $testroot/stdout.expected
948 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
949 cmp -s $testroot/stdout.expected $testroot/stdout
950 ret="$?"
951 if [ "$ret" != "0" ]; then
952 diff -u $testroot/stdout.expected $testroot/stdout
953 test_done "$testroot" "$ret"
954 return 1
955 fi
957 echo 'M alpha' > $testroot/stdout.expected
958 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
959 cmp -s $testroot/stdout.expected $testroot/stdout
960 ret="$?"
961 if [ "$ret" != "0" ]; then
962 diff -u $testroot/stdout.expected $testroot/stdout
963 test_done "$testroot" "$ret"
964 return 1
965 fi
967 rm $testroot/stdout.expected
968 touch $testroot/stdout.expected
970 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
971 cmp -s $testroot/stdout.expected $testroot/stdout
972 ret="$?"
973 if [ "$ret" != "0" ]; then
974 diff -u $testroot/stdout.expected $testroot/stdout
975 test_done "$testroot" "$ret"
976 return 1
977 fi
979 test_done "$testroot" "$ret"
982 test_status_empty_file() {
983 local testroot=`test_init status_empty_file`
985 got checkout $testroot/repo $testroot/wt > /dev/null
986 ret="$?"
987 if [ "$ret" != "0" ]; then
988 test_done "$testroot" "$ret"
989 return 1
990 fi
992 echo -n "" > $testroot/wt/empty
993 (cd $testroot/wt && got add empty >/dev/null)
995 echo 'A empty' > $testroot/stdout.expected
997 (cd $testroot/wt && got status > $testroot/stdout)
999 cmp -s $testroot/stdout.expected $testroot/stdout
1000 ret="$?"
1001 if [ "$ret" != "0" ]; then
1002 diff -u $testroot/stdout.expected $testroot/stdout
1003 test_done "$testroot" "$ret"
1004 return 1
1007 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1009 (cd $testroot/wt && got status > $testroot/stdout)
1011 echo -n > $testroot/stdout.expected
1012 cmp -s $testroot/stdout.expected $testroot/stdout
1013 ret="$?"
1014 if [ "$ret" != "0" ]; then
1015 diff -u $testroot/stdout.expected $testroot/stdout
1016 test_done "$testroot" "$ret"
1017 return 1
1020 # update the timestamp; this used to make the file show up as:
1021 # M empty
1022 # which should not happen
1023 touch $testroot/wt/empty
1025 (cd $testroot/wt && got status > $testroot/stdout)
1027 echo -n > $testroot/stdout.expected
1028 cmp -s $testroot/stdout.expected $testroot/stdout
1029 ret="$?"
1030 if [ "$ret" != "0" ]; then
1031 diff -u $testroot/stdout.expected $testroot/stdout
1033 test_done "$testroot" "$ret"
1036 test_parseargs "$@"
1037 run_test test_status_basic
1038 run_test test_status_subdir_no_mods
1039 run_test test_status_subdir_no_mods2
1040 run_test test_status_obstructed
1041 run_test test_status_shows_local_mods_after_update
1042 run_test test_status_unversioned_subdirs
1043 run_test test_status_symlink
1044 run_test test_status_shows_no_mods_after_complete_merge
1045 run_test test_status_shows_conflict
1046 run_test test_status_empty_dir
1047 run_test test_status_empty_dir_unversioned_file
1048 run_test test_status_many_paths
1049 run_test test_status_cvsignore
1050 run_test test_status_gitignore
1051 run_test test_status_status_code
1052 run_test test_status_suppress
1053 run_test test_status_empty_file