Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 test_status_basic() {
20 local testroot=`test_init status_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret=$?
24 if [ $ret -ne 0 ]; then
25 test_done "$testroot" "$ret"
26 return 1
27 fi
29 echo "modified alpha" > $testroot/wt/alpha
30 (cd $testroot/wt && got rm beta >/dev/null)
31 echo "unversioned file" > $testroot/wt/foo
32 rm $testroot/wt/epsilon/zeta
33 touch $testroot/wt/beta
34 echo "new file" > $testroot/wt/new
35 (cd $testroot/wt && got add new >/dev/null)
36 mkdir -m 0000 $testroot/wt/bar
38 echo 'M alpha' > $testroot/stdout.expected
39 echo 'D beta' >> $testroot/stdout.expected
40 echo '! epsilon/zeta' >> $testroot/stdout.expected
41 echo '? foo' >> $testroot/stdout.expected
42 echo 'A new' >> $testroot/stdout.expected
44 (cd $testroot/wt && got status > $testroot/stdout)
46 cmp -s $testroot/stdout.expected $testroot/stdout
47 ret=$?
48 if [ $ret -ne 0 ]; then
49 diff -u $testroot/stdout.expected $testroot/stdout
50 fi
51 chmod 700 $testroot/wt/bar
52 rmdir $testroot/wt/bar
53 test_done "$testroot" "$ret"
54 }
56 test_status_subdir_no_mods() {
57 local testroot=`test_init status_subdir_no_mods 1`
59 mkdir $testroot/repo/Basic/
60 mkdir $testroot/repo/Basic/Targets/
61 touch $testroot/repo/Basic/Targets/AArch64.cpp
62 touch $testroot/repo/Basic/Targets.cpp
63 touch $testroot/repo/Basic/Targets.h
64 (cd $testroot/repo && git add .)
65 git_commit $testroot/repo -m "add subdir with files"
67 got checkout $testroot/repo $testroot/wt > /dev/null
68 ret=$?
69 if [ $ret -ne 0 ]; then
70 test_done "$testroot" "$ret"
71 return 1
72 fi
74 touch $testroot/stdout.expected
76 # This used to erroneously print:
77 #
78 # ! Basic/Targets.cpp
79 # ? Basic/Targets.cpp
80 (cd $testroot/wt && got status > $testroot/stdout)
82 cmp -s $testroot/stdout.expected $testroot/stdout
83 ret=$?
84 if [ $ret -ne 0 ]; then
85 diff -u $testroot/stdout.expected $testroot/stdout
86 fi
87 test_done "$testroot" "$ret"
88 }
90 test_status_subdir_no_mods2() {
91 local testroot=`test_init status_subdir_no_mods2 1`
93 mkdir $testroot/repo/AST
94 touch $testroot/repo/AST/APValue.cpp
95 mkdir $testroot/repo/ASTMatchers
96 touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
97 mkdir $testroot/repo/Frontend
98 touch $testroot/repo/Frontend/ASTConsumers.cpp
99 mkdir $testroot/repo/Frontend/Rewrite
100 touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
101 mkdir $testroot/repo/FrontendTool
102 touch $testroot/repo/FrontendTool/CMakeLists.txt
103 touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
104 (cd $testroot/repo && git add .)
105 git_commit $testroot/repo -m "add subdir with files"
107 got checkout $testroot/repo $testroot/wt > /dev/null
108 ret=$?
109 if [ $ret -ne 0 ]; then
110 test_done "$testroot" "$ret"
111 return 1
112 fi
114 touch $testroot/stdout.expected
116 # This used to erroneously print:
118 # ! AST/APValue.cpp
119 # ? AST/APValue.cpp
120 # ! Frontend/ASTConsumers.cpp
121 # ! Frontend/Rewrite/CMakeLists.txt
122 # ? Frontend/ASTConsumers.cpp
123 # ? Frontend/Rewrite/CMakeLists.txt
124 (cd $testroot/wt && got status > $testroot/stdout)
126 cmp -s $testroot/stdout.expected $testroot/stdout
127 ret=$?
128 if [ $ret -ne 0 ]; then
129 diff -u $testroot/stdout.expected $testroot/stdout
130 fi
131 test_done "$testroot" "$ret"
134 test_status_obstructed() {
135 local testroot=`test_init status_obstructed`
137 got checkout $testroot/repo $testroot/wt > /dev/null
138 ret=$?
139 if [ $ret -ne 0 ]; then
140 test_done "$testroot" "$ret"
141 return 1
142 fi
144 rm $testroot/wt/epsilon/zeta
145 mkdir $testroot/wt/epsilon/zeta
147 echo '~ epsilon/zeta' > $testroot/stdout.expected
149 (cd $testroot/wt && got status > $testroot/stdout)
151 cmp -s $testroot/stdout.expected $testroot/stdout
152 ret=$?
153 if [ $ret -ne 0 ]; then
154 diff -u $testroot/stdout.expected $testroot/stdout
155 test_done "$testroot" "$ret"
156 return 1
157 fi
159 (cd $testroot/wt && got status epsilon/zeta > $testroot/stdout)
161 cmp -s $testroot/stdout.expected $testroot/stdout
162 ret=$?
163 if [ $ret -ne 0 ]; then
164 diff -u $testroot/stdout.expected $testroot/stdout
165 fi
166 test_done "$testroot" "$ret"
169 test_status_shows_local_mods_after_update() {
170 local testroot=`test_init status_shows_local_mods_after_update 1`
172 echo "1" > $testroot/repo/numbers
173 echo "2" >> $testroot/repo/numbers
174 echo "3" >> $testroot/repo/numbers
175 echo "4" >> $testroot/repo/numbers
176 echo "5" >> $testroot/repo/numbers
177 echo "6" >> $testroot/repo/numbers
178 echo "7" >> $testroot/repo/numbers
179 echo "8" >> $testroot/repo/numbers
180 (cd $testroot/repo && git add numbers)
181 git_commit $testroot/repo -m "added numbers file"
183 got checkout $testroot/repo $testroot/wt > /dev/null
184 ret=$?
185 if [ $ret -ne 0 ]; then
186 test_done "$testroot" "$ret"
187 return 1
188 fi
190 sed -i 's/2/22/' $testroot/repo/numbers
191 git_commit $testroot/repo -m "modified line 2"
193 # modify line 7; both changes should merge cleanly
194 sed -i 's/7/77/' $testroot/wt/numbers
196 echo "G numbers" > $testroot/stdout.expected
197 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
198 git_show_head $testroot/repo >> $testroot/stdout.expected
199 echo >> $testroot/stdout.expected
201 (cd $testroot/wt && got update > $testroot/stdout)
203 cmp -s $testroot/stdout.expected $testroot/stdout
204 ret=$?
205 if [ $ret -ne 0 ]; then
206 diff -u $testroot/stdout.expected $testroot/stdout
207 test_done "$testroot" "$ret"
208 return 1
209 fi
211 echo 'M numbers' > $testroot/stdout.expected
213 (cd $testroot/wt && got status > $testroot/stdout)
215 cmp -s $testroot/stdout.expected $testroot/stdout
216 ret=$?
217 if [ $ret -ne 0 ]; then
218 diff -u $testroot/stdout.expected $testroot/stdout
219 fi
220 test_done "$testroot" "$ret"
223 test_status_unversioned_subdirs() {
224 local testroot=`test_init status_unversioned_subdirs 1`
226 mkdir $testroot/repo/cdfs/
227 touch $testroot/repo/cdfs/Makefile
228 mkdir $testroot/repo/common/
229 touch $testroot/repo/common/Makefile
230 mkdir $testroot/repo/iso/
231 touch $testroot/repo/iso/Makefile
232 mkdir $testroot/repo/ramdisk/
233 touch $testroot/repo/ramdisk/Makefile
234 touch $testroot/repo/ramdisk/list.local
235 mkdir $testroot/repo/ramdisk_cd/
236 touch $testroot/repo/ramdisk_cd/Makefile
237 touch $testroot/repo/ramdisk_cd/list.local
238 (cd $testroot/repo && git add .)
239 git_commit $testroot/repo -m "first commit"
241 got checkout $testroot/repo $testroot/wt > /dev/null
242 ret=$?
243 if [ $ret -ne 0 ]; then
244 test_done "$testroot" "$ret"
245 return 1
246 fi
248 mkdir $testroot/wt/cdfs/obj
249 mkdir $testroot/wt/ramdisk/obj
250 mkdir $testroot/wt/ramdisk_cd/obj
251 mkdir $testroot/wt/iso/obj
253 echo -n > $testroot/stdout.expected
255 # This used to erroneously print:
257 # ! ramdisk_cd/Makefile
258 # ! ramdisk_cd/list.local
259 # ? ramdisk_cd/Makefile
260 # ? ramdisk_cd/list.local
261 (cd $testroot/wt && got status > $testroot/stdout)
263 cmp -s $testroot/stdout.expected $testroot/stdout
264 ret=$?
265 if [ $ret -ne 0 ]; then
266 diff -u $testroot/stdout.expected $testroot/stdout
267 fi
268 test_done "$testroot" "$ret"
271 test_status_symlink() {
272 local testroot=`test_init status_symlink`
274 mkdir $testroot/repo/ramdisk/
275 touch $testroot/repo/ramdisk/Makefile
276 (cd $testroot/repo && ln -s alpha alpha.link)
277 (cd $testroot/repo && ln -s epsilon epsilon.link)
278 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
279 (cd $testroot/repo && git add .)
280 git_commit $testroot/repo -m "first commit"
282 got checkout $testroot/repo $testroot/wt > /dev/null
283 ret=$?
284 if [ $ret -ne 0 ]; then
285 test_done "$testroot" "$ret"
286 return 1
287 fi
289 ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
291 echo "? ramdisk/obj" > $testroot/stdout.expected
293 (cd $testroot/wt && got status > $testroot/stdout)
295 cmp -s $testroot/stdout.expected $testroot/stdout
296 ret=$?
297 if [ $ret -ne 0 ]; then
298 diff -u $testroot/stdout.expected $testroot/stdout
299 test_done "$testroot" "$ret"
300 return 1
301 fi
303 (cd $testroot/wt && ln -sf beta alpha.link)
304 (cd $testroot/wt && ln -sfh gamma epsilon.link)
306 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
307 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
308 (cd $testroot/wt && got add passwd.link epsilon/beta.link > /dev/null)
310 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
312 echo 'M alpha.link' > $testroot/stdout.expected
313 echo 'A epsilon/beta.link' >> $testroot/stdout.expected
314 echo 'M epsilon.link' >> $testroot/stdout.expected
315 echo 'D nonexistent.link' >> $testroot/stdout.expected
316 echo 'A passwd.link' >> $testroot/stdout.expected
317 echo "? ramdisk/obj" >> $testroot/stdout.expected
319 (cd $testroot/wt && got status > $testroot/stdout)
321 cmp -s $testroot/stdout.expected $testroot/stdout
322 ret=$?
323 if [ $ret -ne 0 ]; then
324 diff -u $testroot/stdout.expected $testroot/stdout
325 fi
326 test_done "$testroot" "$ret"
329 test_status_shows_no_mods_after_complete_merge() {
330 local testroot=`test_init status_shows_no_mods_after_complete_merge 1`
332 # make this file larger than the usual blob buffer size of 8192
333 jot 16384 > $testroot/repo/numbers
335 (cd $testroot/repo && git add numbers)
336 git_commit $testroot/repo -m "added numbers file"
338 got checkout $testroot/repo $testroot/wt > /dev/null
339 ret=$?
340 if [ $ret -ne 0 ]; then
341 test_done "$testroot" "$ret"
342 return 1
343 fi
345 sed -i 's/2/22/' $testroot/repo/numbers
346 git_commit $testroot/repo -m "modified line 2"
348 sleep 1
349 # modify line 2 again; no local changes are left after merge
350 sed -i 's/2/22/' $testroot/wt/numbers
352 echo "G numbers" > $testroot/stdout.expected
353 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
354 git_show_head $testroot/repo >> $testroot/stdout.expected
355 echo >> $testroot/stdout.expected
357 (cd $testroot/wt && got update > $testroot/stdout)
359 cmp -s $testroot/stdout.expected $testroot/stdout
360 ret=$?
361 if [ $ret -ne 0 ]; then
362 diff -u $testroot/stdout.expected $testroot/stdout
363 test_done "$testroot" "$ret"
364 return 1
365 fi
367 echo -n > $testroot/stdout.expected
369 (cd $testroot/wt && got status > $testroot/stdout)
371 cmp -s $testroot/stdout.expected $testroot/stdout
372 ret=$?
373 if [ $ret -ne 0 ]; then
374 diff -u $testroot/stdout.expected $testroot/stdout
375 fi
376 test_done "$testroot" "$ret"
379 test_status_shows_conflict() {
380 local testroot=`test_init status_shows_conflict 1`
382 echo "1" > $testroot/repo/numbers
383 echo "2" >> $testroot/repo/numbers
384 echo "3" >> $testroot/repo/numbers
385 echo "4" >> $testroot/repo/numbers
386 echo "5" >> $testroot/repo/numbers
387 echo "6" >> $testroot/repo/numbers
388 echo "7" >> $testroot/repo/numbers
389 echo "8" >> $testroot/repo/numbers
390 (cd $testroot/repo && git add numbers)
391 git_commit $testroot/repo -m "added numbers file"
393 got checkout $testroot/repo $testroot/wt > /dev/null
394 ret=$?
395 if [ $ret -ne 0 ]; then
396 test_done "$testroot" "$ret"
397 return 1
398 fi
400 sed -i 's/2/22/' $testroot/repo/numbers
401 git_commit $testroot/repo -m "modified line 2"
403 # modify line 2 in a conflicting way
404 sed -i 's/2/77/' $testroot/wt/numbers
406 echo "C numbers" > $testroot/stdout.expected
407 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
408 git_show_head $testroot/repo >> $testroot/stdout.expected
409 echo >> $testroot/stdout.expected
410 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
412 (cd $testroot/wt && got update > $testroot/stdout)
414 cmp -s $testroot/stdout.expected $testroot/stdout
415 ret=$?
416 if [ $ret -ne 0 ]; then
417 diff -u $testroot/stdout.expected $testroot/stdout
418 test_done "$testroot" "$ret"
419 return 1
420 fi
422 echo 'C numbers' > $testroot/stdout.expected
424 (cd $testroot/wt && got status > $testroot/stdout)
426 cmp -s $testroot/stdout.expected $testroot/stdout
427 ret=$?
428 if [ $ret -ne 0 ]; then
429 diff -u $testroot/stdout.expected $testroot/stdout
430 fi
431 test_done "$testroot" "$ret"
434 test_status_empty_dir() {
435 local testroot=`test_init status_empty_dir`
437 got checkout $testroot/repo $testroot/wt > /dev/null
438 ret=$?
439 if [ $ret -ne 0 ]; then
440 test_done "$testroot" "$ret"
441 return 1
442 fi
444 rm $testroot/wt/epsilon/zeta
446 echo '! epsilon/zeta' > $testroot/stdout.expected
448 (cd $testroot/wt && got status epsilon > $testroot/stdout)
450 cmp -s $testroot/stdout.expected $testroot/stdout
451 ret=$?
452 if [ $ret -ne 0 ]; then
453 diff -u $testroot/stdout.expected $testroot/stdout
454 fi
455 test_done "$testroot" "$ret"
458 test_status_empty_dir_unversioned_file() {
459 local testroot=`test_init status_empty_dir_unversioned_file`
461 got checkout $testroot/repo $testroot/wt > /dev/null
462 ret=$?
463 if [ $ret -ne 0 ]; then
464 test_done "$testroot" "$ret"
465 return 1
466 fi
468 rm $testroot/wt/epsilon/zeta
469 touch $testroot/wt/epsilon/unversioned
471 echo '? epsilon/unversioned' > $testroot/stdout.expected
472 echo '! epsilon/zeta' >> $testroot/stdout.expected
474 (cd $testroot/wt && got status epsilon > $testroot/stdout)
476 cmp -s $testroot/stdout.expected $testroot/stdout
477 ret=$?
478 if [ $ret -ne 0 ]; then
479 diff -u $testroot/stdout.expected $testroot/stdout
480 fi
481 test_done "$testroot" "$ret"
484 test_status_many_paths() {
485 local testroot=`test_init status_many_paths`
487 got checkout $testroot/repo $testroot/wt > /dev/null
488 ret=$?
489 if [ $ret -ne 0 ]; then
490 test_done "$testroot" "$ret"
491 return 1
492 fi
494 echo "modified alpha" > $testroot/wt/alpha
495 (cd $testroot/wt && got rm beta >/dev/null)
496 echo "unversioned file" > $testroot/wt/foo
497 rm $testroot/wt/epsilon/zeta
498 touch $testroot/wt/beta
499 echo "new file" > $testroot/wt/new
500 mkdir $testroot/wt/newdir
501 (cd $testroot/wt && got add new >/dev/null)
503 (cd $testroot/wt && got status alpha > $testroot/stdout.expected)
504 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
505 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
506 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
507 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
508 (cd $testroot/wt && got status newdir >> $testroot/stdout.expected)
509 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
511 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
512 > $testroot/stdout)
514 cmp -s $testroot/stdout.expected $testroot/stdout
515 ret=$?
516 if [ $ret -ne 0 ]; then
517 diff -u $testroot/stdout.expected $testroot/stdout
518 fi
519 test_done "$testroot" "$ret"
522 test_status_cvsignore() {
523 local testroot=`test_init status_cvsignore`
525 got checkout $testroot/repo $testroot/wt > /dev/null
526 ret=$?
527 if [ $ret -ne 0 ]; then
528 test_done "$testroot" "$ret"
529 return 1
530 fi
532 echo "unversioned file" > $testroot/wt/foo
533 echo "unversioned file" > $testroot/wt/foop
534 echo "unversioned file" > $testroot/wt/epsilon/foo
535 echo "unversioned file" > $testroot/wt/epsilon/bar
536 echo "unversioned file" > $testroot/wt/epsilon/boo
537 echo "unversioned file" > $testroot/wt/epsilon/moo
538 mkdir -p $testroot/wt/epsilon/new/
539 echo "unversioned file" > $testroot/wt/epsilon/new/foo
540 echo "**/foo" > $testroot/wt/.cvsignore
541 echo "**/gamma" >> $testroot/wt/.cvsignore
542 echo "bar" > $testroot/wt/epsilon/.cvsignore
543 echo "moo" >> $testroot/wt/epsilon/.cvsignore
545 echo '? .cvsignore' > $testroot/stdout.expected
546 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
547 echo '? epsilon/boo' >> $testroot/stdout.expected
548 echo '? foop' >> $testroot/stdout.expected
549 (cd $testroot/wt && got status > $testroot/stdout)
551 cmp -s $testroot/stdout.expected $testroot/stdout
552 ret=$?
553 if [ $ret -ne 0 ]; then
554 diff -u $testroot/stdout.expected $testroot/stdout
555 test_done "$testroot" "$ret"
556 return 1
557 fi
559 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
560 echo '? epsilon/boo' >> $testroot/stdout.expected
561 (cd $testroot/wt && got status epsilon > $testroot/stdout)
563 cmp -s $testroot/stdout.expected $testroot/stdout
564 ret=$?
565 if [ $ret -ne 0 ]; then
566 diff -u $testroot/stdout.expected $testroot/stdout
567 test_done "$testroot" "$ret"
568 return 1
569 fi
571 echo -n '' > $testroot/stdout.expected
572 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
574 cmp -s $testroot/stdout.expected $testroot/stdout
575 ret=$?
576 if [ $ret -ne 0 ]; then
577 diff -u $testroot/stdout.expected $testroot/stdout
578 test_done "$testroot" "$ret"
579 return 1
580 fi
582 echo '? .cvsignore' > $testroot/stdout.expected
583 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
584 echo '? epsilon/boo' >> $testroot/stdout.expected
585 echo '? foop' >> $testroot/stdout.expected
586 (cd $testroot/wt/gamma && got status > $testroot/stdout)
588 cmp -s $testroot/stdout.expected $testroot/stdout
589 ret=$?
590 if [ $ret -ne 0 ]; then
591 diff -u $testroot/stdout.expected $testroot/stdout
592 test_done "$testroot" "$ret"
593 return 1
594 fi
596 cat > $testroot/stdout.expected <<EOF
597 ? .cvsignore
598 ? epsilon/.cvsignore
599 ? epsilon/bar
600 ? epsilon/boo
601 ? epsilon/foo
602 ? epsilon/moo
603 ? epsilon/new/foo
604 ? foo
605 ? foop
606 EOF
607 (cd $testroot/wt && got status -I > $testroot/stdout)
608 ret=$?
609 if [ $ret -ne 0 ]; then
610 echo "got status failed unexpectedly" >&2
611 test_done "$testroot" "1"
612 return 1
613 fi
615 cmp -s $testroot/stdout.expected $testroot/stdout
616 ret=$?
617 if [ $ret -ne 0 ]; then
618 diff -u $testroot/stdout.expected $testroot/stdout
619 fi
620 test_done "$testroot" "$ret"
623 test_status_gitignore() {
624 local testroot=`test_init status_gitignore`
626 got checkout $testroot/repo $testroot/wt > /dev/null
627 ret=$?
628 if [ $ret -ne 0 ]; then
629 test_done "$testroot" "$ret"
630 return 1
631 fi
633 echo "unversioned file" > $testroot/wt/foo
634 echo "unversioned file" > $testroot/wt/foop
635 echo "unversioned file" > $testroot/wt/barp
636 echo "unversioned file" > $testroot/wt/epsilon/bar
637 echo "unversioned file" > $testroot/wt/epsilon/boo
638 echo "unversioned file" > $testroot/wt/epsilon/moo
639 mkdir -p $testroot/wt/a/b/c/
640 echo "unversioned file" > $testroot/wt/a/b/c/foo
641 echo "unversioned file" > $testroot/wt/a/b/c/zoo
642 echo "foo" > $testroot/wt/.gitignore
643 echo "bar*" >> $testroot/wt/.gitignore
644 echo "epsilon/**" >> $testroot/wt/.gitignore
645 echo "a/**/foo" >> $testroot/wt/.gitignore
646 echo "**/zoo" >> $testroot/wt/.gitignore
648 echo '? .gitignore' > $testroot/stdout.expected
649 echo '? foop' >> $testroot/stdout.expected
650 (cd $testroot/wt && got status > $testroot/stdout)
652 cmp -s $testroot/stdout.expected $testroot/stdout
653 ret=$?
654 if [ $ret -ne 0 ]; then
655 diff -u $testroot/stdout.expected $testroot/stdout
656 test_done "$testroot" "$ret"
657 return 1
658 fi
660 echo '? .gitignore' > $testroot/stdout.expected
661 echo '? foop' >> $testroot/stdout.expected
662 (cd $testroot/wt/gamma && got status > $testroot/stdout)
664 cmp -s $testroot/stdout.expected $testroot/stdout
665 ret=$?
666 if [ $ret -ne 0 ]; then
667 diff -u $testroot/stdout.expected $testroot/stdout
668 test_done "$testroot" "$ret"
669 return 1
670 fi
672 cat > $testroot/stdout.expected <<EOF
673 ? .gitignore
674 ? a/b/c/foo
675 ? a/b/c/zoo
676 ? barp
677 ? epsilon/bar
678 ? epsilon/boo
679 ? epsilon/moo
680 ? foo
681 ? foop
682 EOF
683 (cd $testroot/wt && got status -I > $testroot/stdout)
684 ret=$?
685 if [ $ret -ne 0 ]; then
686 echo "got status failed unexpectedly" >&2
687 test_done "$testroot" "1"
688 return 1
689 fi
691 cmp -s $testroot/stdout.expected $testroot/stdout
692 ret=$?
693 if [ $ret -ne 0 ]; then
694 diff -u $testroot/stdout.expected $testroot/stdout
695 fi
696 test_done "$testroot" "$ret"
699 test_status_status_code() {
700 local testroot=`test_init status_status_code`
702 got checkout $testroot/repo $testroot/wt > /dev/null
703 ret=$?
704 if [ $ret -ne 0 ]; then
705 test_done "$testroot" "$ret"
706 return 1
707 fi
709 echo "modified alpha" > $testroot/wt/alpha
710 (cd $testroot/wt && got rm beta >/dev/null)
711 echo "unversioned file" > $testroot/wt/foo
712 rm $testroot/wt/epsilon/zeta
713 touch $testroot/wt/beta
714 echo "new file" > $testroot/wt/new
715 (cd $testroot/wt && got add new >/dev/null)
717 (cd $testroot/wt && got status -s xDM \
718 > $testroot/stdout 2> $testroot/stderr)
719 ret=$?
720 if [ $ret -eq 0 ]; then
721 echo "status succeeded unexpectedly" >&2
722 test_done "$testroot" "1"
723 return 1
724 fi
726 echo "got: invalid status code 'x'" > $testroot/stderr.expected
727 cmp -s $testroot/stderr.expected $testroot/stderr
728 ret=$?
729 if [ $ret -ne 0 ]; then
730 diff -u $testroot/stderr.expected $testroot/stderr
731 test_done "$testroot" "$ret"
732 return 1
733 fi
735 echo 'M alpha' > $testroot/stdout.expected
736 (cd $testroot/wt && got status -s M > $testroot/stdout)
737 cmp -s $testroot/stdout.expected $testroot/stdout
738 ret=$?
739 if [ $ret -ne 0 ]; then
740 diff -u $testroot/stdout.expected $testroot/stdout
741 test_done "$testroot" "$ret"
742 return 1
743 fi
745 echo 'D beta' > $testroot/stdout.expected
746 (cd $testroot/wt && got status -s D > $testroot/stdout)
747 cmp -s $testroot/stdout.expected $testroot/stdout
748 ret=$?
749 if [ $ret -ne 0 ]; then
750 diff -u $testroot/stdout.expected $testroot/stdout
751 test_done "$testroot" "$ret"
752 return 1
753 fi
755 echo '! epsilon/zeta' > $testroot/stdout.expected
756 echo '? foo' >> $testroot/stdout.expected
757 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
758 cmp -s $testroot/stdout.expected $testroot/stdout
759 ret=$?
760 if [ $ret -ne 0 ]; then
761 diff -u $testroot/stdout.expected $testroot/stdout
762 test_done "$testroot" "$ret"
763 return 1
764 fi
766 echo 'A new' > $testroot/stdout.expected
767 (cd $testroot/wt && got status -s A > $testroot/stdout)
768 cmp -s $testroot/stdout.expected $testroot/stdout
769 ret=$?
770 if [ $ret -ne 0 ]; then
771 diff -u $testroot/stdout.expected $testroot/stdout
772 test_done "$testroot" "$ret"
773 return 1
774 fi
776 (cd $testroot/wt && got stage new > $testroot/stdout)
778 echo ' A new' > $testroot/stdout.expected
779 (cd $testroot/wt && got status -s A > $testroot/stdout)
780 cmp -s $testroot/stdout.expected $testroot/stdout
781 ret=$?
782 if [ $ret -ne 0 ]; then
783 diff -u $testroot/stdout.expected $testroot/stdout
784 test_done "$testroot" "$ret"
785 return 1
786 fi
788 echo 'changed file new' > $testroot/wt/new
790 echo 'MA new' > $testroot/stdout.expected
791 (cd $testroot/wt && got status -s A > $testroot/stdout)
792 cmp -s $testroot/stdout.expected $testroot/stdout
793 ret=$?
794 if [ $ret -ne 0 ]; then
795 diff -u $testroot/stdout.expected $testroot/stdout
796 test_done "$testroot" "$ret"
797 return 1
798 fi
800 echo 'M alpha' > $testroot/stdout.expected
801 echo 'MA new' >> $testroot/stdout.expected
802 (cd $testroot/wt && got status -s M > $testroot/stdout)
803 cmp -s $testroot/stdout.expected $testroot/stdout
804 ret=$?
805 if [ $ret -ne 0 ]; then
806 diff -u $testroot/stdout.expected $testroot/stdout
807 test_done "$testroot" "$ret"
808 return 1
809 fi
811 test_done "$testroot" "$ret"
814 test_status_suppress() {
815 local testroot=`test_init status_suppress`
817 got checkout $testroot/repo $testroot/wt > /dev/null
818 ret=$?
819 if [ $ret -ne 0 ]; then
820 test_done "$testroot" "$ret"
821 return 1
822 fi
824 echo "modified alpha" > $testroot/wt/alpha
825 (cd $testroot/wt && got rm beta >/dev/null)
826 echo "unversioned file" > $testroot/wt/foo
827 rm $testroot/wt/epsilon/zeta
828 touch $testroot/wt/beta
829 echo "new file" > $testroot/wt/new
830 (cd $testroot/wt && got add new >/dev/null)
832 (cd $testroot/wt && got status -S A -s M \
833 > $testroot/stdout 2> $testroot/stderr)
834 ret=$?
835 if [ $ret -eq 0 ]; then
836 echo "status succeeded unexpectedly" >&2
837 test_done "$testroot" "1"
838 return 1
839 fi
841 echo "got: -s and -S options are mutually exclusive" \
842 > $testroot/stderr.expected
843 cmp -s $testroot/stderr.expected $testroot/stderr
844 ret=$?
845 if [ $ret -ne 0 ]; then
846 diff -u $testroot/stderr.expected $testroot/stderr
847 test_done "$testroot" "$ret"
848 return 1
849 fi
851 (cd $testroot/wt && got status -s A -S M \
852 > $testroot/stdout 2> $testroot/stderr)
853 ret=$?
854 if [ $ret -eq 0 ]; then
855 echo "status succeeded unexpectedly" >&2
856 test_done "$testroot" "1"
857 return 1
858 fi
860 echo "got: -S and -s options are mutually exclusive" \
861 > $testroot/stderr.expected
862 cmp -s $testroot/stderr.expected $testroot/stderr
863 ret=$?
864 if [ $ret -ne 0 ]; then
865 diff -u $testroot/stderr.expected $testroot/stderr
866 test_done "$testroot" "$ret"
867 return 1
868 fi
870 (cd $testroot/wt && got status -S xDM \
871 > $testroot/stdout 2> $testroot/stderr)
872 ret=$?
873 if [ $ret -eq 0 ]; then
874 echo "status succeeded unexpectedly" >&2
875 test_done "$testroot" "1"
876 return 1
877 fi
879 echo "got: invalid status code 'x'" > $testroot/stderr.expected
880 cmp -s $testroot/stderr.expected $testroot/stderr
881 ret=$?
882 if [ $ret -ne 0 ]; then
883 diff -u $testroot/stderr.expected $testroot/stderr
884 test_done "$testroot" "$ret"
885 return 1
886 fi
888 echo 'M alpha' > $testroot/stdout.expected
889 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
890 cmp -s $testroot/stdout.expected $testroot/stdout
891 ret=$?
892 if [ $ret -ne 0 ]; then
893 diff -u $testroot/stdout.expected $testroot/stdout
894 test_done "$testroot" "$ret"
895 return 1
896 fi
898 echo 'D beta' > $testroot/stdout.expected
899 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
900 cmp -s $testroot/stdout.expected $testroot/stdout
901 ret=$?
902 if [ $ret -ne 0 ]; then
903 diff -u $testroot/stdout.expected $testroot/stdout
904 test_done "$testroot" "$ret"
905 return 1
906 fi
908 echo '! epsilon/zeta' > $testroot/stdout.expected
909 echo '? foo' >> $testroot/stdout.expected
910 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
911 cmp -s $testroot/stdout.expected $testroot/stdout
912 ret=$?
913 if [ $ret -ne 0 ]; then
914 diff -u $testroot/stdout.expected $testroot/stdout
915 test_done "$testroot" "$ret"
916 return 1
917 fi
919 echo 'A new' > $testroot/stdout.expected
920 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
921 cmp -s $testroot/stdout.expected $testroot/stdout
922 ret=$?
923 if [ $ret -ne 0 ]; then
924 diff -u $testroot/stdout.expected $testroot/stdout
925 test_done "$testroot" "$ret"
926 return 1
927 fi
929 (cd $testroot/wt && got stage new > $testroot/stdout)
931 echo ' A new' > $testroot/stdout.expected
932 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
933 cmp -s $testroot/stdout.expected $testroot/stdout
934 ret=$?
935 if [ $ret -ne 0 ]; then
936 diff -u $testroot/stdout.expected $testroot/stdout
937 test_done "$testroot" "$ret"
938 return 1
939 fi
941 echo 'changed file new' > $testroot/wt/new
943 echo 'M alpha' > $testroot/stdout.expected
944 echo 'MA new' >> $testroot/stdout.expected
945 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
946 cmp -s $testroot/stdout.expected $testroot/stdout
947 ret=$?
948 if [ $ret -ne 0 ]; then
949 diff -u $testroot/stdout.expected $testroot/stdout
950 test_done "$testroot" "$ret"
951 return 1
952 fi
954 echo 'M alpha' > $testroot/stdout.expected
955 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
956 cmp -s $testroot/stdout.expected $testroot/stdout
957 ret=$?
958 if [ $ret -ne 0 ]; then
959 diff -u $testroot/stdout.expected $testroot/stdout
960 test_done "$testroot" "$ret"
961 return 1
962 fi
964 rm $testroot/stdout.expected
965 touch $testroot/stdout.expected
967 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
968 cmp -s $testroot/stdout.expected $testroot/stdout
969 ret=$?
970 if [ $ret -ne 0 ]; then
971 diff -u $testroot/stdout.expected $testroot/stdout
972 test_done "$testroot" "$ret"
973 return 1
974 fi
976 test_done "$testroot" "$ret"
979 test_status_empty_file() {
980 local testroot=`test_init status_empty_file`
982 got checkout $testroot/repo $testroot/wt > /dev/null
983 ret=$?
984 if [ $ret -ne 0 ]; then
985 test_done "$testroot" "$ret"
986 return 1
987 fi
989 echo -n "" > $testroot/wt/empty
990 (cd $testroot/wt && got add empty >/dev/null)
992 echo 'A empty' > $testroot/stdout.expected
994 (cd $testroot/wt && got status > $testroot/stdout)
996 cmp -s $testroot/stdout.expected $testroot/stdout
997 ret=$?
998 if [ $ret -ne 0 ]; then
999 diff -u $testroot/stdout.expected $testroot/stdout
1000 test_done "$testroot" "$ret"
1001 return 1
1004 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
1006 (cd $testroot/wt && got status > $testroot/stdout)
1008 echo -n > $testroot/stdout.expected
1009 cmp -s $testroot/stdout.expected $testroot/stdout
1010 ret=$?
1011 if [ $ret -ne 0 ]; then
1012 diff -u $testroot/stdout.expected $testroot/stdout
1013 test_done "$testroot" "$ret"
1014 return 1
1017 # update the timestamp; this used to make the file show up as:
1018 # M empty
1019 # which should not happen
1020 touch $testroot/wt/empty
1022 (cd $testroot/wt && got status > $testroot/stdout)
1024 echo -n > $testroot/stdout.expected
1025 cmp -s $testroot/stdout.expected $testroot/stdout
1026 ret=$?
1027 if [ $ret -ne 0 ]; then
1028 diff -u $testroot/stdout.expected $testroot/stdout
1030 test_done "$testroot" "$ret"
1033 test_parseargs "$@"
1034 run_test test_status_basic
1035 run_test test_status_subdir_no_mods
1036 run_test test_status_subdir_no_mods2
1037 run_test test_status_obstructed
1038 run_test test_status_shows_local_mods_after_update
1039 run_test test_status_unversioned_subdirs
1040 run_test test_status_symlink
1041 run_test test_status_shows_no_mods_after_complete_merge
1042 run_test test_status_shows_conflict
1043 run_test test_status_empty_dir
1044 run_test test_status_empty_dir_unversioned_file
1045 run_test test_status_many_paths
1046 run_test test_status_cvsignore
1047 run_test test_status_gitignore
1048 run_test test_status_status_code
1049 run_test test_status_suppress
1050 run_test test_status_empty_file