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