Blame


1 c970ea82 2019-07-27 stsp #!/bin/sh
2 c970ea82 2019-07-27 stsp #
3 c970ea82 2019-07-27 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c970ea82 2019-07-27 stsp #
5 c970ea82 2019-07-27 stsp # Permission to use, copy, modify, and distribute this software for any
6 c970ea82 2019-07-27 stsp # purpose with or without fee is hereby granted, provided that the above
7 c970ea82 2019-07-27 stsp # copyright notice and this permission notice appear in all copies.
8 c970ea82 2019-07-27 stsp #
9 c970ea82 2019-07-27 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c970ea82 2019-07-27 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c970ea82 2019-07-27 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c970ea82 2019-07-27 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c970ea82 2019-07-27 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c970ea82 2019-07-27 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c970ea82 2019-07-27 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 c970ea82 2019-07-27 stsp
17 c970ea82 2019-07-27 stsp . ./common.sh
18 c970ea82 2019-07-27 stsp
19 c970ea82 2019-07-27 stsp function test_blame_basic {
20 c970ea82 2019-07-27 stsp local testroot=`test_init blame_basic`
21 c970ea82 2019-07-27 stsp
22 c970ea82 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 c970ea82 2019-07-27 stsp ret="$?"
24 c970ea82 2019-07-27 stsp if [ "$ret" != "0" ]; then
25 c970ea82 2019-07-27 stsp test_done "$testroot" "$ret"
26 c970ea82 2019-07-27 stsp return 1
27 c970ea82 2019-07-27 stsp fi
28 c970ea82 2019-07-27 stsp
29 c970ea82 2019-07-27 stsp echo 1 > $testroot/wt/alpha
30 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
31 c970ea82 2019-07-27 stsp local commit1=`git_show_head $testroot/repo`
32 c970ea82 2019-07-27 stsp
33 c970ea82 2019-07-27 stsp echo 2 >> $testroot/wt/alpha
34 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
35 c970ea82 2019-07-27 stsp local commit2=`git_show_head $testroot/repo`
36 c970ea82 2019-07-27 stsp
37 c970ea82 2019-07-27 stsp echo 3 >> $testroot/wt/alpha
38 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
39 c970ea82 2019-07-27 stsp local commit3=`git_show_head $testroot/repo`
40 c970ea82 2019-07-27 stsp
41 c970ea82 2019-07-27 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
42 c970ea82 2019-07-27 stsp
43 c970ea82 2019-07-27 stsp local short_commit1=`trim_obj_id 32 $commit1`
44 c970ea82 2019-07-27 stsp local short_commit2=`trim_obj_id 32 $commit2`
45 c970ea82 2019-07-27 stsp local short_commit3=`trim_obj_id 32 $commit3`
46 c970ea82 2019-07-27 stsp
47 c970ea82 2019-07-27 stsp echo "$short_commit1 1" > $testroot/stdout.expected
48 c970ea82 2019-07-27 stsp echo "$short_commit2 2" >> $testroot/stdout.expected
49 c970ea82 2019-07-27 stsp echo "$short_commit3 3" >> $testroot/stdout.expected
50 c970ea82 2019-07-27 stsp
51 c970ea82 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
52 c970ea82 2019-07-27 stsp ret="$?"
53 c970ea82 2019-07-27 stsp if [ "$ret" != "0" ]; then
54 c970ea82 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
55 c970ea82 2019-07-27 stsp fi
56 c970ea82 2019-07-27 stsp
57 c970ea82 2019-07-27 stsp test_done "$testroot" "$ret"
58 c970ea82 2019-07-27 stsp }
59 c970ea82 2019-07-27 stsp
60 c970ea82 2019-07-27 stsp run_test test_blame_basic