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