3 a184c764 2023-04-22 thomas # Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
5 a184c764 2023-04-22 thomas # Permission to use, copy, modify, and distribute this software for any
6 a184c764 2023-04-22 thomas # purpose with or without fee is hereby granted, provided that the above
7 a184c764 2023-04-22 thomas # copyright notice and this permission notice appear in all copies.
9 a184c764 2023-04-22 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 a184c764 2023-04-22 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 a184c764 2023-04-22 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 a184c764 2023-04-22 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 a184c764 2023-04-22 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 a184c764 2023-04-22 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 a184c764 2023-04-22 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 a184c764 2023-04-22 thomas . ./common.sh
19 a184c764 2023-04-22 thomas test_tree_basic()
21 a184c764 2023-04-22 thomas test_init tree_basic 48 8
23 a184c764 2023-04-22 thomas local head_id=`git_show_head $testroot/repo`
25 a184c764 2023-04-22 thomas cat <<EOF >$TOG_TEST_SCRIPT
26 a184c764 2023-04-22 thomas SCREENDUMP
29 a184c764 2023-04-22 thomas cat <<EOF >$testroot/view.expected
30 a184c764 2023-04-22 thomas commit $head_id
40 a184c764 2023-04-22 thomas cd $testroot/repo && tog tree
41 a184c764 2023-04-22 thomas cmp -s $testroot/view.expected $testroot/view
43 a184c764 2023-04-22 thomas if [ $ret -ne 0 ]; then
44 a184c764 2023-04-22 thomas diff -u $testroot/view.expected $testroot/view
45 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
49 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
52 a184c764 2023-04-22 thomas test_tree_vsplit_blame()
54 a184c764 2023-04-22 thomas test_init tree_vsplit_blame 120 8
56 a184c764 2023-04-22 thomas local head_id=`git_show_head $testroot/repo`
57 a184c764 2023-04-22 thomas local head_id_truncated=`trim_obj_id 8 $head_id`
58 a184c764 2023-04-22 thomas local head_id_short=`trim_obj_id 32 $head_id`
60 a184c764 2023-04-22 thomas cat <<EOF >$TOG_TEST_SCRIPT
62 a184c764 2023-04-22 thomas WAIT_FOR_UI wait for blame to finish
63 a184c764 2023-04-22 thomas SCREENDUMP
66 a184c764 2023-04-22 thomas cat <<EOF >$testroot/view.expected
67 a184c764 2023-04-22 thomas commit $head_id_truncated|commit $head_id
68 a184c764 2023-04-22 thomas [1/4] / |[1/1] /alpha
69 a184c764 2023-04-22 thomas |$head_id_short alpha
72 a184c764 2023-04-22 thomas epsilon/ |
77 a184c764 2023-04-22 thomas cd $testroot/repo && tog tree
78 a184c764 2023-04-22 thomas cmp -s $testroot/view.expected $testroot/view
80 a184c764 2023-04-22 thomas if [ $ret -ne 0 ]; then
81 a184c764 2023-04-22 thomas diff -u $testroot/view.expected $testroot/view
82 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
86 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
89 a184c764 2023-04-22 thomas test_tree_hsplit_blame()
91 a184c764 2023-04-22 thomas test_init tree_hsplit_blame 48 24
93 a184c764 2023-04-22 thomas local head_id=`git_show_head $testroot/repo`
94 a184c764 2023-04-22 thomas local head_id_truncated=`trim_obj_id 8 $head_id`
95 a184c764 2023-04-22 thomas local head_id_short=`trim_obj_id 32 $head_id`
97 a184c764 2023-04-22 thomas cat <<EOF >$TOG_TEST_SCRIPT
100 a184c764 2023-04-22 thomas S toggle horizontal split
101 a184c764 2023-04-22 thomas 4- 4x decrease blame split
102 a184c764 2023-04-22 thomas WAIT_FOR_UI wait for blame to finish
103 a184c764 2023-04-22 thomas SCREENDUMP
106 a184c764 2023-04-22 thomas cat <<EOF >$testroot/view.expected
107 a184c764 2023-04-22 thomas commit $head_id
117 a184c764 2023-04-22 thomas ------------------------------------------------
118 a184c764 2023-04-22 thomas commit $head_id
119 a184c764 2023-04-22 thomas [1/1] /beta
120 a184c764 2023-04-22 thomas $head_id_short beta
133 a184c764 2023-04-22 thomas cd $testroot/repo && tog tree
134 a184c764 2023-04-22 thomas cmp -s $testroot/view.expected $testroot/view
136 a184c764 2023-04-22 thomas if [ $ret -ne 0 ]; then
137 a184c764 2023-04-22 thomas diff -u $testroot/view.expected $testroot/view
138 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
142 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
145 94d1a66a 2023-06-25 thomas test_tree_symlink()
147 94d1a66a 2023-06-25 thomas test_init tree_symlink 48 8
149 94d1a66a 2023-06-25 thomas (cd $testroot/repo && ln -s alpha symlink)
150 94d1a66a 2023-06-25 thomas (cd $testroot/repo && git add symlink)
151 94d1a66a 2023-06-25 thomas git_commit $testroot/repo -m "symlink to alpha"
152 94d1a66a 2023-06-25 thomas local head_id=`git_show_head $testroot/repo`
154 94d1a66a 2023-06-25 thomas cat <<EOF >$TOG_TEST_SCRIPT
155 94d1a66a 2023-06-25 thomas SCREENDUMP
158 94d1a66a 2023-06-25 thomas cat <<EOF >$testroot/view.expected
159 94d1a66a 2023-06-25 thomas commit $head_id
166 94d1a66a 2023-06-25 thomas symlink@ -> alpha
169 94d1a66a 2023-06-25 thomas cd $testroot/repo && tog tree
170 94d1a66a 2023-06-25 thomas cmp -s $testroot/view.expected $testroot/view
172 94d1a66a 2023-06-25 thomas if [ $ret -ne 0 ]; then
173 94d1a66a 2023-06-25 thomas diff -u $testroot/view.expected $testroot/view
174 94d1a66a 2023-06-25 thomas test_done "$testroot" "$ret"
178 94d1a66a 2023-06-25 thomas test_done "$testroot" "$ret"
181 66b04f8f 2023-07-19 thomas test_tree_commit_keywords()
183 66b04f8f 2023-07-19 thomas test_init tree_commit_keywords 48 11
184 66b04f8f 2023-07-19 thomas local repo="$testroot/repo"
185 66b04f8f 2023-07-19 thomas local wt="$testroot/wt"
186 66b04f8f 2023-07-19 thomas local id=$(git_show_head "$repo")
188 66b04f8f 2023-07-19 thomas set -A ids "$id"
190 66b04f8f 2023-07-19 thomas got checkout "$repo" "$wt" > /dev/null
192 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
193 66b04f8f 2023-07-19 thomas echo "got checkout failed unexpectedly"
194 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
198 66b04f8f 2023-07-19 thomas # move into the work tree (test is run in a subshell)
201 66b04f8f 2023-07-19 thomas for i in $(seq 8); do
202 66b04f8f 2023-07-19 thomas if [ $(( i % 2 )) -eq 0 ]; then
203 66b04f8f 2023-07-19 thomas echo "file${i}" > "file${i}"
204 66b04f8f 2023-07-19 thomas got add "file${i}" > /dev/null
206 66b04f8f 2023-07-19 thomas echo "alpha $i" > alpha
209 66b04f8f 2023-07-19 thomas got ci -m "commit $i" > /dev/null
211 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
212 66b04f8f 2023-07-19 thomas echo "commit failed unexpectedly" >&2
213 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
217 66b04f8f 2023-07-19 thomas id=$(git_show_head "$repo")
218 66b04f8f 2023-07-19 thomas set -- "$ids" "$id"
223 66b04f8f 2023-07-19 thomas cat <<-EOF >$TOG_TEST_SCRIPT
224 66b04f8f 2023-07-19 thomas SCREENDUMP
227 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
228 66b04f8f 2023-07-19 thomas commit $(pop_id 8 $ids)
241 66b04f8f 2023-07-19 thomas tog tree -c:base:-
242 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
244 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
245 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
246 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
250 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
251 66b04f8f 2023-07-19 thomas commit $(pop_id 6 $ids)
264 66b04f8f 2023-07-19 thomas tog tree -cmaster:-3
265 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
267 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
268 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
269 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
273 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
274 66b04f8f 2023-07-19 thomas commit $(pop_id 9 $ids)
287 66b04f8f 2023-07-19 thomas got up -c:head:-99 > /dev/null
288 66b04f8f 2023-07-19 thomas tog tree -c:base:+99
289 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
291 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
292 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
293 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
297 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
298 66b04f8f 2023-07-19 thomas commit $(pop_id 4 $ids)
311 66b04f8f 2023-07-19 thomas tog tree -c:head:-5
312 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
314 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
315 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
316 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
320 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
321 66b04f8f 2023-07-19 thomas commit $(pop_id 1 $ids)
334 66b04f8f 2023-07-19 thomas tog tree -r "$repo" -cmaster:-99
335 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
337 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
338 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
339 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
342 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
345 a184c764 2023-04-22 thomas test_parseargs "$@"
346 a184c764 2023-04-22 thomas run_test test_tree_basic
347 a184c764 2023-04-22 thomas run_test test_tree_vsplit_blame
348 a184c764 2023-04-22 thomas run_test test_tree_hsplit_blame
349 94d1a66a 2023-06-25 thomas run_test test_tree_symlink
350 66b04f8f 2023-07-19 thomas run_test test_tree_commit_keywords