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 function 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 function 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 function 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 function 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 function 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 commit " >> $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 function 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 function 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 -sfh 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 function 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 commit " >> $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 function 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 commit " >> $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 function 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 function 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 function 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 function 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 fi
585 test_done "$testroot" "$ret"
588 function test_status_gitignore {
589 local testroot=`test_init status_gitignore`
591 got checkout $testroot/repo $testroot/wt > /dev/null
592 ret="$?"
593 if [ "$ret" != "0" ]; then
594 test_done "$testroot" "$ret"
595 return 1
596 fi
598 echo "unversioned file" > $testroot/wt/foo
599 echo "unversioned file" > $testroot/wt/foop
600 echo "unversioned file" > $testroot/wt/barp
601 echo "unversioned file" > $testroot/wt/epsilon/bar
602 echo "unversioned file" > $testroot/wt/epsilon/boo
603 echo "unversioned file" > $testroot/wt/epsilon/moo
604 mkdir -p $testroot/wt/a/b/c/
605 echo "unversioned file" > $testroot/wt/a/b/c/foo
606 echo "unversioned file" > $testroot/wt/a/b/c/zoo
607 echo "foo" > $testroot/wt/.gitignore
608 echo "bar*" >> $testroot/wt/.gitignore
609 echo "epsilon/**" >> $testroot/wt/.gitignore
610 echo "a/**/foo" >> $testroot/wt/.gitignore
611 echo "**/zoo" >> $testroot/wt/.gitignore
613 echo '? .gitignore' > $testroot/stdout.expected
614 echo '? foop' >> $testroot/stdout.expected
615 (cd $testroot/wt && got status > $testroot/stdout)
617 cmp -s $testroot/stdout.expected $testroot/stdout
618 ret="$?"
619 if [ "$ret" != "0" ]; then
620 diff -u $testroot/stdout.expected $testroot/stdout
621 test_done "$testroot" "$ret"
622 return 1
623 fi
625 echo '? .gitignore' > $testroot/stdout.expected
626 echo '? foop' >> $testroot/stdout.expected
627 (cd $testroot/wt/gamma && got status > $testroot/stdout)
629 cmp -s $testroot/stdout.expected $testroot/stdout
630 ret="$?"
631 if [ "$ret" != "0" ]; then
632 diff -u $testroot/stdout.expected $testroot/stdout
633 fi
634 test_done "$testroot" "$ret"
637 function test_status_status_code {
638 local testroot=`test_init status_status_code`
640 got checkout $testroot/repo $testroot/wt > /dev/null
641 ret="$?"
642 if [ "$ret" != "0" ]; then
643 test_done "$testroot" "$ret"
644 return 1
645 fi
647 echo "modified alpha" > $testroot/wt/alpha
648 (cd $testroot/wt && got rm beta >/dev/null)
649 echo "unversioned file" > $testroot/wt/foo
650 rm $testroot/wt/epsilon/zeta
651 touch $testroot/wt/beta
652 echo "new file" > $testroot/wt/new
653 (cd $testroot/wt && got add new >/dev/null)
655 (cd $testroot/wt && got status -s xDM \
656 > $testroot/stdout 2> $testroot/stderr)
657 ret="$?"
658 if [ "$ret" == "0" ]; then
659 echo "status succeeded unexpectedly" >&2
660 test_done "$testroot" "1"
661 return 1
662 fi
664 echo "got: invalid status code 'x'" > $testroot/stderr.expected
665 cmp -s $testroot/stderr.expected $testroot/stderr
666 ret="$?"
667 if [ "$ret" != "0" ]; then
668 diff -u $testroot/stderr.expected $testroot/stderr
669 test_done "$testroot" "$ret"
670 return 1
671 fi
673 echo 'M alpha' > $testroot/stdout.expected
674 (cd $testroot/wt && got status -s M > $testroot/stdout)
675 cmp -s $testroot/stdout.expected $testroot/stdout
676 ret="$?"
677 if [ "$ret" != "0" ]; then
678 diff -u $testroot/stdout.expected $testroot/stdout
679 test_done "$testroot" "$ret"
680 return 1
681 fi
683 echo 'D beta' > $testroot/stdout.expected
684 (cd $testroot/wt && got status -s D > $testroot/stdout)
685 cmp -s $testroot/stdout.expected $testroot/stdout
686 ret="$?"
687 if [ "$ret" != "0" ]; then
688 diff -u $testroot/stdout.expected $testroot/stdout
689 test_done "$testroot" "$ret"
690 return 1
691 fi
693 echo '! epsilon/zeta' > $testroot/stdout.expected
694 echo '? foo' >> $testroot/stdout.expected
695 (cd $testroot/wt && got status -s \!? > $testroot/stdout)
696 cmp -s $testroot/stdout.expected $testroot/stdout
697 ret="$?"
698 if [ "$ret" != "0" ]; then
699 diff -u $testroot/stdout.expected $testroot/stdout
700 test_done "$testroot" "$ret"
701 return 1
702 fi
704 echo 'A new' > $testroot/stdout.expected
705 (cd $testroot/wt && got status -s A > $testroot/stdout)
706 cmp -s $testroot/stdout.expected $testroot/stdout
707 ret="$?"
708 if [ "$ret" != "0" ]; then
709 diff -u $testroot/stdout.expected $testroot/stdout
710 test_done "$testroot" "$ret"
711 return 1
712 fi
714 (cd $testroot/wt && got stage new > $testroot/stdout)
716 echo ' A new' > $testroot/stdout.expected
717 (cd $testroot/wt && got status -s A > $testroot/stdout)
718 cmp -s $testroot/stdout.expected $testroot/stdout
719 ret="$?"
720 if [ "$ret" != "0" ]; then
721 diff -u $testroot/stdout.expected $testroot/stdout
722 test_done "$testroot" "$ret"
723 return 1
724 fi
726 echo 'changed file new' > $testroot/wt/new
728 echo 'MA new' > $testroot/stdout.expected
729 (cd $testroot/wt && got status -s A > $testroot/stdout)
730 cmp -s $testroot/stdout.expected $testroot/stdout
731 ret="$?"
732 if [ "$ret" != "0" ]; then
733 diff -u $testroot/stdout.expected $testroot/stdout
734 test_done "$testroot" "$ret"
735 return 1
736 fi
738 echo 'M alpha' > $testroot/stdout.expected
739 echo 'MA new' >> $testroot/stdout.expected
740 (cd $testroot/wt && got status -s M > $testroot/stdout)
741 cmp -s $testroot/stdout.expected $testroot/stdout
742 ret="$?"
743 if [ "$ret" != "0" ]; then
744 diff -u $testroot/stdout.expected $testroot/stdout
745 test_done "$testroot" "$ret"
746 return 1
747 fi
749 test_done "$testroot" "$ret"
753 test_parseargs "$@"
754 run_test test_status_basic
755 run_test test_status_subdir_no_mods
756 run_test test_status_subdir_no_mods2
757 run_test test_status_obstructed
758 run_test test_status_shows_local_mods_after_update
759 run_test test_status_unversioned_subdirs
760 run_test test_status_symlink
761 run_test test_status_shows_no_mods_after_complete_merge
762 run_test test_status_shows_conflict
763 run_test test_status_empty_dir
764 run_test test_status_empty_dir_unversioned_file
765 run_test test_status_many_paths
766 run_test test_status_cvsignore
767 run_test test_status_gitignore
768 run_test test_status_status_code