3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
20 local testroot
=`test_init status_basic`
22 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
24 if [ "$ret" != "0" ]; then
25 test_done
"$testroot" "$ret"
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
48 if [ "$ret" != "0" ]; then
49 diff -u $testroot/stdout.expected
$testroot/stdout
51 chmod 700 $testroot/wt
/bar
52 rmdir $testroot/wt
/bar
53 test_done
"$testroot" "$ret"
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
69 if [ "$ret" != "0" ]; then
70 test_done
"$testroot" "$ret"
74 touch $testroot/stdout.expected
76 # This used to erroneously print:
80 (cd $testroot/wt
&& got status
> $testroot/stdout
)
82 cmp -s $testroot/stdout.expected
$testroot/stdout
84 if [ "$ret" != "0" ]; then
85 diff -u $testroot/stdout.expected
$testroot/stdout
87 test_done
"$testroot" "$ret"
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
109 if [ "$ret" != "0" ]; then
110 test_done
"$testroot" "$ret"
114 touch $testroot/stdout.expected
116 # This used to erroneously print:
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
128 if [ "$ret" != "0" ]; then
129 diff -u $testroot/stdout.expected
$testroot/stdout
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
139 if [ "$ret" != "0" ]; then
140 test_done
"$testroot" "$ret"
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
153 if [ "$ret" != "0" ]; then
154 diff -u $testroot/stdout.expected
$testroot/stdout
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
175 if [ "$ret" != "0" ]; then
176 test_done
"$testroot" "$ret"
180 sed -i '' -e '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 '' -e '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
195 if [ "$ret" != "0" ]; then
196 diff -u $testroot/stdout.expected
$testroot/stdout
197 test_done
"$testroot" "$ret"
201 echo 'M numbers' > $testroot/stdout.expected
203 (cd $testroot/wt
&& got status
> $testroot/stdout
)
205 cmp -s $testroot/stdout.expected
$testroot/stdout
207 if [ "$ret" != "0" ]; then
208 diff -u $testroot/stdout.expected
$testroot/stdout
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
233 if [ "$ret" != "0" ]; then
234 test_done
"$testroot" "$ret"
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
255 if [ "$ret" != "0" ]; then
256 diff -u $testroot/stdout.expected
$testroot/stdout
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
274 if [ "$ret" != "0" ]; then
275 test_done
"$testroot" "$ret"
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
287 if [ "$ret" != "0" ]; then
288 diff -u $testroot/stdout.expected
$testroot/stdout
289 test_done
"$testroot" "$ret"
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
313 if [ "$ret" != "0" ]; then
314 diff -u $testroot/stdout.expected
$testroot/stdout
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
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
333 if [ "$ret" != "0" ]; then
334 test_done
"$testroot" "$ret"
338 sed -i '' -e 's/2/22/' $testroot/repo
/numbers
339 git_commit
$testroot/repo
-m "modified line 2"
342 # modify line 2 again; no local changes are left after merge
343 sed -i '' -e '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
354 if [ "$ret" != "0" ]; then
355 diff -u $testroot/stdout.expected
$testroot/stdout
356 test_done
"$testroot" "$ret"
360 echo -n > $testroot/stdout.expected
362 (cd $testroot/wt
&& got status
> $testroot/stdout
)
364 cmp -s $testroot/stdout.expected
$testroot/stdout
366 if [ "$ret" != "0" ]; then
367 diff -u $testroot/stdout.expected
$testroot/stdout
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
388 if [ "$ret" != "0" ]; then
389 test_done
"$testroot" "$ret"
393 sed -i '' -e '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 '' -e '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
409 if [ "$ret" != "0" ]; then
410 diff -u $testroot/stdout.expected
$testroot/stdout
411 test_done
"$testroot" "$ret"
415 echo 'C numbers' > $testroot/stdout.expected
417 (cd $testroot/wt
&& got status
> $testroot/stdout
)
419 cmp -s $testroot/stdout.expected
$testroot/stdout
421 if [ "$ret" != "0" ]; then
422 diff -u $testroot/stdout.expected
$testroot/stdout
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
432 if [ "$ret" != "0" ]; then
433 test_done
"$testroot" "$ret"
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
445 if [ "$ret" != "0" ]; then
446 diff -u $testroot/stdout.expected
$testroot/stdout
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
456 if [ "$ret" != "0" ]; then
457 test_done
"$testroot" "$ret"
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
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected
$testroot/stdout
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
482 if [ "$ret" != "0" ]; then
483 test_done
"$testroot" "$ret"
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 . \
507 cmp -s $testroot/stdout.expected
$testroot/stdout
509 if [ "$ret" != "0" ]; then
510 diff -u $testroot/stdout.expected
$testroot/stdout
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
520 if [ "$ret" != "0" ]; then
521 test_done
"$testroot" "$ret"
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
545 if [ "$ret" != "0" ]; then
546 diff -u $testroot/stdout.expected
$testroot/stdout
547 test_done
"$testroot" "$ret"
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
557 if [ "$ret" != "0" ]; then
558 diff -u $testroot/stdout.expected
$testroot/stdout
559 test_done
"$testroot" "$ret"
563 echo -n '' > $testroot/stdout.expected
564 (cd $testroot/wt
&& got status epsilon
/new
> $testroot/stdout
)
566 cmp -s $testroot/stdout.expected
$testroot/stdout
568 if [ "$ret" != "0" ]; then
569 diff -u $testroot/stdout.expected
$testroot/stdout
570 test_done
"$testroot" "$ret"
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
582 if [ "$ret" != "0" ]; then
583 diff -u $testroot/stdout.expected
$testroot/stdout
584 test_done
"$testroot" "$ret"
588 cat > $testroot/stdout.expected
<<EOF
599 (cd $testroot/wt
&& got status
-I > $testroot/stdout
)
601 if [ "$ret" != "0" ]; then
602 echo "got status failed unexpectedly" >&2
603 test_done
"$testroot" "1"
607 cmp -s $testroot/stdout.expected
$testroot/stdout
609 if [ "$ret" != "0" ]; then
610 diff -u $testroot/stdout.expected
$testroot/stdout
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
620 if [ "$ret" != "0" ]; then
621 test_done
"$testroot" "$ret"
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
646 if [ "$ret" != "0" ]; then
647 diff -u $testroot/stdout.expected
$testroot/stdout
648 test_done
"$testroot" "$ret"
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
658 if [ "$ret" != "0" ]; then
659 diff -u $testroot/stdout.expected
$testroot/stdout
660 test_done
"$testroot" "$ret"
664 cat > $testroot/stdout.expected
<<EOF
675 (cd $testroot/wt
&& got status
-I > $testroot/stdout
)
677 if [ "$ret" != "0" ]; then
678 echo "got status failed unexpectedly" >&2
679 test_done
"$testroot" "1"
683 cmp -s $testroot/stdout.expected
$testroot/stdout
685 if [ "$ret" != "0" ]; then
686 diff -u $testroot/stdout.expected
$testroot/stdout
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
696 if [ "$ret" != "0" ]; then
697 test_done
"$testroot" "$ret"
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
)
712 if [ "$ret" = "0" ]; then
713 echo "status succeeded unexpectedly" >&2
714 test_done
"$testroot" "1"
718 echo "got: invalid status code 'x'" > $testroot/stderr.expected
719 cmp -s $testroot/stderr.expected
$testroot/stderr
721 if [ "$ret" != "0" ]; then
722 diff -u $testroot/stderr.expected
$testroot/stderr
723 test_done
"$testroot" "$ret"
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
731 if [ "$ret" != "0" ]; then
732 diff -u $testroot/stdout.expected
$testroot/stdout
733 test_done
"$testroot" "$ret"
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
741 if [ "$ret" != "0" ]; then
742 diff -u $testroot/stdout.expected
$testroot/stdout
743 test_done
"$testroot" "$ret"
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
752 if [ "$ret" != "0" ]; then
753 diff -u $testroot/stdout.expected
$testroot/stdout
754 test_done
"$testroot" "$ret"
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
762 if [ "$ret" != "0" ]; then
763 diff -u $testroot/stdout.expected
$testroot/stdout
764 test_done
"$testroot" "$ret"
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
774 if [ "$ret" != "0" ]; then
775 diff -u $testroot/stdout.expected
$testroot/stdout
776 test_done
"$testroot" "$ret"
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
786 if [ "$ret" != "0" ]; then
787 diff -u $testroot/stdout.expected
$testroot/stdout
788 test_done
"$testroot" "$ret"
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
797 if [ "$ret" != "0" ]; then
798 diff -u $testroot/stdout.expected
$testroot/stdout
799 test_done
"$testroot" "$ret"
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
811 if [ "$ret" != "0" ]; then
812 test_done
"$testroot" "$ret"
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
)
827 if [ "$ret" = "0" ]; then
828 echo "status succeeded unexpectedly" >&2
829 test_done
"$testroot" "1"
833 echo "got: -s and -S options are mutually exclusive" \
834 > $testroot/stderr.expected
835 cmp -s $testroot/stderr.expected
$testroot/stderr
837 if [ "$ret" != "0" ]; then
838 diff -u $testroot/stderr.expected
$testroot/stderr
839 test_done
"$testroot" "$ret"
843 (cd $testroot/wt
&& got status
-s A
-S M \
844 > $testroot/stdout
2> $testroot/stderr
)
846 if [ "$ret" = "0" ]; then
847 echo "status succeeded unexpectedly" >&2
848 test_done
"$testroot" "1"
852 echo "got: -S and -s options are mutually exclusive" \
853 > $testroot/stderr.expected
854 cmp -s $testroot/stderr.expected
$testroot/stderr
856 if [ "$ret" != "0" ]; then
857 diff -u $testroot/stderr.expected
$testroot/stderr
858 test_done
"$testroot" "$ret"
862 (cd $testroot/wt
&& got status
-S xDM \
863 > $testroot/stdout
2> $testroot/stderr
)
865 if [ "$ret" = "0" ]; then
866 echo "status succeeded unexpectedly" >&2
867 test_done
"$testroot" "1"
871 echo "got: invalid status code 'x'" > $testroot/stderr.expected
872 cmp -s $testroot/stderr.expected
$testroot/stderr
874 if [ "$ret" != "0" ]; then
875 diff -u $testroot/stderr.expected
$testroot/stderr
876 test_done
"$testroot" "$ret"
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
884 if [ "$ret" != "0" ]; then
885 diff -u $testroot/stdout.expected
$testroot/stdout
886 test_done
"$testroot" "$ret"
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
894 if [ "$ret" != "0" ]; then
895 diff -u $testroot/stdout.expected
$testroot/stdout
896 test_done
"$testroot" "$ret"
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
905 if [ "$ret" != "0" ]; then
906 diff -u $testroot/stdout.expected
$testroot/stdout
907 test_done
"$testroot" "$ret"
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
915 if [ "$ret" != "0" ]; then
916 diff -u $testroot/stdout.expected
$testroot/stdout
917 test_done
"$testroot" "$ret"
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
927 if [ "$ret" != "0" ]; then
928 diff -u $testroot/stdout.expected
$testroot/stdout
929 test_done
"$testroot" "$ret"
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
940 if [ "$ret" != "0" ]; then
941 diff -u $testroot/stdout.expected
$testroot/stdout
942 test_done
"$testroot" "$ret"
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
950 if [ "$ret" != "0" ]; then
951 diff -u $testroot/stdout.expected
$testroot/stdout
952 test_done
"$testroot" "$ret"
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
962 if [ "$ret" != "0" ]; then
963 diff -u $testroot/stdout.expected
$testroot/stdout
964 test_done
"$testroot" "$ret"
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
976 if [ "$ret" != "0" ]; then
977 test_done
"$testroot" "$ret"
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
990 if [ "$ret" != "0" ]; then
991 diff -u $testroot/stdout.expected
$testroot/stdout
992 test_done
"$testroot" "$ret"
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
1003 if [ "$ret" != "0" ]; then
1004 diff -u $testroot/stdout.expected
$testroot/stdout
1005 test_done
"$testroot" "$ret"
1009 # update the timestamp; this used to make the file show up as:
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
1019 if [ "$ret" != "0" ]; then
1020 diff -u $testroot/stdout.expected
$testroot/stdout
1022 test_done
"$testroot" "$ret"
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