3 # Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
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.
21 test_init tree_basic 48 8
23 local head_id=`git_show_head $testroot/repo`
25 cat <<EOF >$TOG_TEST_SCRIPT
29 cat <<EOF >$testroot/view.expected
40 cd $testroot/repo && tog tree
41 cmp -s $testroot/view.expected $testroot/view
43 if [ $ret -ne 0 ]; then
44 diff -u $testroot/view.expected $testroot/view
45 test_done "$testroot" "$ret"
49 test_done "$testroot" "$ret"
52 test_tree_vsplit_blame()
54 test_init tree_vsplit_blame 120 8
56 local head_id=`git_show_head $testroot/repo`
57 local head_id_truncated=`trim_obj_id 8 $head_id`
58 local head_id_short=`trim_obj_id 32 $head_id`
60 cat <<EOF >$TOG_TEST_SCRIPT
62 WAIT_FOR_UI wait for blame to finish
66 cat <<EOF >$testroot/view.expected
67 commit $head_id_truncated|commit $head_id
77 cd $testroot/repo && tog tree
78 cmp -s $testroot/view.expected $testroot/view
80 if [ $ret -ne 0 ]; then
81 diff -u $testroot/view.expected $testroot/view
82 test_done "$testroot" "$ret"
86 test_done "$testroot" "$ret"
89 test_tree_hsplit_blame()
91 test_init tree_hsplit_blame 48 24
93 local head_id=`git_show_head $testroot/repo`
94 local head_id_truncated=`trim_obj_id 8 $head_id`
95 local head_id_short=`trim_obj_id 32 $head_id`
97 cat <<EOF >$TOG_TEST_SCRIPT
100 S toggle horizontal split
101 4- 4x decrease blame split
102 WAIT_FOR_UI wait for blame to finish
106 cat <<EOF >$testroot/view.expected
117 ------------------------------------------------
133 cd $testroot/repo && tog tree
134 cmp -s $testroot/view.expected $testroot/view
136 if [ $ret -ne 0 ]; then
137 diff -u $testroot/view.expected $testroot/view
138 test_done "$testroot" "$ret"
142 test_done "$testroot" "$ret"
147 test_init tree_symlink 48 8
149 (cd $testroot/repo && ln -s alpha symlink)
150 (cd $testroot/repo && git add symlink)
151 git_commit $testroot/repo -m "symlink to alpha"
152 local head_id=`git_show_head $testroot/repo`
154 cat <<EOF >$TOG_TEST_SCRIPT
158 cat <<EOF >$testroot/view.expected
169 cd $testroot/repo && tog tree
170 cmp -s $testroot/view.expected $testroot/view
172 if [ $ret -ne 0 ]; then
173 diff -u $testroot/view.expected $testroot/view
174 test_done "$testroot" "$ret"
178 test_done "$testroot" "$ret"
181 test_tree_commit_keywords()
183 test_init tree_commit_keywords 48 11
184 local repo="$testroot/repo"
185 local wt="$testroot/wt"
186 local id=$(git_show_head "$repo")
190 got checkout "$repo" "$wt" > /dev/null
192 if [ $ret -ne 0 ]; then
193 echo "got checkout failed unexpectedly"
194 test_done "$testroot" "$ret"
198 # move into the work tree (test is run in a subshell)
201 for i in $(seq 8); do
202 if [ $(( i % 2 )) -eq 0 ]; then
203 echo "file${i}" > "file${i}"
204 got add "file${i}" > /dev/null
206 echo "alpha $i" > alpha
209 got ci -m "commit $i" > /dev/null
211 if [ $ret -ne 0 ]; then
212 echo "commit failed unexpectedly" >&2
213 test_done "$testroot" "$ret"
217 id=$(git_show_head "$repo")
223 cat <<-EOF >$TOG_TEST_SCRIPT
227 cat <<-EOF >$testroot/view.expected
228 commit $(pop_id 8 $ids)
242 cmp -s $testroot/view.expected $testroot/view
244 if [ $ret -ne 0 ]; then
245 diff -u $testroot/view.expected $testroot/view
246 test_done "$testroot" "$ret"
250 cat <<-EOF >$testroot/view.expected
251 commit $(pop_id 6 $ids)
265 cmp -s $testroot/view.expected $testroot/view
267 if [ $ret -ne 0 ]; then
268 diff -u $testroot/view.expected $testroot/view
269 test_done "$testroot" "$ret"
273 cat <<-EOF >$testroot/view.expected
274 commit $(pop_id 9 $ids)
287 got up -c:head:-99 > /dev/null
289 cmp -s $testroot/view.expected $testroot/view
291 if [ $ret -ne 0 ]; then
292 diff -u $testroot/view.expected $testroot/view
293 test_done "$testroot" "$ret"
297 cat <<-EOF >$testroot/view.expected
298 commit $(pop_id 4 $ids)
312 cmp -s $testroot/view.expected $testroot/view
314 if [ $ret -ne 0 ]; then
315 diff -u $testroot/view.expected $testroot/view
316 test_done "$testroot" "$ret"
320 cat <<-EOF >$testroot/view.expected
321 commit $(pop_id 1 $ids)
334 tog tree -r "$repo" -cmaster:-99
335 cmp -s $testroot/view.expected $testroot/view
337 if [ $ret -ne 0 ]; then
338 diff -u $testroot/view.expected $testroot/view
339 test_done "$testroot" "$ret"
342 test_done "$testroot" "$ret"
346 run_test test_tree_basic
347 run_test test_tree_vsplit_blame
348 run_test test_tree_hsplit_blame
349 run_test test_tree_symlink
350 run_test test_tree_commit_keywords