3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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 export GOT_AUTHOR="Flan Hacker <flan_hacker@openbsd.org>"
19 export MALLOC_OPTIONS=S
30 (cd $repo && git commit -q -a "$@")
37 (cd $repo && git rm -q "$@")
40 function git_show_head
43 (cd $repo && git show --no-patch --pretty='format:%H')
46 function git_show_parent_commit
49 (cd $repo && git show --no-patch --pretty='format:%P')
52 function git_show_tree
55 (cd $repo && git show --no-patch --pretty='format:%T')
64 while [ trimcount -gt 0 ]; do
72 function git_commit_tree
77 (cd $repo && git commit-tree -m "$msg" "$tree")
80 function make_test_tree
84 echo alpha > $repo/alpha
85 echo beta > $repo/beta
87 echo delta > $repo/gamma/delta
89 echo zeta > $repo/epsilon/zeta
98 got tree -r $repo -i $tree_path | grep ${filename}$ | cut -d' ' -f 1
105 if [ -z "$testname" ]; then
106 echo "No test name provided" >&2
109 local testroot=`mktemp -p /tmp -d got-test-$testname-XXXXXXXX`
111 git_init $testroot/repo
112 if [ -z "$no_tree" ]; then
113 make_test_tree $testroot/repo
114 (cd $repo && git add .)
115 git_commit $testroot/repo -m "adding the test tree"
120 function test_cleanup
124 (cd $testroot/repo && git fsck --strict \
125 > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
127 if [ "$ret" != "0" ]; then
129 cat $testroot/fsck.stderr
130 echo "git fsck failed; leaving test data in $testroot"
148 if [ "$result" == "0" ]; then
149 test_cleanup "$testroot" || return 1
151 elif echo "$result" | grep -q "^xfail"; then
152 # expected test failure; test reproduces an unfixed bug
154 test_cleanup "$testroot" || return 1
156 echo "test failed; leaving test data in $testroot"