3 f2900386 2022-10-31 thomas # Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 f2900386 2022-10-31 thomas . ../cmdline/common.sh
18 f2900386 2022-10-31 thomas . ./common.sh
20 f2900386 2022-10-31 thomas test_send_basic() {
21 f2900386 2022-10-31 thomas local testroot=`test_init send_basic 1`
23 f2900386 2022-10-31 thomas ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.before
25 f2900386 2022-10-31 thomas got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
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"
33 c9aa63fb 2023-01-10 thomas # create a second clone to test an incremental fetch with later
34 c9aa63fb 2023-01-10 thomas got clone -q -m ${GOTD_TEST_REPO_URL} $testroot/repo-clone2
36 c9aa63fb 2023-01-10 thomas if [ $ret -ne 0 ]; then
37 c9aa63fb 2023-01-10 thomas echo "got clone failed unexpectedly" >&2
38 c9aa63fb 2023-01-10 thomas test_done "$testroot" "1"
42 f2900386 2022-10-31 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
44 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
45 f2900386 2022-10-31 thomas echo "got checkout failed unexpectedly" >&2
46 f2900386 2022-10-31 thomas test_done "$testroot" "1"
50 f2900386 2022-10-31 thomas mkdir $testroot/wt/psi
51 f2900386 2022-10-31 thomas echo "new" > $testroot/wt/psi/new
52 f2900386 2022-10-31 thomas (cd $testroot/wt && got add psi/new > /dev/null)
53 f2900386 2022-10-31 thomas echo "more alpha" >> $testroot/wt/alpha
54 f2900386 2022-10-31 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
56 f2900386 2022-10-31 thomas got send -q -r $testroot/repo-clone
58 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
59 f2900386 2022-10-31 thomas echo "got send failed unexpectedly" >&2
60 f2900386 2022-10-31 thomas test_done "$testroot" "1"
64 f2900386 2022-10-31 thomas # Verify that the send operation worked fine.
65 c9aa63fb 2023-01-10 thomas got fetch -q -r $testroot/repo-clone2
67 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
68 c9aa63fb 2023-01-10 thomas echo "got fetch failed unexpectedly" >&2
69 f2900386 2022-10-31 thomas test_done "$testroot" "1"
73 f2900386 2022-10-31 thomas got tree -R -r $testroot/repo-clone2 > $testroot/stdout
74 f2900386 2022-10-31 thomas cat > $testroot/stdout.expected <<EOF
78 f2900386 2022-10-31 thomas epsilon/zeta
80 f2900386 2022-10-31 thomas gamma/delta
84 f2900386 2022-10-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
86 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
87 f2900386 2022-10-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
88 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
92 f2900386 2022-10-31 thomas # sending to a repository should result in a new pack file
93 f2900386 2022-10-31 thomas ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.after
94 f2900386 2022-10-31 thomas diff -u $testroot/repo-list.before $testroot/repo-list.after \
95 f2900386 2022-10-31 thomas > $testroot/repo-list.diff
96 f2900386 2022-10-31 thomas grep '^+[^+]' < $testroot/repo-list.diff > $testroot/repo-list.newlines
97 f2900386 2022-10-31 thomas nplus=`wc -l < $testroot/repo-list.newlines | tr -d ' '`
98 f2900386 2022-10-31 thomas if [ "$nplus" != "2" ]; then
99 f2900386 2022-10-31 thomas echo "$nplus new files created"
100 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
103 f2900386 2022-10-31 thomas egrep -q '\+pack-[a-f0-9]{40}.pack' $testroot/repo-list.newlines
105 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
106 f2900386 2022-10-31 thomas echo "new pack file not found in ${GOTD_TEST_REPO}"
107 f2900386 2022-10-31 thomas cat $testroot/repo-list.newlines
108 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
111 f2900386 2022-10-31 thomas egrep -q '\+pack-[a-f0-9]{40}.idx' $testroot/repo-list.newlines
113 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
114 f2900386 2022-10-31 thomas echo "new pack index not found in ${GOTD_TEST_REPO}"
115 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
119 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
122 f2900386 2022-10-31 thomas test_parseargs "$@"
123 f2900386 2022-10-31 thomas run_test test_send_basic