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