Skip to content

Commit 152cb0c

Browse files
committed
Merge branch 'sg/test-cmp-rev'
Test framework update. * sg/test-cmp-rev: test-lib-functions: make 'test_cmp_rev' more informative on failure
2 parents 2c23f0b + 30d0b6d commit 152cb0c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

t/test-lib-functions.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,23 @@ test_must_be_empty () {
854854

855855
# Tests that its two parameters refer to the same revision
856856
test_cmp_rev () {
857-
git rev-parse --verify "$1" >expect.rev &&
858-
git rev-parse --verify "$2" >actual.rev &&
859-
test_cmp expect.rev actual.rev
857+
if test $# != 2
858+
then
859+
error "bug in the test script: test_cmp_rev requires two revisions, but got $#"
860+
else
861+
local r1 r2
862+
r1=$(git rev-parse --verify "$1") &&
863+
r2=$(git rev-parse --verify "$2") &&
864+
if test "$r1" != "$r2"
865+
then
866+
cat >&4 <<-EOF
867+
error: two revisions point to different objects:
868+
'$1': $r1
869+
'$2': $r2
870+
EOF
871+
return 1
872+
fi
873+
fi
860874
}
861875

862876
# Print a sequence of integers in increasing order, either with

0 commit comments

Comments
 (0)