Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
4 #
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.
8 #
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 . ./common.sh
19 test_tree_basic()
20 {
21 test_init tree_basic 48 8
23 local head_id=`git_show_head $testroot/repo`
25 cat <<EOF >$TOG_TEST_SCRIPT
26 SCREENDUMP
27 EOF
29 cat <<EOF >$testroot/view.expected
30 commit $head_id
31 [1/4] /
33 alpha
34 beta
35 epsilon/
36 gamma/
38 EOF
40 cd $testroot/repo && tog tree
41 cmp -s $testroot/view.expected $testroot/view
42 ret=$?
43 if [ $ret -ne 0 ]; then
44 diff -u $testroot/view.expected $testroot/view
45 test_done "$testroot" "$ret"
46 return 1
47 fi
49 test_done "$testroot" "$ret"
50 }
52 test_tree_vsplit_blame()
53 {
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
61 KEY_ENTER
62 WAIT_FOR_UI wait for blame to finish
63 SCREENDUMP
64 EOF
66 cat <<EOF >$testroot/view.expected
67 commit $head_id_truncated|commit $head_id
68 [1/4] / |[1/1] /alpha
69 |$head_id_short alpha
70 alpha |
71 beta |
72 epsilon/ |
73 gamma/ |
74 |
75 EOF
77 cd $testroot/repo && tog tree
78 cmp -s $testroot/view.expected $testroot/view
79 ret=$?
80 if [ $ret -ne 0 ]; then
81 diff -u $testroot/view.expected $testroot/view
82 test_done "$testroot" "$ret"
83 return 1
84 fi
86 test_done "$testroot" "$ret"
87 }
89 test_tree_hsplit_blame()
90 {
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
98 j
99 KEY_ENTER
100 S toggle horizontal split
101 4- 4x decrease blame split
102 WAIT_FOR_UI wait for blame to finish
103 SCREENDUMP
104 EOF
106 cat <<EOF >$testroot/view.expected
107 commit $head_id
108 [2/4] /
110 alpha
111 beta
112 epsilon/
113 gamma/
117 ------------------------------------------------
118 commit $head_id
119 [1/1] /beta
120 $head_id_short beta
131 EOF
133 cd $testroot/repo && tog tree
134 cmp -s $testroot/view.expected $testroot/view
135 ret=$?
136 if [ $ret -ne 0 ]; then
137 diff -u $testroot/view.expected $testroot/view
138 test_done "$testroot" "$ret"
139 return 1
140 fi
142 test_done "$testroot" "$ret"
145 test_parseargs "$@"
146 run_test test_tree_basic
147 run_test test_tree_vsplit_blame
148 run_test test_tree_hsplit_blame