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.
19 function test_checkout_basic {
20 local testroot=`test_init checkout_basic`
22 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
23 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
24 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
25 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
26 echo "Now shut up and hack" >> $testroot/stdout.expected
28 got checkout $testroot/repo $testroot/wt > $testroot/stdout
30 if [ "$ret" != "0" ]; then
31 test_done "$testroot" "$ret"
35 cmp -s $testroot/stdout.expected $testroot/stdout
37 if [ "$ret" != "0" ]; then
38 diff -u $testroot/stdout.expected $testroot/stdout
39 test_done "$testroot" "$ret"
43 echo "alpha" > $testroot/content.expected
44 echo "beta" >> $testroot/content.expected
45 echo "zeta" >> $testroot/content.expected
46 echo "delta" >> $testroot/content.expected
47 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
48 $testroot/wt/gamma/delta > $testroot/content
50 cmp -s $testroot/content.expected $testroot/content
52 if [ "$ret" != "0" ]; then
53 diff -u $testroot/content.expected $testroot/content
55 test_done "$testroot" "$ret"
58 function test_checkout_dir_exists {
59 local testroot=`test_init checkout_dir_exists`
61 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
62 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
63 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
64 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
65 echo "Now shut up and hack" >> $testroot/stdout.expected
69 got checkout $testroot/repo $testroot/wt > $testroot/stdout
71 if [ "$ret" != "0" ]; then
72 test_done "$testroot" "$ret"
76 cmp -s $testroot/stdout.expected $testroot/stdout
78 if [ "$ret" != "0" ]; then
79 diff -u $testroot/stdout.expected $testroot/stdout
80 test_done "$testroot" "$ret"
84 echo "alpha" > $testroot/content.expected
85 echo "beta" >> $testroot/content.expected
86 echo "zeta" >> $testroot/content.expected
87 echo "delta" >> $testroot/content.expected
88 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
89 $testroot/wt/gamma/delta > $testroot/content
91 cmp -s $testroot/content.expected $testroot/content
93 if [ "$ret" != "0" ]; then
94 diff -u $testroot/content.expected $testroot/content
96 test_done "$testroot" "$ret"
99 function test_checkout_dir_not_empty {
100 local testroot=`test_init checkout_dir_not_empty`
102 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
103 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
104 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
105 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
106 echo "Now shut up and hack" >> $testroot/stdout.expected
109 touch $testroot/wt/foo
111 got checkout $testroot/repo $testroot/wt > $testroot/stdout \
114 if [ "$ret" == "0" ]; then
115 echo "checkout succeeded unexpectedly" >&2
116 test_done "$testroot" "1"
120 echo "got: $testroot/wt: directory exists and is not empty" \
121 > $testroot/stderr.expected
122 cmp -s $testroot/stderr.expected $testroot/stderr
124 if [ "$ret" != "0" ]; then
125 diff -u $testroot/stderr.expected $testroot/stderr
126 test_done "$testroot" "$ret"
130 echo -n > $testroot/stdout.expected
131 cmp -s $testroot/stdout.expected $testroot/stdout
133 if [ "$ret" != "0" ]; then
134 diff -u $testroot/stdout.expected $testroot/stdout
136 test_done "$testroot" "$ret"
140 function test_checkout_sets_xbit {
141 local testroot=`test_init checkout_sets_xbit 1`
143 touch $testroot/repo/xfile
144 chmod +x $testroot/repo/xfile
145 (cd $testroot/repo && git add .)
146 git_commit $testroot/repo -m "adding executable file"
148 echo "A $testroot/wt/xfile" > $testroot/stdout.expected
149 echo "Now shut up and hack" >> $testroot/stdout.expected
151 got checkout $testroot/repo $testroot/wt > $testroot/stdout
153 if [ "$ret" != "0" ]; then
154 test_done "$testroot" "$ret"
158 cmp -s $testroot/stdout.expected $testroot/stdout
160 if [ "$ret" != "0" ]; then
161 diff -u $testroot/stdout.expected $testroot/stdout
162 test_done "$testroot" "$ret"
166 ls -l $testroot/wt/xfile | grep -q '^-rwx'
168 if [ "$ret" != "0" ]; then
169 echo "file is not executable" >&2
170 ls -l $testroot/wt/xfile >&2
172 test_done "$testroot" "$ret"
175 function test_checkout_commit_from_wrong_branch {
176 local testroot=`test_init checkout_commit_from_wrong_branch`
178 (cd $testroot/repo && git checkout -q -b newbranch)
179 echo "modified alpha on new branch" > $testroot/repo/alpha
180 git_commit $testroot/repo -m "modified alpha on new branch"
182 local head_rev=`git_show_head $testroot/repo`
183 got checkout -b master -c $head_rev $testroot/repo $testroot/wt \
184 > $testroot/stdout 2> $testroot/stderr
186 if [ "$ret" == "0" ]; then
187 test_done "$testroot" "1"
191 echo -n "" > $testroot/stdout.expected
192 cmp -s $testroot/stdout.expected $testroot/stdout
194 if [ "$ret" != "0" ]; then
195 diff -u $testroot/stdout.expected $testroot/stdout
196 test_done "$testroot" "$ret"
200 echo -n "got: target commit is not contained in branch 'master'; " \
201 > $testroot/stderr.expected
202 echo -n "the branch to use must be specified with -b; if necessary " \
203 >> $testroot/stderr.expected
204 echo -n "a new branch can be created for this commit with "\
205 >> $testroot/stderr.expected
206 echo "'got branch -c $head_rev BRANCH_NAME'" \
207 >> $testroot/stderr.expected
208 cmp -s $testroot/stderr.expected $testroot/stderr
210 if [ "$ret" != "0" ]; then
211 diff -u $testroot/stderr.expected $testroot/stderr
212 test_done "$testroot" "$ret"
216 test_done "$testroot" "$ret"
219 function test_checkout_tag {
220 local testroot=`test_init checkout_tag`
223 (cd $testroot/repo && git tag -a -m "test" $tag)
225 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
226 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
227 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
228 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
229 echo "Now shut up and hack" >> $testroot/stdout.expected
231 got checkout -c $tag $testroot/repo $testroot/wt > $testroot/stdout
233 if [ "$ret" != "0" ]; then
234 test_done "$testroot" "$ret"
238 cmp -s $testroot/stdout.expected $testroot/stdout
240 if [ "$ret" != "0" ]; then
241 diff -u $testroot/stdout.expected $testroot/stdout
242 test_done "$testroot" "$ret"
246 echo "alpha" > $testroot/content.expected
247 echo "beta" >> $testroot/content.expected
248 echo "zeta" >> $testroot/content.expected
249 echo "delta" >> $testroot/content.expected
250 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
251 $testroot/wt/gamma/delta > $testroot/content
253 cmp -s $testroot/content.expected $testroot/content
255 if [ "$ret" != "0" ]; then
256 diff -u $testroot/content.expected $testroot/content
258 test_done "$testroot" "$ret"
261 function test_checkout_ignores_submodules {
262 local testroot=`test_init checkout_ignores_submodules`
264 make_single_file_repo $testroot/repo2 foo
266 (cd $testroot/repo && git submodule -q add ../repo2)
267 (cd $testroot/repo && git commit -q -m 'adding submodule')
269 echo "A $testroot/wt/.gitmodules" > $testroot/stdout.expected
270 echo "A $testroot/wt/alpha" >> $testroot/stdout.expected
271 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
272 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
273 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
274 echo "Now shut up and hack" >> $testroot/stdout.expected
276 got checkout $testroot/repo $testroot/wt > $testroot/stdout
278 if [ "$ret" != "0" ]; then
279 test_done "$testroot" "$ret"
283 cmp -s $testroot/stdout.expected $testroot/stdout
285 if [ "$ret" != "0" ]; then
286 diff -u $testroot/stdout.expected $testroot/stdout
287 test_done "$testroot" "$ret"
291 echo "alpha" > $testroot/content.expected
292 echo "beta" >> $testroot/content.expected
293 echo "zeta" >> $testroot/content.expected
294 echo "delta" >> $testroot/content.expected
295 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
296 $testroot/wt/gamma/delta > $testroot/content
298 cmp -s $testroot/content.expected $testroot/content
300 if [ "$ret" != "0" ]; then
301 diff -u $testroot/content.expected $testroot/content
303 test_done "$testroot" "$ret"
306 function test_checkout_read_only {
307 local testroot=`test_init checkout_read_only`
309 # Make the repostiory read-only
310 chmod -R a-w $testroot/repo
312 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
313 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
314 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
315 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
316 echo "Now shut up and hack" >> $testroot/stdout.expected
318 got checkout $testroot/repo $testroot/wt \
319 > $testroot/stdout 2> $testroot/stderr
321 if [ "$ret" != "0" ]; then
322 test_done "$testroot" "$ret"
326 cmp -s $testroot/stdout.expected $testroot/stdout
328 if [ "$ret" != "0" ]; then
329 diff -u $testroot/stdout.expected $testroot/stdout
330 test_done "$testroot" "$ret"
334 echo -n "got: warning: could not create a reference " \
335 > $testroot/stderr.expected
336 echo -n "to the work tree's base commit; the commit could " \
337 >> $testroot/stderr.expected
338 echo -n "be garbage-collected by Git; making the repository " \
339 >> $testroot/stderr.expected
340 echo "writable and running 'got update' will prevent this" \
341 >> $testroot/stderr.expected
342 cmp -s $testroot/stderr.expected $testroot/stderr
344 if [ "$ret" != "0" ]; then
345 diff -u $testroot/stderr.expected $testroot/stderr
346 test_done "$testroot" "$ret"
350 echo "alpha" > $testroot/content.expected
351 echo "beta" >> $testroot/content.expected
352 echo "zeta" >> $testroot/content.expected
353 echo "delta" >> $testroot/content.expected
354 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
355 $testroot/wt/gamma/delta > $testroot/content
357 cmp -s $testroot/content.expected $testroot/content
359 if [ "$ret" != "0" ]; then
360 diff -u $testroot/content.expected $testroot/content
362 chmod -R u+w $testroot/repo # make repo cleanup work
363 test_done "$testroot" "$ret"
366 function test_checkout_into_nonempty_dir {
367 local testroot=`test_init checkout_into_nonempty_dir`
369 mkdir -p $testroot/wt
370 make_test_tree $testroot/wt
372 got checkout $testroot/repo $testroot/wt > $testroot/stdout \
375 if [ "$ret" == "0" ]; then
376 echo "checkout succeeded unexpectedly" >&2
377 test_done "$testroot" "1"
381 echo -n > $testroot/stdout.expected
382 cmp -s $testroot/stdout.expected $testroot/stdout
384 if [ "$ret" != "0" ]; then
385 diff -u $testroot/stdout.expected $testroot/stdout
386 test_done "$testroot" "$ret"
390 echo "got: $testroot/wt: directory exists and is not empty" \
391 > $testroot/stderr.expected
392 cmp -s $testroot/stderr.expected $testroot/stderr
394 if [ "$ret" != "0" ]; then
395 diff -u $testroot/stderr.expected $testroot/stderr
396 test_done "$testroot" "$ret"
400 echo "? $testroot/wt/alpha" > $testroot/stdout.expected
401 echo "? $testroot/wt/beta" >> $testroot/stdout.expected
402 echo "? $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
403 echo "? $testroot/wt/gamma/delta" >> $testroot/stdout.expected
404 echo "Now shut up and hack" >> $testroot/stdout.expected
406 got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
408 if [ "$ret" != "0" ]; then
409 test_done "$testroot" "$ret"
413 cmp -s $testroot/stdout.expected $testroot/stdout
415 if [ "$ret" != "0" ]; then
416 diff -u $testroot/stdout.expected $testroot/stdout
417 test_done "$testroot" "$ret"
421 echo "E $testroot/wt/alpha" > $testroot/stdout.expected
422 echo "E $testroot/wt/beta" >> $testroot/stdout.expected
423 echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
424 echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
425 echo "Now shut up and hack" >> $testroot/stdout.expected
427 got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
429 if [ "$ret" != "0" ]; then
430 test_done "$testroot" "$ret"
434 cmp -s $testroot/stdout.expected $testroot/stdout
436 if [ "$ret" != "0" ]; then
437 diff -u $testroot/stdout.expected $testroot/stdout
438 test_done "$testroot" "$ret"
442 echo "alpha" > $testroot/content.expected
443 echo "beta" >> $testroot/content.expected
444 echo "zeta" >> $testroot/content.expected
445 echo "delta" >> $testroot/content.expected
446 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
447 $testroot/wt/gamma/delta > $testroot/content
449 cmp -s $testroot/content.expected $testroot/content
451 if [ "$ret" != "0" ]; then
452 diff -u $testroot/content.expected $testroot/content
453 test_done "$testroot" "$ret"
457 echo "modified alpha" > $testroot/wt/alpha
459 echo "E $testroot/wt/alpha" > $testroot/stdout.expected
460 echo "E $testroot/wt/beta" >> $testroot/stdout.expected
461 echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
462 echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
463 echo "Now shut up and hack" >> $testroot/stdout.expected
465 got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
467 if [ "$ret" != "0" ]; then
468 test_done "$testroot" "$ret"
472 cmp -s $testroot/stdout.expected $testroot/stdout
474 if [ "$ret" != "0" ]; then
475 diff -u $testroot/stdout.expected $testroot/stdout
476 test_done "$testroot" "$ret"
480 echo "modified alpha" > $testroot/content.expected
481 echo "beta" >> $testroot/content.expected
482 echo "zeta" >> $testroot/content.expected
483 echo "delta" >> $testroot/content.expected
484 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
485 $testroot/wt/gamma/delta > $testroot/content
487 cmp -s $testroot/content.expected $testroot/content
489 if [ "$ret" != "0" ]; then
490 diff -u $testroot/content.expected $testroot/content
491 test_done "$testroot" "$ret"
495 echo 'M alpha' > $testroot/stdout.expected
496 (cd $testroot/wt && got status > $testroot/stdout)
498 cmp -s $testroot/stdout.expected $testroot/stdout
500 if [ "$ret" != "0" ]; then
501 diff -u $testroot/stdout.expected $testroot/stdout
503 test_done "$testroot" "$ret"
506 function test_checkout_symlink {
507 local testroot=`test_init checkout_symlink`
509 (cd $testroot/repo && ln -s alpha alpha.link)
510 (cd $testroot/repo && ln -s epsilon epsilon.link)
511 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
512 (cd $testroot/repo && ln -s passwd.link passwd2.link)
513 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
514 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
515 (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
516 (cd $testroot/repo && git add .)
517 git_commit $testroot/repo -m "add symlinks"
519 got checkout $testroot/repo $testroot/wt > $testroot/stdout
521 if [ "$ret" != "0" ]; then
522 echo "got checkout failed unexpectedly" >&2
523 test_done "$testroot" "$ret"
527 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
528 echo "A $testroot/wt/alpha.link" >> $testroot/stdout.expected
529 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
530 echo "A $testroot/wt/dotgotfoo.link" >> $testroot/stdout.expected
531 echo "A $testroot/wt/epsilon/beta.link" >> $testroot/stdout.expected
532 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
533 echo "A $testroot/wt/epsilon.link" >> $testroot/stdout.expected
534 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
535 echo "A $testroot/wt/nonexistent.link" >> $testroot/stdout.expected
536 echo "A $testroot/wt/passwd.link" >> $testroot/stdout.expected
537 echo "A $testroot/wt/passwd2.link" >> $testroot/stdout.expected
538 echo "Now shut up and hack" >> $testroot/stdout.expected
540 cmp -s $testroot/stdout.expected $testroot/stdout
542 if [ "$ret" != "0" ]; then
543 diff -u $testroot/stdout.expected $testroot/stdout
544 test_done "$testroot" "$ret"
548 if ! [ -h $testroot/wt/alpha.link ]; then
549 echo "alpha.link is not a symlink"
550 test_done "$testroot" "1"
554 readlink $testroot/wt/alpha.link > $testroot/stdout
555 echo "alpha" > $testroot/stdout.expected
556 cmp -s $testroot/stdout.expected $testroot/stdout
558 if [ "$ret" != "0" ]; then
559 diff -u $testroot/stdout.expected $testroot/stdout
560 test_done "$testroot" "$ret"
564 if ! [ -h $testroot/wt/epsilon.link ]; then
565 echo "epsilon.link is not a symlink"
566 test_done "$testroot" "1"
570 readlink $testroot/wt/epsilon.link > $testroot/stdout
571 echo "epsilon" > $testroot/stdout.expected
572 cmp -s $testroot/stdout.expected $testroot/stdout
574 if [ "$ret" != "0" ]; then
575 diff -u $testroot/stdout.expected $testroot/stdout
576 test_done "$testroot" "$ret"
580 if [ -h $testroot/wt/passwd.link ]; then
581 echo -n "passwd.link symlink points outside of work tree: " >&2
582 readlink $testroot/wt/passwd.link >&2
583 test_done "$testroot" "1"
587 echo -n "/etc/passwd" > $testroot/content.expected
588 cp $testroot/wt/passwd.link $testroot/content
590 cmp -s $testroot/content.expected $testroot/content
592 if [ "$ret" != "0" ]; then
593 diff -u $testroot/content.expected $testroot/content
594 test_done "$testroot" "$ret"
598 if ! [ -h $testroot/wt/passwd2.link ]; then
599 echo "passwd2.link is not a symlink"
600 test_done "$testroot" "1"
604 readlink $testroot/wt/passwd2.link > $testroot/stdout
605 echo "passwd.link" > $testroot/stdout.expected
606 cmp -s $testroot/stdout.expected $testroot/stdout
608 if [ "$ret" != "0" ]; then
609 diff -u $testroot/stdout.expected $testroot/stdout
610 test_done "$testroot" "$ret"
614 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
615 echo "../beta" > $testroot/stdout.expected
616 cmp -s $testroot/stdout.expected $testroot/stdout
618 if [ "$ret" != "0" ]; then
619 diff -u $testroot/stdout.expected $testroot/stdout
620 test_done "$testroot" "$ret"
624 readlink $testroot/wt/nonexistent.link > $testroot/stdout
625 echo "nonexistent" > $testroot/stdout.expected
626 cmp -s $testroot/stdout.expected $testroot/stdout
628 if [ "$ret" != "0" ]; then
629 diff -u $testroot/stdout.expected $testroot/stdout
630 test_done "$testroot" "$ret"
634 if [ -h $testroot/wt/dotgotfoo.link ]; then
635 echo -n "dotgotfoo.link symlink points into .got dir: " >&2
636 readlink $testroot/wt/dotgotfoo.link >&2
637 test_done "$testroot" "1"
641 echo -n ".got/foo" > $testroot/content.expected
642 cp $testroot/wt/dotgotfoo.link $testroot/content
644 cmp -s $testroot/content.expected $testroot/content
646 if [ "$ret" != "0" ]; then
647 diff -u $testroot/content.expected $testroot/content
649 test_done "$testroot" "$ret"
652 function test_checkout_symlink_relative_wtpath {
653 local testroot=`test_init checkout_symlink_with_wtpath`
655 (cd $testroot/repo && ln -s alpha alpha.link)
656 (cd $testroot/repo && ln -s epsilon epsilon.link)
657 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
658 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
659 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
660 (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
661 (cd $testroot/repo && git add .)
662 git_commit $testroot/repo -m "add symlinks"
664 (cd $testroot && got checkout $testroot/repo wt > /dev/null)
666 if [ "$ret" != "0" ]; then
667 test_done "$testroot" "$ret"
671 if ! [ -h $testroot/wt/alpha.link ]; then
672 echo "alpha.link is not a symlink"
673 test_done "$testroot" "1"
677 readlink $testroot/wt/alpha.link > $testroot/stdout
678 echo "alpha" > $testroot/stdout.expected
679 cmp -s $testroot/stdout.expected $testroot/stdout
681 if [ "$ret" != "0" ]; then
682 diff -u $testroot/stdout.expected $testroot/stdout
683 test_done "$testroot" "$ret"
687 if ! [ -h $testroot/wt/epsilon.link ]; then
688 echo "epsilon.link is not a symlink"
689 test_done "$testroot" "1"
693 readlink $testroot/wt/epsilon.link > $testroot/stdout
694 echo "epsilon" > $testroot/stdout.expected
695 cmp -s $testroot/stdout.expected $testroot/stdout
697 if [ "$ret" != "0" ]; then
698 diff -u $testroot/stdout.expected $testroot/stdout
699 test_done "$testroot" "$ret"
703 if [ -h $testroot/wt/passwd.link ]; then
704 echo -n "passwd.link symlink points outside of work tree: " >&2
705 readlink $testroot/wt/passwd.link >&2
706 test_done "$testroot" "1"
710 echo -n "/etc/passwd" > $testroot/content.expected
711 cp $testroot/wt/passwd.link $testroot/content
713 cmp -s $testroot/content.expected $testroot/content
715 if [ "$ret" != "0" ]; then
716 diff -u $testroot/content.expected $testroot/content
717 test_done "$testroot" "$ret"
721 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
722 echo "../beta" > $testroot/stdout.expected
723 cmp -s $testroot/stdout.expected $testroot/stdout
725 if [ "$ret" != "0" ]; then
726 diff -u $testroot/stdout.expected $testroot/stdout
727 test_done "$testroot" "$ret"
731 readlink $testroot/wt/nonexistent.link > $testroot/stdout
732 echo "nonexistent" > $testroot/stdout.expected
733 cmp -s $testroot/stdout.expected $testroot/stdout
735 if [ "$ret" != "0" ]; then
736 diff -u $testroot/stdout.expected $testroot/stdout
737 test_done "$testroot" "$ret"
741 if [ -h $testroot/wt/dotgotfoo.link ]; then
742 echo -n "dotgotfoo.link symlink points into .got dir: " >&2
743 readlink $testroot/wt/dotgotfoo.link >&2
744 test_done "$testroot" "1"
748 echo -n ".got/foo" > $testroot/content.expected
749 cp $testroot/wt/dotgotfoo.link $testroot/content
751 cmp -s $testroot/content.expected $testroot/content
753 if [ "$ret" != "0" ]; then
754 diff -u $testroot/content.expected $testroot/content
756 test_done "$testroot" "$ret"
759 run_test test_checkout_basic
760 run_test test_checkout_dir_exists
761 run_test test_checkout_dir_not_empty
762 run_test test_checkout_sets_xbit
763 run_test test_checkout_commit_from_wrong_branch
764 run_test test_checkout_tag
765 run_test test_checkout_ignores_submodules
766 run_test test_checkout_read_only
767 run_test test_checkout_into_nonempty_dir
768 run_test test_checkout_symlink
769 run_test test_checkout_symlink_relative_wtpath