Blame


1 6ae16afd 2022-10-31 stsp #!/bin/sh
2 6ae16afd 2022-10-31 stsp #
3 6ae16afd 2022-10-31 stsp # Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
4 6ae16afd 2022-10-31 stsp #
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.
8 6ae16afd 2022-10-31 stsp #
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.
16 6ae16afd 2022-10-31 stsp
17 6ae16afd 2022-10-31 stsp . ../cmdline/common.sh
18 6ae16afd 2022-10-31 stsp . ./common.sh
19 6ae16afd 2022-10-31 stsp
20 6ae16afd 2022-10-31 stsp test_clone_basic() {
21 6ae16afd 2022-10-31 stsp local testroot=`test_init clone_basic 1`
22 6ae16afd 2022-10-31 stsp
23 6ae16afd 2022-10-31 stsp cp -r ${GOTD_TEST_REPO} $testroot/repo-copy
24 6ae16afd 2022-10-31 stsp
25 6ae16afd 2022-10-31 stsp got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
26 6ae16afd 2022-10-31 stsp ret=$?
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"
30 6ae16afd 2022-10-31 stsp return 1
31 6ae16afd 2022-10-31 stsp fi
32 6ae16afd 2022-10-31 stsp
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"
35 6ae16afd 2022-10-31 stsp ret=$?
36 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
37 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
38 6ae16afd 2022-10-31 stsp return 1
39 6ae16afd 2022-10-31 stsp fi
40 6ae16afd 2022-10-31 stsp
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
43 6ae16afd 2022-10-31 stsp alpha
44 6ae16afd 2022-10-31 stsp beta
45 6ae16afd 2022-10-31 stsp epsilon/
46 6ae16afd 2022-10-31 stsp epsilon/zeta
47 6ae16afd 2022-10-31 stsp gamma/
48 6ae16afd 2022-10-31 stsp gamma/delta
49 6ae16afd 2022-10-31 stsp EOF
50 6ae16afd 2022-10-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
51 6ae16afd 2022-10-31 stsp ret=$?
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"
55 6ae16afd 2022-10-31 stsp return 1
56 6ae16afd 2022-10-31 stsp fi
57 6ae16afd 2022-10-31 stsp
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
63 6ae16afd 2022-10-31 stsp ret=$?
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"
67 6ae16afd 2022-10-31 stsp return 1
68 6ae16afd 2022-10-31 stsp fi
69 6ae16afd 2022-10-31 stsp
70 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
71 6ae16afd 2022-10-31 stsp }
72 6ae16afd 2022-10-31 stsp
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`
75 0ccf3acb 2022-11-16 stsp
76 0ccf3acb 2022-11-16 stsp ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.before
77 0ccf3acb 2022-11-16 stsp
78 0ccf3acb 2022-11-16 stsp got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
79 0ccf3acb 2022-11-16 stsp ret=$?
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"
83 0ccf3acb 2022-11-16 stsp return 1
84 0ccf3acb 2022-11-16 stsp fi
85 0ccf3acb 2022-11-16 stsp
86 0ccf3acb 2022-11-16 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
87 0ccf3acb 2022-11-16 stsp ret=$?
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"
91 0ccf3acb 2022-11-16 stsp return 1
92 0ccf3acb 2022-11-16 stsp fi
93 0ccf3acb 2022-11-16 stsp
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)
99 0ccf3acb 2022-11-16 stsp
100 30eb1ad6 2022-12-09 stsp got send -q -r $testroot/repo-clone 2>$testroot/stderr.raw
101 0ccf3acb 2022-11-16 stsp ret=$?
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"
105 0ccf3acb 2022-11-16 stsp return 1
106 0ccf3acb 2022-11-16 stsp fi
107 30eb1ad6 2022-12-09 stsp grep -v ^gotsh: $testroot/stderr.raw > $testroot/stderr
108 0ccf3acb 2022-11-16 stsp
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
113 0ccf3acb 2022-11-16 stsp ret=$?
114 0ccf3acb 2022-11-16 stsp if [ $ret -ne 0 ]; then
115 0ccf3acb 2022-11-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
116 0ccf3acb 2022-11-16 stsp fi
117 0ccf3acb 2022-11-16 stsp test_done "$testroot" "$ret"
118 0ccf3acb 2022-11-16 stsp }
119 0ccf3acb 2022-11-16 stsp
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