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_blame_basic()
20 {
21 test_init blame_basic 80 8
23 local commit_id1=`git_show_head $testroot/repo`
25 got checkout $testroot/repo $testroot/wt > /dev/null
26 ret=$?
27 if [ $ret -ne 0 ]; then
28 test_done "$testroot" "$ret"
29 return 1
30 fi
32 echo aaaa >> $testroot/wt/alpha
33 (cd $testroot/wt && got commit -m "a change" > /dev/null)
34 local commit_id2=`git_show_head $testroot/repo`
36 echo bbbb >> $testroot/wt/alpha
37 (cd $testroot/wt && got commit -m "b change" > /dev/null)
38 local commit_id3=`git_show_head $testroot/repo`
40 echo cccc >> $testroot/wt/alpha
41 (cd $testroot/wt && got commit -m "c change" > /dev/null)
42 local commit_id4=`git_show_head $testroot/repo`
43 local author_time=`git_show_author_time $testroot/repo`
44 local ymd=`date -u -r $author_time +"%G-%m-%d"`
46 cat <<EOF >$TOG_TEST_SCRIPT
47 WAIT_FOR_UI wait for blame to finish
48 SCREENDUMP
49 EOF
51 local commit_id1_short=`trim_obj_id 32 $commit_id1`
52 local commit_id2_short=`trim_obj_id 32 $commit_id2`
53 local commit_id3_short=`trim_obj_id 32 $commit_id3`
54 local commit_id4_short=`trim_obj_id 32 $commit_id4`
56 cat <<EOF >$testroot/view.expected
57 commit $commit_id4
58 [1/4] /alpha
59 $commit_id1_short alpha
60 $commit_id2_short aaaa
61 $commit_id3_short bbbb
62 $commit_id4_short cccc
65 EOF
67 cd $testroot/wt && tog blame alpha
68 cmp -s $testroot/view.expected $testroot/view
69 ret=$?
70 if [ $ret -ne 0 ]; then
71 diff -u $testroot/view.expected $testroot/view
72 test_done "$testroot" "$ret"
73 return 1
74 fi
76 test_done "$testroot" "$ret"
77 }
79 test_parseargs "$@"
80 run_test test_blame_basic