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 f2900386 2022-10-31 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
35 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
36 f2900386 2022-10-31 thomas echo "got checkout failed unexpectedly" >&2
37 f2900386 2022-10-31 thomas test_done "$testroot" "1"
41 f2900386 2022-10-31 thomas mkdir $testroot/wt/psi
42 f2900386 2022-10-31 thomas echo "new" > $testroot/wt/psi/new
43 f2900386 2022-10-31 thomas (cd $testroot/wt && got add psi/new > /dev/null)
44 f2900386 2022-10-31 thomas echo "more alpha" >> $testroot/wt/alpha
45 f2900386 2022-10-31 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
47 f2900386 2022-10-31 thomas got send -q -r $testroot/repo-clone
49 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
50 f2900386 2022-10-31 thomas echo "got send failed unexpectedly" >&2
51 f2900386 2022-10-31 thomas test_done "$testroot" "1"
55 f2900386 2022-10-31 thomas # Verify that the send operation worked fine.
56 f2900386 2022-10-31 thomas got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone2
58 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
59 f2900386 2022-10-31 thomas echo "got clone failed unexpectedly" >&2
60 f2900386 2022-10-31 thomas test_done "$testroot" "1"
64 f2900386 2022-10-31 thomas got tree -R -r $testroot/repo-clone2 > $testroot/stdout
65 f2900386 2022-10-31 thomas cat > $testroot/stdout.expected <<EOF
69 f2900386 2022-10-31 thomas epsilon/zeta
71 f2900386 2022-10-31 thomas gamma/delta
75 f2900386 2022-10-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
77 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
78 f2900386 2022-10-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
79 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
83 f2900386 2022-10-31 thomas # sending to a repository should result in a new pack file
84 f2900386 2022-10-31 thomas ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.after
85 f2900386 2022-10-31 thomas diff -u $testroot/repo-list.before $testroot/repo-list.after \
86 f2900386 2022-10-31 thomas > $testroot/repo-list.diff
87 f2900386 2022-10-31 thomas grep '^+[^+]' < $testroot/repo-list.diff > $testroot/repo-list.newlines
88 f2900386 2022-10-31 thomas nplus=`wc -l < $testroot/repo-list.newlines | tr -d ' '`
89 f2900386 2022-10-31 thomas if [ "$nplus" != "2" ]; then
90 f2900386 2022-10-31 thomas echo "$nplus new files created"
91 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
94 f2900386 2022-10-31 thomas egrep -q '\+pack-[a-f0-9]{40}.pack' $testroot/repo-list.newlines
96 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
97 f2900386 2022-10-31 thomas echo "new pack file not found in ${GOTD_TEST_REPO}"
98 f2900386 2022-10-31 thomas cat $testroot/repo-list.newlines
99 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
102 f2900386 2022-10-31 thomas egrep -q '\+pack-[a-f0-9]{40}.idx' $testroot/repo-list.newlines
104 f2900386 2022-10-31 thomas if [ $ret -ne 0 ]; then
105 f2900386 2022-10-31 thomas echo "new pack index not found in ${GOTD_TEST_REPO}"
106 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
110 f2900386 2022-10-31 thomas test_done "$testroot" "$ret"
113 f2900386 2022-10-31 thomas test_parseargs "$@"
114 f2900386 2022-10-31 thomas run_test test_send_basic