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 fi
156 test_done "$testroot" "$ret"
159 test_status_shows_local_mods_after_update() {
160 local testroot=`test_init status_shows_local_mods_after_update 1`
162 echo "1" > $testroot/repo/numbers
163 echo "2" >> $testroot/repo/numbers
164 echo "3" >> $testroot/repo/numbers
165 echo "4" >> $testroot/repo/numbers
166 echo "5" >> $testroot/repo/numbers
167 echo "6" >> $testroot/repo/numbers
168 echo "7" >> $testroot/repo/numbers
169 echo "8" >> $testroot/repo/numbers
170 (cd $testroot/repo && git add numbers)
171 git_commit $testroot/repo -m "added numbers file"
173 got checkout $testroot/repo $testroot/wt > /dev/null
174 ret="$?"
175 if [ "$ret" != "0" ]; then
176 test_done "$testroot" "$ret"
177 return 1
178 fi
180 sed -i 's/2/22/' $testroot/repo/numbers
181 git_commit $testroot/repo -m "modified line 2"
183 # modify line 7; both changes should merge cleanly
184 sed -i 's/7/77/' $testroot/wt/numbers
186 echo "G numbers" > $testroot/stdout.expected
187 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
188 git_show_head $testroot/repo >> $testroot/stdout.expected
189 echo >> $testroot/stdout.expected
191 (cd $testroot/wt && got update > $testroot/stdout)
193 cmp -s $testroot/stdout.expected $testroot/stdout
194 ret="$?"
195 if [ "$ret" != "0" ]; then
196 diff -u $testroot/stdout.expected $testroot/stdout
197 test_done "$testroot" "$ret"
198 return 1
199 fi
201 echo 'M numbers' > $testroot/stdout.expected
203 (cd $testroot/wt && got status > $testroot/stdout)
205 cmp -s $testroot/stdout.expected $testroot/stdout
206 ret="$?"
207 if [ "$ret" != "0" ]; then
208 diff -u $testroot/stdout.expected $testroot/stdout
209 fi
210 test_done "$testroot" "$ret"
213 test_status_unversioned_subdirs() {
214 local testroot=`test_init status_unversioned_subdirs 1`
216 mkdir $testroot/repo/cdfs/
217 touch $testroot/repo/cdfs/Makefile
218 mkdir $testroot/repo/common/
219 touch $testroot/repo/common/Makefile
220 mkdir $testroot/repo/iso/
221 touch $testroot/repo/iso/Makefile
222 mkdir $testroot/repo/ramdisk/
223 touch $testroot/repo/ramdisk/Makefile
224 touch $testroot/repo/ramdisk/list.local
225 mkdir $testroot/repo/ramdisk_cd/
226 touch $testroot/repo/ramdisk_cd/Makefile
227 touch $testroot/repo/ramdisk_cd/list.local
228 (cd $testroot/repo && git add .)
229 git_commit $testroot/repo -m "first commit"
231 got checkout $testroot/repo $testroot/wt > /dev/null
232 ret="$?"
233 if [ "$ret" != "0" ]; then
234 test_done "$testroot" "$ret"
235 return 1
236 fi
238 mkdir $testroot/wt/cdfs/obj
239 mkdir $testroot/wt/ramdisk/obj
240 mkdir $testroot/wt/ramdisk_cd/obj
241 mkdir $testroot/wt/iso/obj
243 echo -n > $testroot/stdout.expected
245 # This used to erroneously print:
247 # ! ramdisk_cd/Makefile
248 # ! ramdisk_cd/list.local
249 # ? ramdisk_cd/Makefile
250 # ? ramdisk_cd/list.local
251 (cd $testroot/wt && got status > $testroot/stdout)
253 cmp -s $testroot/stdout.expected $testroot/stdout
254 ret="$?"
255 if [ "$ret" != "0" ]; then
256 diff -u $testroot/stdout.expected $testroot/stdout
257 fi
258 test_done "$testroot" "$ret"
261 test_status_symlink() {
262 local testroot=`test_init status_symlink`
264 mkdir $testroot/repo/ramdisk/
265 touch $testroot/repo/ramdisk/Makefile
266 (cd $testroot/repo && ln -s alpha alpha.link)
267 (cd $testroot/repo && ln -s epsilon epsilon.link)
268 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
269 (cd $testroot/repo && git add .)
270 git_commit $testroot/repo -m "first commit"
272 got checkout $testroot/repo $testroot/wt > /dev/null
273 ret="$?"
274 if [ "$ret" != "0" ]; then
275 test_done "$testroot" "$ret"
276 return 1
277 fi
279 ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
281 echo "? ramdisk/obj" > $testroot/stdout.expected
283 (cd $testroot/wt && got status > $testroot/stdout)
285 cmp -s $testroot/stdout.expected $testroot/stdout
286 ret="$?"
287 if [ "$ret" != "0" ]; then
288 diff -u $testroot/stdout.expected $testroot/stdout
289 test_done "$testroot" "$ret"
290 return 1
291 fi
293 (cd $testroot/wt && ln -sf beta alpha.link)
294 (cd $testroot/wt && ln -sfT gamma epsilon.link)
296 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
297 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
298 (cd $testroot/wt && got add passwd.link epsilon/beta.link > /dev/null)
300 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
302 echo 'M alpha.link' > $testroot/stdout.expected
303 echo 'A epsilon/beta.link' >> $testroot/stdout.expected
304 echo 'M epsilon.link' >> $testroot/stdout.expected
305 echo 'D nonexistent.link' >> $testroot/stdout.expected
306 echo 'A passwd.link' >> $testroot/stdout.expected
307 echo "? ramdisk/obj" >> $testroot/stdout.expected
309 (cd $testroot/wt && got status > $testroot/stdout)
311 cmp -s $testroot/stdout.expected $testroot/stdout
312 ret="$?"
313 if [ "$ret" != "0" ]; then
314 diff -u $testroot/stdout.expected $testroot/stdout
315 fi
316 test_done "$testroot" "$ret"
319 test_status_shows_no_mods_after_complete_merge() {
320 local testroot=`test_init status_shows_no_mods_after_complete_merge 1`
322 # make this file larger than the usual blob buffer size of 8192
323 echo -n > $testroot/repo/numbers
324 for i in `jot 16384`; do
325 echo "$i" >> $testroot/repo/numbers
326 done
328 (cd $testroot/repo && git add numbers)
329 git_commit $testroot/repo -m "added numbers file"
331 got checkout $testroot/repo $testroot/wt > /dev/null
332 ret="$?"
333 if [ "$ret" != "0" ]; then
334 test_done "$testroot" "$ret"
335 return 1
336 fi
338 sed -i 's/2/22/' $testroot/repo/numbers
339 git_commit $testroot/repo -m "modified line 2"
341 sleep 1
342 # modify line 2 again; no local changes are left after merge
343 sed -i 's/2/22/' $testroot/wt/numbers
345 echo "G numbers" > $testroot/stdout.expected
346 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
347 git_show_head $testroot/repo >> $testroot/stdout.expected
348 echo >> $testroot/stdout.expected
350 (cd $testroot/wt && got update > $testroot/stdout)
352 cmp -s $testroot/stdout.expected $testroot/stdout
353 ret="$?"
354 if [ "$ret" != "0" ]; then
355 diff -u $testroot/stdout.expected $testroot/stdout
356 test_done "$testroot" "$ret"
357 return 1
358 fi
360 echo -n > $testroot/stdout.expected
362 (cd $testroot/wt && got status > $testroot/stdout)
364 cmp -s $testroot/stdout.expected $testroot/stdout
365 ret="$?"
366 if [ "$ret" != "0" ]; then
367 diff -u $testroot/stdout.expected $testroot/stdout
368 fi
369 test_done "$testroot" "$ret"
372 test_status_shows_conflict() {
373 local testroot=`test_init status_shows_conflict 1`
375 echo "1" > $testroot/repo/numbers
376 echo "2" >> $testroot/repo/numbers
377 echo "3" >> $testroot/repo/numbers
378 echo "4" >> $testroot/repo/numbers
379 echo "5" >> $testroot/repo/numbers
380 echo "6" >> $testroot/repo/numbers
381 echo "7" >> $testroot/repo/numbers
382 echo "8" >> $testroot/repo/numbers
383 (cd $testroot/repo && git add numbers)
384 git_commit $testroot/repo -m "added numbers file"
386 got checkout $testroot/repo $testroot/wt > /dev/null
387 ret="$?"
388 if [ "$ret" != "0" ]; then
389 test_done "$testroot" "$ret"
390 return 1
391 fi
393 sed -i 's/2/22/' $testroot/repo/numbers
394 git_commit $testroot/repo -m "modified line 2"
396 # modify line 2 in a conflicting way
397 sed -i 's/2/77/' $testroot/wt/numbers
399 echo "C numbers" > $testroot/stdout.expected
400 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
401 git_show_head $testroot/repo >> $testroot/stdout.expected
402 echo >> $testroot/stdout.expected
403 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
405 (cd $testroot/wt && got update > $testroot/stdout)
407 cmp -s $testroot/stdout.expected $testroot/stdout
408 ret="$?"
409 if [ "$ret" != "0" ]; then
410 diff -u $testroot/stdout.expected $testroot/stdout
411 test_done "$testroot" "$ret"
412 return 1
413 fi
415 echo 'C numbers' > $testroot/stdout.expected
417 (cd $testroot/wt && got status > $testroot/stdout)
419 cmp -s $testroot/stdout.expected $testroot/stdout
420 ret="$?"
421 if [ "$ret" != "0" ]; then
422 diff -u $testroot/stdout.expected $testroot/stdout
423 fi
424 test_done "$testroot" "$ret"
427 test_status_empty_dir() {
428 local testroot=`test_init status_empty_dir`
430 got checkout $testroot/repo $testroot/wt > /dev/null
431 ret="$?"
432 if [ "$ret" != "0" ]; then
433 test_done "$testroot" "$ret"
434 return 1
435 fi
437 rm $testroot/wt/epsilon/zeta
439 echo '! epsilon/zeta' > $testroot/stdout.expected
441 (cd $testroot/wt && got status epsilon > $testroot/stdout)
443 cmp -s $testroot/stdout.expected $testroot/stdout
444 ret="$?"
445 if [ "$ret" != "0" ]; then
446 diff -u $testroot/stdout.expected $testroot/stdout
447 fi
448 test_done "$testroot" "$ret"
451 test_status_empty_dir_unversioned_file() {
452 local testroot=`test_init status_empty_dir_unversioned_file`
454 got checkout $testroot/repo $testroot/wt > /dev/null
455 ret="$?"
456 if [ "$ret" != "0" ]; then
457 test_done "$testroot" "$ret"
458 return 1
459 fi
461 rm $testroot/wt/epsilon/zeta
462 touch $testroot/wt/epsilon/unversioned
464 echo '? epsilon/unversioned' > $testroot/stdout.expected
465 echo '! epsilon/zeta' >> $testroot/stdout.expected
467 (cd $testroot/wt && got status epsilon > $testroot/stdout)
469 cmp -s $testroot/stdout.expected $testroot/stdout
470 ret="$?"
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
473 fi
474 test_done "$testroot" "$ret"
477 test_status_many_paths() {
478 local testroot=`test_init status_many_paths`
480 got checkout $testroot/repo $testroot/wt > /dev/null
481 ret="$?"
482 if [ "$ret" != "0" ]; then
483 test_done "$testroot" "$ret"
484 return 1
485 fi
487 echo "modified alpha" > $testroot/wt/alpha
488 (cd $testroot/wt && got rm beta >/dev/null)
489 echo "unversioned file" > $testroot/wt/foo
490 rm $testroot/wt/epsilon/zeta
491 touch $testroot/wt/beta
492 echo "new file" > $testroot/wt/new
493 mkdir $testroot/wt/newdir
494 (cd $testroot/wt && got add new >/dev/null)
496 (cd $testroot/wt && got status newdir > $testroot/stdout.expected)
497 (cd $testroot/wt && got status alpha >> $testroot/stdout.expected)
498 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
499 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
500 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
501 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
502 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
504 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
505 > $testroot/stdout)
507 cmp -s $testroot/stdout.expected $testroot/stdout
508 ret="$?"
509 if [ "$ret" != "0" ]; then
510 diff -u $testroot/stdout.expected $testroot/stdout
511 fi
512 test_done "$testroot" "$ret"
515 test_status_cvsignore() {
516 local testroot=`test_init status_cvsignore`
518 got checkout $testroot/repo $testroot/wt > /dev/null
519 ret="$?"
520 if [ "$ret" != "0" ]; then
521 test_done "$testroot" "$ret"
522 return 1
523 fi
525 echo "unversioned file" > $testroot/wt/foo
526 echo "unversioned file" > $testroot/wt/foop
527 echo "unversioned file" > $testroot/wt/epsilon/foo
528 echo "unversioned file" > $testroot/wt/epsilon/bar
529 echo "unversioned file" > $testroot/wt/epsilon/boo
530 echo "unversioned file" > $testroot/wt/epsilon/moo
531 mkdir -p $testroot/wt/epsilon/new/
532 echo "unversioned file" > $testroot/wt/epsilon/new/foo
533 echo "**/foo" > $testroot/wt/.cvsignore
534 echo "bar" > $testroot/wt/epsilon/.cvsignore
535 echo "moo" >> $testroot/wt/epsilon/.cvsignore
537 echo '? .cvsignore' > $testroot/stdout.expected
538 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
539 echo '? epsilon/boo' >> $testroot/stdout.expected
540 echo '? foop' >> $testroot/stdout.expected
541 (cd $testroot/wt && got status > $testroot/stdout)
543 cmp -s $testroot/stdout.expected $testroot/stdout
544 ret="$?"
545 if [ "$ret" != "0" ]; then
546 diff -u $testroot/stdout.expected $testroot/stdout
547 test_done "$testroot" "$ret"
548 return 1
549 fi
551 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
552 echo '? epsilon/boo' >> $testroot/stdout.expected
553 (cd $testroot/wt && got status epsilon > $testroot/stdout)
555 cmp -s $testroot/stdout.expected $testroot/stdout
556 ret="$?"
557 if [ "$ret" != "0" ]; then
558 diff -u $testroot/stdout.expected $testroot/stdout
559 test_done "$testroot" "$ret"
560 return 1
561 fi
563 echo -n '' > $testroot/stdout.expected
564 (cd $testroot/wt && got status epsilon/new > $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 '? .cvsignore' > $testroot/stdout.expected
575 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
576 echo '? epsilon/boo' >> $testroot/stdout.expected
577 echo '? foop' >> $testroot/stdout.expected
578 (cd $testroot/wt/gamma && got status > $testroot/stdout)
580 cmp -s $testroot/stdout.expected $testroot/stdout
581 ret="$?"
582 if [ "$ret" != "0" ]; then
583 diff -u $testroot/stdout.expected $testroot/stdout
584 test_done "$testroot" "$ret"
585 return 1
586 fi
588 cat > $testroot/stdout.expected <<EOF
589 ? .cvsignore
590 ? epsilon/.cvsignore
591 ? epsilon/bar
592 ? epsilon/boo
593 ? epsilon/foo
594 ? epsilon/moo
595 ? epsilon/new/foo
596 ? foo
597 ? foop
598 EOF
599 (cd $testroot/wt && got status -I > $testroot/stdout)
600 ret="$?"
601 if [ "$ret" != "0" ]; then
602 echo "got status failed unexpectedly" >&2
603 test_done "$testroot" "1"
604 return 1
605 fi
607 cmp -s $testroot/stdout.expected $testroot/stdout
608 ret="$?"
609 if [ "$ret" != "0" ]; then
610 diff -u $testroot/stdout.expected $testroot/stdout
611 fi
612 test_done "$testroot" "$ret"
615 test_status_gitignore() {
616 local testroot=`test_init status_gitignore`
618 got checkout $testroot/repo $testroot/wt > /dev/null
619 ret="$?"
620 if [ "$ret" != "0" ]; then
621 test_done "$testroot" "$ret"
622 return 1
623 fi
625 echo "unversioned file" > $testroot/wt/foo
626 echo "unversioned file" > $testroot/wt/foop
627 echo "unversioned file" > $testroot/wt/barp
628 echo "unversioned file" > $testroot/wt/epsilon/bar
629 echo "unversioned file" > $testroot/wt/epsilon/boo
630 echo "unversioned file" > $testroot/wt/epsilon/moo
631 mkdir -p $testroot/wt/a/b/c/
632 echo "unversioned file" > $testroot/wt/a/b/c/foo
633 echo "unversioned file" > $testroot/wt/a/b/c/zoo
634 echo "foo" > $testroot/wt/.gitignore
635 echo "bar*" >> $testroot/wt/.gitignore
636 echo "epsilon/**" >> $testroot/wt/.gitignore
637 echo "a/**/foo" >> $testroot/wt/.gitignore
638 echo "**/zoo" >> $testroot/wt/.gitignore
640 echo '? .gitignore' > $testroot/stdout.expected
641 echo '? foop' >> $testroot/stdout.expected
642 (cd $testroot/wt && got status > $testroot/stdout)
644 cmp -s $testroot/stdout.expected $testroot/stdout
645 ret="$?"
646 if [ "$ret" != "0" ]; then
647 diff -u $testroot/stdout.expected $testroot/stdout
648 test_done "$testroot" "$ret"
649 return 1
650 fi
652 echo '? .gitignore' > $testroot/stdout.expected
653 echo '? foop' >> $testroot/stdout.expected
654 (cd $testroot/wt/gamma && got status > $testroot/stdout)
656 cmp -s $testroot/stdout.expected $testroot/stdout
657 ret="$?"
658 if [ "$ret" != "0" ]; then
659 diff -u $testroot/stdout.expected $testroot/stdout
660 test_done "$testroot" "$ret"
661 return 1
662 fi
664 cat > $testroot/stdout.expected <<EOF
665 ? .gitignore
666 ? a/b/c/foo
667 ? a/b/c/zoo
668 ? barp
669 ? epsilon/bar
670 ? epsilon/boo
671 ? epsilon/moo
672 ? foo
673 ? foop
674 EOF
675 (cd $testroot/wt && got status -I > $testroot/stdout)
676 ret="$?"
677 if [ "$ret" != "0" ]; then
678 echo "got status failed unexpectedly" >&2
679 test_done "$testroot" "1"
680 return 1
681 fi
683 cmp -s $testroot/stdout.expected $testroot/stdout
684 ret="$?"
685 if [ "$ret" != "0" ]; then
686 diff -u $testroot/stdout.expected $testroot/stdout
687 fi
688 test_done "$testroot" "$ret"
691 test_status_status_code() {
692 local testroot=`test_init status_status_code`
694 got checkout $testroot/repo $testroot/wt > /dev/null
695 ret="$?"
696 if [ "$ret" != "0" ]; then
697 test_done "$testroot" "$ret"
698 return 1
699 fi
701 echo "modified alpha" > $testroot/wt/alpha
702 (cd $testroot/wt && got rm beta >/dev/null)
703 echo "unversioned file" > $testroot/wt/foo
704 rm $testroot/wt/epsilon/zeta
705 touch $testroot/wt/beta
706 echo "new file" > $testroot/wt/new
707 (cd $testroot/wt && got add new >/dev/null)
709 (cd $testroot/wt && got status -s xDM \
710 > $testroot/stdout 2> $testroot/stderr)
711 ret="$?"
712 if [ "$ret" = "0" ]; then
713 echo "status succeeded unexpectedly" >&2
714 test_done "$testroot" "1"
715 return 1
716 fi
718 echo "got: invalid status code 'x'" > $testroot/stderr.expected
719 cmp -s $testroot/stderr.expected $testroot/stderr
720 ret="$?"
721 if [ "$ret" != "0" ]; then
722 diff -u $testroot/stderr.expected $testroot/stderr
723 test_done "$testroot" "$ret"
724 return 1
725 fi
727 echo 'M alpha' > $testroot/stdout.expected
728 (cd $testroot/wt && got status -s M > $testroot/stdout)
729 cmp -s $testroot/stdout.expected $testroot/stdout
730 ret="$?"
731 if [ "$ret" != "0" ]; then
732 diff -u $testroot/stdout.expected $testroot/stdout
733 test_done "$testroot" "$ret"
734 return 1
735 fi
737 echo 'D beta' > $testroot/stdout.expected
738 (cd $testroot/wt && got status -s D > $testroot/stdout)
739 cmp -s $testroot/stdout.expected $testroot/stdout
740 ret="$?"
741 if [ "$ret" != "0" ]; then
742 diff -u $testroot/stdout.expected $testroot/stdout
743 test_done "$testroot" "$ret"
744 return 1
745 fi
747 echo '! epsilon/zeta' > $testroot/stdout.expected
748 echo '? foo' >> $testroot/stdout.expected
749 (cd $testroot/wt && got status -s !\? > $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 'A new' > $testroot/stdout.expected
759 (cd $testroot/wt && got status -s A > $testroot/stdout)
760 cmp -s $testroot/stdout.expected $testroot/stdout
761 ret="$?"
762 if [ "$ret" != "0" ]; then
763 diff -u $testroot/stdout.expected $testroot/stdout
764 test_done "$testroot" "$ret"
765 return 1
766 fi
768 (cd $testroot/wt && got stage new > $testroot/stdout)
770 echo ' A new' > $testroot/stdout.expected
771 (cd $testroot/wt && got status -s A > $testroot/stdout)
772 cmp -s $testroot/stdout.expected $testroot/stdout
773 ret="$?"
774 if [ "$ret" != "0" ]; then
775 diff -u $testroot/stdout.expected $testroot/stdout
776 test_done "$testroot" "$ret"
777 return 1
778 fi
780 echo 'changed file new' > $testroot/wt/new
782 echo 'MA new' > $testroot/stdout.expected
783 (cd $testroot/wt && got status -s A > $testroot/stdout)
784 cmp -s $testroot/stdout.expected $testroot/stdout
785 ret="$?"
786 if [ "$ret" != "0" ]; then
787 diff -u $testroot/stdout.expected $testroot/stdout
788 test_done "$testroot" "$ret"
789 return 1
790 fi
792 echo 'M alpha' > $testroot/stdout.expected
793 echo 'MA new' >> $testroot/stdout.expected
794 (cd $testroot/wt && got status -s M > $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 test_done "$testroot" "$ret"
806 test_status_suppress() {
807 local testroot=`test_init status_suppress`
809 got checkout $testroot/repo $testroot/wt > /dev/null
810 ret="$?"
811 if [ "$ret" != "0" ]; then
812 test_done "$testroot" "$ret"
813 return 1
814 fi
816 echo "modified alpha" > $testroot/wt/alpha
817 (cd $testroot/wt && got rm beta >/dev/null)
818 echo "unversioned file" > $testroot/wt/foo
819 rm $testroot/wt/epsilon/zeta
820 touch $testroot/wt/beta
821 echo "new file" > $testroot/wt/new
822 (cd $testroot/wt && got add new >/dev/null)
824 (cd $testroot/wt && got status -S A -s M \
825 > $testroot/stdout 2> $testroot/stderr)
826 ret="$?"
827 if [ "$ret" = "0" ]; then
828 echo "status succeeded unexpectedly" >&2
829 test_done "$testroot" "1"
830 return 1
831 fi
833 echo "got: -s and -S options are mutually exclusive" \
834 > $testroot/stderr.expected
835 cmp -s $testroot/stderr.expected $testroot/stderr
836 ret="$?"
837 if [ "$ret" != "0" ]; then
838 diff -u $testroot/stderr.expected $testroot/stderr
839 test_done "$testroot" "$ret"
840 return 1
841 fi
843 (cd $testroot/wt && got status -s A -S M \
844 > $testroot/stdout 2> $testroot/stderr)
845 ret="$?"
846 if [ "$ret" = "0" ]; then
847 echo "status succeeded unexpectedly" >&2
848 test_done "$testroot" "1"
849 return 1
850 fi
852 echo "got: -S and -s options are mutually exclusive" \
853 > $testroot/stderr.expected
854 cmp -s $testroot/stderr.expected $testroot/stderr
855 ret="$?"
856 if [ "$ret" != "0" ]; then
857 diff -u $testroot/stderr.expected $testroot/stderr
858 test_done "$testroot" "$ret"
859 return 1
860 fi
862 (cd $testroot/wt && got status -S xDM \
863 > $testroot/stdout 2> $testroot/stderr)
864 ret="$?"
865 if [ "$ret" = "0" ]; then
866 echo "status succeeded unexpectedly" >&2
867 test_done "$testroot" "1"
868 return 1
869 fi
871 echo "got: invalid status code 'x'" > $testroot/stderr.expected
872 cmp -s $testroot/stderr.expected $testroot/stderr
873 ret="$?"
874 if [ "$ret" != "0" ]; then
875 diff -u $testroot/stderr.expected $testroot/stderr
876 test_done "$testroot" "$ret"
877 return 1
878 fi
880 echo 'M alpha' > $testroot/stdout.expected
881 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
882 cmp -s $testroot/stdout.expected $testroot/stdout
883 ret="$?"
884 if [ "$ret" != "0" ]; then
885 diff -u $testroot/stdout.expected $testroot/stdout
886 test_done "$testroot" "$ret"
887 return 1
888 fi
890 echo 'D beta' > $testroot/stdout.expected
891 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
892 cmp -s $testroot/stdout.expected $testroot/stdout
893 ret="$?"
894 if [ "$ret" != "0" ]; then
895 diff -u $testroot/stdout.expected $testroot/stdout
896 test_done "$testroot" "$ret"
897 return 1
898 fi
900 echo '! epsilon/zeta' > $testroot/stdout.expected
901 echo '? foo' >> $testroot/stdout.expected
902 (cd $testroot/wt && got status -S MDA > $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 'A new' > $testroot/stdout.expected
912 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
913 cmp -s $testroot/stdout.expected $testroot/stdout
914 ret="$?"
915 if [ "$ret" != "0" ]; then
916 diff -u $testroot/stdout.expected $testroot/stdout
917 test_done "$testroot" "$ret"
918 return 1
919 fi
921 (cd $testroot/wt && got stage new > $testroot/stdout)
923 echo ' A new' > $testroot/stdout.expected
924 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
925 cmp -s $testroot/stdout.expected $testroot/stdout
926 ret="$?"
927 if [ "$ret" != "0" ]; then
928 diff -u $testroot/stdout.expected $testroot/stdout
929 test_done "$testroot" "$ret"
930 return 1
931 fi
933 echo 'changed file new' > $testroot/wt/new
935 echo 'M alpha' > $testroot/stdout.expected
936 echo 'MA new' >> $testroot/stdout.expected
937 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
938 cmp -s $testroot/stdout.expected $testroot/stdout
939 ret="$?"
940 if [ "$ret" != "0" ]; then
941 diff -u $testroot/stdout.expected $testroot/stdout
942 test_done "$testroot" "$ret"
943 return 1
944 fi
946 echo 'M alpha' > $testroot/stdout.expected
947 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
948 cmp -s $testroot/stdout.expected $testroot/stdout
949 ret="$?"
950 if [ "$ret" != "0" ]; then
951 diff -u $testroot/stdout.expected $testroot/stdout
952 test_done "$testroot" "$ret"
953 return 1
954 fi
956 rm $testroot/stdout.expected
957 touch $testroot/stdout.expected
959 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
960 cmp -s $testroot/stdout.expected $testroot/stdout
961 ret="$?"
962 if [ "$ret" != "0" ]; then
963 diff -u $testroot/stdout.expected $testroot/stdout
964 test_done "$testroot" "$ret"
965 return 1
966 fi
968 test_done "$testroot" "$ret"
971 test_status_empty_file() {
972 local testroot=`test_init status_empty_file`
974 got checkout $testroot/repo $testroot/wt > /dev/null
975 ret="$?"
976 if [ "$ret" != "0" ]; then
977 test_done "$testroot" "$ret"
978 return 1
979 fi
981 echo -n "" > $testroot/wt/empty
982 (cd $testroot/wt && got add empty >/dev/null)
984 echo 'A empty' > $testroot/stdout.expected
986 (cd $testroot/wt && got status > $testroot/stdout)
988 cmp -s $testroot/stdout.expected $testroot/stdout
989 ret="$?"
990 if [ "$ret" != "0" ]; then
991 diff -u $testroot/stdout.expected $testroot/stdout
992 test_done "$testroot" "$ret"
993 return 1
994 fi
996 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
998 (cd $testroot/wt && got status > $testroot/stdout)
1000 echo -n > $testroot/stdout.expected
1001 cmp -s $testroot/stdout.expected $testroot/stdout
1002 ret="$?"
1003 if [ "$ret" != "0" ]; then
1004 diff -u $testroot/stdout.expected $testroot/stdout
1005 test_done "$testroot" "$ret"
1006 return 1
1009 # update the timestamp; this used to make the file show up as:
1010 # M empty
1011 # which should not happen
1012 touch $testroot/wt/empty
1014 (cd $testroot/wt && got status > $testroot/stdout)
1016 echo -n > $testroot/stdout.expected
1017 cmp -s $testroot/stdout.expected $testroot/stdout
1018 ret="$?"
1019 if [ "$ret" != "0" ]; then
1020 diff -u $testroot/stdout.expected $testroot/stdout
1022 test_done "$testroot" "$ret"
1025 test_parseargs "$@"
1026 run_test test_status_basic
1027 run_test test_status_subdir_no_mods
1028 run_test test_status_subdir_no_mods2
1029 run_test test_status_obstructed
1030 run_test test_status_shows_local_mods_after_update
1031 run_test test_status_unversioned_subdirs
1032 run_test test_status_symlink
1033 run_test test_status_shows_no_mods_after_complete_merge
1034 run_test test_status_shows_conflict
1035 run_test test_status_empty_dir
1036 run_test test_status_empty_dir_unversioned_file
1037 run_test test_status_many_paths
1038 run_test test_status_cvsignore
1039 run_test test_status_gitignore
1040 run_test test_status_status_code
1041 run_test test_status_suppress
1042 run_test test_status_empty_file