Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ../cmdline/common.sh
18 . ./common.sh
20 test_clone_basic() {
21 local testroot=`test_init clone_basic 1`
23 cp -r ${GOTD_TEST_REPO} $testroot/repo-copy
25 got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
26 ret=$?
27 if [ $ret -ne 0 ]; then
28 echo "got clone failed unexpectedly" >&2
29 test_done "$testroot" "1"
30 return 1
31 fi
33 # Verify that the clone operation worked fine.
34 git_fsck "$testroot" "$testroot/repo-clone"
35 ret=$?
36 if [ $ret -ne 0 ]; then
37 test_done "$testroot" "1"
38 return 1
39 fi
41 got tree -R -r "$testroot/repo-clone" > $testroot/stdout
42 cat > $testroot/stdout.expected <<EOF
43 alpha
44 beta
45 epsilon/
46 epsilon/zeta
47 gamma/
48 gamma/delta
49 EOF
50 cmp -s $testroot/stdout.expected $testroot/stdout
51 ret=$?
52 if [ $ret -ne 0 ]; then
53 diff -u $testroot/stdout.expected $testroot/stdout
54 test_done "$testroot" "$ret"
55 return 1
56 fi
58 # cloning a repository should not result in modifications
59 diff -urN ${GOTD_TEST_REPO} $testroot/repo-copy \
60 > $testroot/stdout
61 echo -n > $testroot/stdout.expected
62 cmp -s $testroot/stdout.expected $testroot/stdout
63 ret=$?
64 if [ $ret -ne 0 ]; then
65 diff -u $testroot/stdout.expected $testroot/stdout
66 test_done "$testroot" "$ret"
67 return 1
68 fi
70 test_done "$testroot" "$ret"
71 }
73 test_parseargs "$@"
74 run_test test_clone_basic