Blame


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