test suite: cross-check got blame results with git blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
diff --git a/regress/cmdline/blame.sh b/regress/cmdline/blame.sh
index ac29d63..c34f767 100755
--- a/regress/cmdline/blame.sh
+++ b/regress/cmdline/blame.sh
@@ -16,6 +16,25 @@
. ./common.sh
+function blame_cmp {
+ local testroot="$1"
+ local file="$2"
+
+ (cd $testroot/wt && got blame "$file" | cut -d ' ' -f 2 \
+ > $testroot/${file}.blame.got)
+ (cd $testroot/repo && git reset --hard master > /dev/null)
+ (cd $testroot/repo && git blame "$file" | cut -d ' ' -f 1 \
+ > $testroot/${file}.blame.git)
+
+ cmp -s $testroot/${file}.blame.git $testroot/${file}.blame.got
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/${file}.blame.git $testroot/${file}.blame.got
+ return 1
+ fi
+ return 0
+}
+
function test_blame_basic {
local testroot=`test_init blame_basic`
@@ -54,8 +73,12 @@ function test_blame_basic {
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+ blame_cmp "$testroot" "alpha"
+ ret="$?"
test_done "$testroot" "$ret"
}
@@ -97,7 +120,12 @@ function test_blame_tag {
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ blame_cmp "$testroot" "alpha"
+ ret="$?"
test_done "$testroot" "$ret"
}
@@ -127,7 +155,12 @@ function test_blame_file_single_line {
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ blame_cmp "$testroot" "alpha"
+ ret="$?"
test_done "$testroot" "$ret"
}
@@ -245,8 +278,12 @@ function test_blame_lines_shifted_up {
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+ blame_cmp "$testroot" "alpha"
+ ret="$?"
test_done "$testroot" "$ret"
}
@@ -311,8 +348,12 @@ function test_blame_lines_shifted_down {
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+ blame_cmp "$testroot" "alpha"
+ ret="$?"
test_done "$testroot" "$ret"
}
@@ -489,6 +530,9 @@ EOF
test_done "$testroot" "$ret"
return 1
fi
+
+ blame_cmp "$testroot" "alpha"
+ ret="$?"
test_done "$testroot" "$ret"
}