Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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 function test_blame_basic {
20 local testroot=`test_init blame_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret="$?"
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
26 return 1
27 fi
29 echo 1 > $testroot/wt/alpha
30 (cd $testroot/wt && got commit -m "change 1" > /dev/null)
31 local commit1=`git_show_head $testroot/repo`
33 echo 2 >> $testroot/wt/alpha
34 (cd $testroot/wt && got commit -m "change 2" > /dev/null)
35 local commit2=`git_show_head $testroot/repo`
37 echo 3 >> $testroot/wt/alpha
38 (cd $testroot/wt && got commit -m "change 3" > /dev/null)
39 local commit3=`git_show_head $testroot/repo`
41 (cd $testroot/wt && got blame alpha > $testroot/stdout)
43 local short_commit1=`trim_obj_id 32 $commit1`
44 local short_commit2=`trim_obj_id 32 $commit2`
45 local short_commit3=`trim_obj_id 32 $commit3`
47 echo "$short_commit1 1" > $testroot/stdout.expected
48 echo "$short_commit2 2" >> $testroot/stdout.expected
49 echo "$short_commit3 3" >> $testroot/stdout.expected
51 cmp -s $testroot/stdout.expected $testroot/stdout
52 ret="$?"
53 if [ "$ret" != "0" ]; then
54 diff -u $testroot/stdout.expected $testroot/stdout
55 fi
57 test_done "$testroot" "$ret"
58 }
60 run_test test_blame_basic