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 8642913b 2023-07-26 thomas set -- "$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 8642913b 2023-07-26 thomas set -- "$@" "$id"
222 66b04f8f 2023-07-19 thomas cat <<-EOF >$TOG_TEST_SCRIPT
223 66b04f8f 2023-07-19 thomas SCREENDUMP
226 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
227 8642913b 2023-07-26 thomas commit $(pop_idx 8 $@)
240 66b04f8f 2023-07-19 thomas tog tree -c:base:-
241 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
243 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
244 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
245 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
249 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
250 8642913b 2023-07-26 thomas commit $(pop_idx 6 $@)
263 66b04f8f 2023-07-19 thomas tog tree -cmaster:-3
264 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
266 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
267 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
268 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
272 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
273 8642913b 2023-07-26 thomas commit $(pop_idx 9 $@)
286 66b04f8f 2023-07-19 thomas got up -c:head:-99 > /dev/null
287 66b04f8f 2023-07-19 thomas tog tree -c:base:+99
288 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
290 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
291 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
292 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
296 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
297 8642913b 2023-07-26 thomas commit $(pop_idx 4 $@)
310 66b04f8f 2023-07-19 thomas tog tree -c:head:-5
311 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
313 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
314 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
315 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
319 66b04f8f 2023-07-19 thomas cat <<-EOF >$testroot/view.expected
320 8642913b 2023-07-26 thomas commit $(pop_idx 1 $@)
333 66b04f8f 2023-07-19 thomas tog tree -r "$repo" -cmaster:-99
334 66b04f8f 2023-07-19 thomas cmp -s $testroot/view.expected $testroot/view
336 66b04f8f 2023-07-19 thomas if [ $ret -ne 0 ]; then
337 66b04f8f 2023-07-19 thomas diff -u $testroot/view.expected $testroot/view
338 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
341 66b04f8f 2023-07-19 thomas test_done "$testroot" "$ret"
344 a184c764 2023-04-22 thomas test_parseargs "$@"
345 a184c764 2023-04-22 thomas run_test test_tree_basic
346 a184c764 2023-04-22 thomas run_test test_tree_vsplit_blame
347 a184c764 2023-04-22 thomas run_test test_tree_hsplit_blame
348 94d1a66a 2023-06-25 thomas run_test test_tree_symlink
349 66b04f8f 2023-07-19 thomas run_test test_tree_commit_keywords