Blame


1 a184c764 2023-04-22 thomas #!/bin/sh
2 a184c764 2023-04-22 thomas #
3 a184c764 2023-04-22 thomas # Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
4 a184c764 2023-04-22 thomas #
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.
8 a184c764 2023-04-22 thomas #
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.
16 a184c764 2023-04-22 thomas
17 a184c764 2023-04-22 thomas . ./common.sh
18 a184c764 2023-04-22 thomas
19 a184c764 2023-04-22 thomas test_tree_basic()
20 a184c764 2023-04-22 thomas {
21 a184c764 2023-04-22 thomas test_init tree_basic 48 8
22 a184c764 2023-04-22 thomas
23 a184c764 2023-04-22 thomas local head_id=`git_show_head $testroot/repo`
24 a184c764 2023-04-22 thomas
25 a184c764 2023-04-22 thomas cat <<EOF >$TOG_TEST_SCRIPT
26 a184c764 2023-04-22 thomas SCREENDUMP
27 a184c764 2023-04-22 thomas EOF
28 a184c764 2023-04-22 thomas
29 a184c764 2023-04-22 thomas cat <<EOF >$testroot/view.expected
30 a184c764 2023-04-22 thomas commit $head_id
31 a184c764 2023-04-22 thomas [1/4] /
32 a184c764 2023-04-22 thomas
33 a184c764 2023-04-22 thomas alpha
34 a184c764 2023-04-22 thomas beta
35 a184c764 2023-04-22 thomas epsilon/
36 a184c764 2023-04-22 thomas gamma/
37 a184c764 2023-04-22 thomas
38 a184c764 2023-04-22 thomas EOF
39 a184c764 2023-04-22 thomas
40 a184c764 2023-04-22 thomas cd $testroot/repo && tog tree
41 a184c764 2023-04-22 thomas cmp -s $testroot/view.expected $testroot/view
42 a184c764 2023-04-22 thomas ret=$?
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"
46 a184c764 2023-04-22 thomas return 1
47 a184c764 2023-04-22 thomas fi
48 a184c764 2023-04-22 thomas
49 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
50 a184c764 2023-04-22 thomas }
51 a184c764 2023-04-22 thomas
52 a184c764 2023-04-22 thomas test_tree_vsplit_blame()
53 a184c764 2023-04-22 thomas {
54 a184c764 2023-04-22 thomas test_init tree_vsplit_blame 120 8
55 a184c764 2023-04-22 thomas
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`
59 a184c764 2023-04-22 thomas
60 a184c764 2023-04-22 thomas cat <<EOF >$TOG_TEST_SCRIPT
61 a184c764 2023-04-22 thomas KEY_ENTER
62 a184c764 2023-04-22 thomas WAIT_FOR_UI wait for blame to finish
63 a184c764 2023-04-22 thomas SCREENDUMP
64 a184c764 2023-04-22 thomas EOF
65 a184c764 2023-04-22 thomas
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
70 a184c764 2023-04-22 thomas alpha |
71 a184c764 2023-04-22 thomas beta |
72 a184c764 2023-04-22 thomas epsilon/ |
73 a184c764 2023-04-22 thomas gamma/ |
74 a184c764 2023-04-22 thomas |
75 a184c764 2023-04-22 thomas EOF
76 a184c764 2023-04-22 thomas
77 a184c764 2023-04-22 thomas cd $testroot/repo && tog tree
78 a184c764 2023-04-22 thomas cmp -s $testroot/view.expected $testroot/view
79 a184c764 2023-04-22 thomas ret=$?
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"
83 a184c764 2023-04-22 thomas return 1
84 a184c764 2023-04-22 thomas fi
85 a184c764 2023-04-22 thomas
86 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
87 a184c764 2023-04-22 thomas }
88 a184c764 2023-04-22 thomas
89 a184c764 2023-04-22 thomas test_tree_hsplit_blame()
90 a184c764 2023-04-22 thomas {
91 a184c764 2023-04-22 thomas test_init tree_hsplit_blame 48 24
92 a184c764 2023-04-22 thomas
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`
96 a184c764 2023-04-22 thomas
97 a184c764 2023-04-22 thomas cat <<EOF >$TOG_TEST_SCRIPT
98 a184c764 2023-04-22 thomas j
99 a184c764 2023-04-22 thomas KEY_ENTER
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
104 a184c764 2023-04-22 thomas EOF
105 a184c764 2023-04-22 thomas
106 a184c764 2023-04-22 thomas cat <<EOF >$testroot/view.expected
107 a184c764 2023-04-22 thomas commit $head_id
108 a184c764 2023-04-22 thomas [2/4] /
109 a184c764 2023-04-22 thomas
110 a184c764 2023-04-22 thomas alpha
111 a184c764 2023-04-22 thomas beta
112 a184c764 2023-04-22 thomas epsilon/
113 a184c764 2023-04-22 thomas gamma/
114 a184c764 2023-04-22 thomas
115 a184c764 2023-04-22 thomas
116 a184c764 2023-04-22 thomas
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
121 a184c764 2023-04-22 thomas
122 a184c764 2023-04-22 thomas
123 a184c764 2023-04-22 thomas
124 a184c764 2023-04-22 thomas
125 a184c764 2023-04-22 thomas
126 a184c764 2023-04-22 thomas
127 a184c764 2023-04-22 thomas
128 a184c764 2023-04-22 thomas
129 a184c764 2023-04-22 thomas
130 a184c764 2023-04-22 thomas
131 a184c764 2023-04-22 thomas EOF
132 a184c764 2023-04-22 thomas
133 a184c764 2023-04-22 thomas cd $testroot/repo && tog tree
134 a184c764 2023-04-22 thomas cmp -s $testroot/view.expected $testroot/view
135 a184c764 2023-04-22 thomas ret=$?
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"
139 a184c764 2023-04-22 thomas return 1
140 a184c764 2023-04-22 thomas fi
141 a184c764 2023-04-22 thomas
142 a184c764 2023-04-22 thomas test_done "$testroot" "$ret"
143 a184c764 2023-04-22 thomas }
144 a184c764 2023-04-22 thomas
145 94d1a66a 2023-06-25 thomas test_tree_symlink()
146 94d1a66a 2023-06-25 thomas {
147 94d1a66a 2023-06-25 thomas test_init tree_symlink 48 8
148 94d1a66a 2023-06-25 thomas
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`
153 94d1a66a 2023-06-25 thomas
154 94d1a66a 2023-06-25 thomas cat <<EOF >$TOG_TEST_SCRIPT
155 94d1a66a 2023-06-25 thomas SCREENDUMP
156 94d1a66a 2023-06-25 thomas EOF
157 94d1a66a 2023-06-25 thomas
158 94d1a66a 2023-06-25 thomas cat <<EOF >$testroot/view.expected
159 94d1a66a 2023-06-25 thomas commit $head_id
160 94d1a66a 2023-06-25 thomas [1/5] /
161 94d1a66a 2023-06-25 thomas
162 94d1a66a 2023-06-25 thomas alpha
163 94d1a66a 2023-06-25 thomas beta
164 94d1a66a 2023-06-25 thomas epsilon/
165 94d1a66a 2023-06-25 thomas gamma/
166 94d1a66a 2023-06-25 thomas symlink@ -> alpha
167 94d1a66a 2023-06-25 thomas EOF
168 94d1a66a 2023-06-25 thomas
169 94d1a66a 2023-06-25 thomas cd $testroot/repo && tog tree
170 94d1a66a 2023-06-25 thomas cmp -s $testroot/view.expected $testroot/view
171 94d1a66a 2023-06-25 thomas ret=$?
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"
175 94d1a66a 2023-06-25 thomas return 1
176 94d1a66a 2023-06-25 thomas fi
177 94d1a66a 2023-06-25 thomas
178 94d1a66a 2023-06-25 thomas test_done "$testroot" "$ret"
179 94d1a66a 2023-06-25 thomas }
180 94d1a66a 2023-06-25 thomas
181 a184c764 2023-04-22 thomas test_parseargs "$@"
182 a184c764 2023-04-22 thomas run_test test_tree_basic
183 a184c764 2023-04-22 thomas run_test test_tree_vsplit_blame
184 a184c764 2023-04-22 thomas run_test test_tree_hsplit_blame
185 94d1a66a 2023-06-25 thomas run_test test_tree_symlink