Blame


1 8e778ade 2023-04-22 thomas #!/bin/sh
2 8e778ade 2023-04-22 thomas #
3 8e778ade 2023-04-22 thomas # Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
4 8e778ade 2023-04-22 thomas #
5 8e778ade 2023-04-22 thomas # Permission to use, copy, modify, and distribute this software for any
6 8e778ade 2023-04-22 thomas # purpose with or without fee is hereby granted, provided that the above
7 8e778ade 2023-04-22 thomas # copyright notice and this permission notice appear in all copies.
8 8e778ade 2023-04-22 thomas #
9 8e778ade 2023-04-22 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 8e778ade 2023-04-22 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 8e778ade 2023-04-22 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 8e778ade 2023-04-22 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 8e778ade 2023-04-22 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 8e778ade 2023-04-22 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 8e778ade 2023-04-22 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 8e778ade 2023-04-22 thomas
17 8e778ade 2023-04-22 thomas . ./common.sh
18 8e778ade 2023-04-22 thomas
19 8e778ade 2023-04-22 thomas test_blame_basic()
20 8e778ade 2023-04-22 thomas {
21 8e778ade 2023-04-22 thomas test_init blame_basic 80 8
22 8e778ade 2023-04-22 thomas
23 8e778ade 2023-04-22 thomas local commit_id1=`git_show_head $testroot/repo`
24 8e778ade 2023-04-22 thomas
25 8e778ade 2023-04-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
26 8e778ade 2023-04-22 thomas ret=$?
27 8e778ade 2023-04-22 thomas if [ $ret -ne 0 ]; then
28 8e778ade 2023-04-22 thomas test_done "$testroot" "$ret"
29 8e778ade 2023-04-22 thomas return 1
30 8e778ade 2023-04-22 thomas fi
31 8e778ade 2023-04-22 thomas
32 8e778ade 2023-04-22 thomas echo aaaa >> $testroot/wt/alpha
33 8e778ade 2023-04-22 thomas (cd $testroot/wt && got commit -m "a change" > /dev/null)
34 8e778ade 2023-04-22 thomas local commit_id2=`git_show_head $testroot/repo`
35 8e778ade 2023-04-22 thomas
36 8e778ade 2023-04-22 thomas echo bbbb >> $testroot/wt/alpha
37 8e778ade 2023-04-22 thomas (cd $testroot/wt && got commit -m "b change" > /dev/null)
38 8e778ade 2023-04-22 thomas local commit_id3=`git_show_head $testroot/repo`
39 8e778ade 2023-04-22 thomas
40 8e778ade 2023-04-22 thomas echo cccc >> $testroot/wt/alpha
41 8e778ade 2023-04-22 thomas (cd $testroot/wt && got commit -m "c change" > /dev/null)
42 8e778ade 2023-04-22 thomas local commit_id4=`git_show_head $testroot/repo`
43 8e778ade 2023-04-22 thomas local author_time=`git_show_author_time $testroot/repo`
44 8e778ade 2023-04-22 thomas local ymd=`date -u -r $author_time +"%G-%m-%d"`
45 8e778ade 2023-04-22 thomas
46 8e778ade 2023-04-22 thomas cat <<EOF >$TOG_TEST_SCRIPT
47 8e778ade 2023-04-22 thomas WAIT_FOR_UI wait for blame to finish
48 8e778ade 2023-04-22 thomas SCREENDUMP
49 8e778ade 2023-04-22 thomas EOF
50 8e778ade 2023-04-22 thomas
51 8e778ade 2023-04-22 thomas local commit_id1_short=`trim_obj_id 32 $commit_id1`
52 8e778ade 2023-04-22 thomas local commit_id2_short=`trim_obj_id 32 $commit_id2`
53 8e778ade 2023-04-22 thomas local commit_id3_short=`trim_obj_id 32 $commit_id3`
54 8e778ade 2023-04-22 thomas local commit_id4_short=`trim_obj_id 32 $commit_id4`
55 8e778ade 2023-04-22 thomas
56 8e778ade 2023-04-22 thomas cat <<EOF >$testroot/view.expected
57 8e778ade 2023-04-22 thomas commit $commit_id4
58 8e778ade 2023-04-22 thomas [1/4] /alpha
59 8e778ade 2023-04-22 thomas $commit_id1_short alpha
60 8e778ade 2023-04-22 thomas $commit_id2_short aaaa
61 8e778ade 2023-04-22 thomas $commit_id3_short bbbb
62 8e778ade 2023-04-22 thomas $commit_id4_short cccc
63 8e778ade 2023-04-22 thomas
64 8e778ade 2023-04-22 thomas
65 8e778ade 2023-04-22 thomas EOF
66 8e778ade 2023-04-22 thomas
67 8e778ade 2023-04-22 thomas cd $testroot/wt && tog blame alpha
68 8e778ade 2023-04-22 thomas cmp -s $testroot/view.expected $testroot/view
69 8e778ade 2023-04-22 thomas ret=$?
70 8e778ade 2023-04-22 thomas if [ $ret -ne 0 ]; then
71 8e778ade 2023-04-22 thomas diff -u $testroot/view.expected $testroot/view
72 8e778ade 2023-04-22 thomas test_done "$testroot" "$ret"
73 8e778ade 2023-04-22 thomas return 1
74 8e778ade 2023-04-22 thomas fi
75 8e778ade 2023-04-22 thomas
76 8e778ade 2023-04-22 thomas test_done "$testroot" "$ret"
77 8e778ade 2023-04-22 thomas }
78 8e778ade 2023-04-22 thomas
79 8e778ade 2023-04-22 thomas test_parseargs "$@"
80 8e778ade 2023-04-22 thomas run_test test_blame_basic