Blame


1 f2900386 2022-10-31 thomas #!/bin/sh
2 f2900386 2022-10-31 thomas #
3 f2900386 2022-10-31 thomas # Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
4 f2900386 2022-10-31 thomas #
5 f2900386 2022-10-31 thomas # Permission to use, copy, modify, and distribute this software for any
6 f2900386 2022-10-31 thomas # purpose with or without fee is hereby granted, provided that the above
7 f2900386 2022-10-31 thomas # copyright notice and this permission notice appear in all copies.
8 f2900386 2022-10-31 thomas #
9 f2900386 2022-10-31 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f2900386 2022-10-31 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f2900386 2022-10-31 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f2900386 2022-10-31 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f2900386 2022-10-31 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f2900386 2022-10-31 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f2900386 2022-10-31 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 f2900386 2022-10-31 thomas
17 f2900386 2022-10-31 thomas . ../cmdline/common.sh
18 f2900386 2022-10-31 thomas . ./common.sh
19 f2900386 2022-10-31 thomas
20 f2900386 2022-10-31 thomas test_clone_basic() {
21 f2900386 2022-10-31 thomas local testroot=`test_init clone_basic 1`
22 f2900386 2022-10-31 thomas
23 f2900386 2022-10-31 thomas cp -r ${GOTD_TEST_REPO} $testroot/repo-copy
24 f2900386 2022-10-31 thomas
25 f2900386 2022-10-31 thomas got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
26 f2900386 2022-10-31 thomas ret=$?
27 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
28 f2900386 2022-10-31 thomas echo "got clone failed unexpectedly" >&2
29 f2900386 2022-10-31 thomas test_done "$testroot" "1"
30 f2900386 2022-10-31 thomas return 1
31 f2900386 2022-10-31 thomas fi
32 f2900386 2022-10-31 thomas
33 f2900386 2022-10-31 thomas # Verify that the clone operation worked fine.
34 f2900386 2022-10-31 thomas git_fsck "$testroot" "$testroot/repo-clone"
35 f2900386 2022-10-31 thomas ret=$?
36 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
37 f2900386 2022-10-31 thomas test_done "$testroot" "1"
38 f2900386 2022-10-31 thomas return 1
39 f2900386 2022-10-31 thomas fi
40 f2900386 2022-10-31 thomas
41 f2900386 2022-10-31 thomas got tree -R -r "$testroot/repo-clone" > $testroot/stdout
42 f2900386 2022-10-31 thomas cat > $testroot/stdout.expected <<EOF
43 f2900386 2022-10-31 thomas alpha
44 f2900386 2022-10-31 thomas beta
45 f2900386 2022-10-31 thomas epsilon/
46 f2900386 2022-10-31 thomas epsilon/zeta
47 f2900386 2022-10-31 thomas gamma/
48 f2900386 2022-10-31 thomas gamma/delta
49 f2900386 2022-10-31 thomas EOF
50 f2900386 2022-10-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
51 f2900386 2022-10-31 thomas ret=$?
52 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
53 f2900386 2022-10-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
54 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
55 f2900386 2022-10-31 thomas return 1
56 f2900386 2022-10-31 thomas fi
57 f2900386 2022-10-31 thomas
58 f2900386 2022-10-31 thomas # cloning a repository should not result in modifications
59 f2900386 2022-10-31 thomas diff -urN ${GOTD_TEST_REPO} $testroot/repo-copy \
60 f2900386 2022-10-31 thomas > $testroot/stdout
61 f2900386 2022-10-31 thomas echo -n > $testroot/stdout.expected
62 f2900386 2022-10-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
63 f2900386 2022-10-31 thomas ret=$?
64 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
65 f2900386 2022-10-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
66 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
67 f2900386 2022-10-31 thomas return 1
68 f2900386 2022-10-31 thomas fi
69 f2900386 2022-10-31 thomas
70 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
71 f2900386 2022-10-31 thomas }
72 f2900386 2022-10-31 thomas
73 729a7e24 2022-11-17 thomas test_send_to_read_only_repo() {
74 729a7e24 2022-11-17 thomas local testroot=`test_init send_to_read_only_repo 1`
75 729a7e24 2022-11-17 thomas
76 729a7e24 2022-11-17 thomas ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.before
77 729a7e24 2022-11-17 thomas
78 729a7e24 2022-11-17 thomas got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
79 729a7e24 2022-11-17 thomas ret=$?
80 729a7e24 2022-11-17 thomas if [ $ret -ne 0 ]; then
81 729a7e24 2022-11-17 thomas echo "got clone failed unexpectedly" >&2
82 729a7e24 2022-11-17 thomas test_done "$testroot" "1"
83 729a7e24 2022-11-17 thomas return 1
84 729a7e24 2022-11-17 thomas fi
85 729a7e24 2022-11-17 thomas
86 729a7e24 2022-11-17 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
87 729a7e24 2022-11-17 thomas ret=$?
88 729a7e24 2022-11-17 thomas if [ $ret -ne 0 ]; then
89 729a7e24 2022-11-17 thomas echo "got checkout failed unexpectedly" >&2
90 729a7e24 2022-11-17 thomas test_done "$testroot" "1"
91 729a7e24 2022-11-17 thomas return 1
92 729a7e24 2022-11-17 thomas fi
93 729a7e24 2022-11-17 thomas
94 729a7e24 2022-11-17 thomas mkdir $testroot/wt/psi
95 729a7e24 2022-11-17 thomas echo "new" > $testroot/wt/psi/new
96 729a7e24 2022-11-17 thomas (cd $testroot/wt && got add psi/new > /dev/null)
97 729a7e24 2022-11-17 thomas echo "more alpha" >> $testroot/wt/alpha
98 729a7e24 2022-11-17 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
99 729a7e24 2022-11-17 thomas
100 f1cbd0ef 2022-12-11 thomas got send -q -r $testroot/repo-clone 2>$testroot/stderr.raw
101 729a7e24 2022-11-17 thomas ret=$?
102 729a7e24 2022-11-17 thomas if [ $ret -eq 0 ]; then
103 729a7e24 2022-11-17 thomas echo "got send succeeded unexpectedly" >&2
104 729a7e24 2022-11-17 thomas test_done "$testroot" "1"
105 729a7e24 2022-11-17 thomas return 1
106 729a7e24 2022-11-17 thomas fi
107 f1cbd0ef 2022-12-11 thomas grep -v ^gotsh: $testroot/stderr.raw > $testroot/stderr
108 729a7e24 2022-11-17 thomas
109 729a7e24 2022-11-17 thomas echo 'got-send-pack: test-repo: Permission denied' \
110 729a7e24 2022-11-17 thomas > $testroot/stderr.expected
111 729a7e24 2022-11-17 thomas echo 'got: could not send pack file' >> $testroot/stderr.expected
112 729a7e24 2022-11-17 thomas cmp -s $testroot/stderr.expected $testroot/stderr
113 729a7e24 2022-11-17 thomas ret=$?
114 729a7e24 2022-11-17 thomas if [ $ret -ne 0 ]; then
115 729a7e24 2022-11-17 thomas diff -u $testroot/stderr.expected $testroot/stderr
116 729a7e24 2022-11-17 thomas fi
117 729a7e24 2022-11-17 thomas test_done "$testroot" "$ret"
118 729a7e24 2022-11-17 thomas }
119 729a7e24 2022-11-17 thomas
120 f2900386 2022-10-31 thomas test_parseargs "$@"
121 f2900386 2022-10-31 thomas run_test test_clone_basic
122 729a7e24 2022-11-17 thomas run_test test_send_to_read_only_repo