From 3175b0cfc1392de1ff00c01796f85b92df317cc8 Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand" Date: Mon, 17 Dec 2007 23:28:46 +0100 Subject: the use of 'tr' in the test suite isn't really portable Some versions of 'tr' only accept octal codes if entered with three digits, and therefor misinterpret the '\0' in the test suite. Some versions of 'tr' reject the (needless) use of character classes. Signed-off-by: H.Merijn Brand Signed-off-by: Junio C Hamano --- t/diff-lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/diff-lib.sh') diff --git a/t/diff-lib.sh b/t/diff-lib.sh index 4624fe654c..7dc6d7eb1e 100644 --- a/t/diff-lib.sh +++ b/t/diff-lib.sh @@ -21,8 +21,8 @@ compare_diff_raw_z () { # Also we do not check SHA1 hash generation in this test, which # is a job for t0000-basic.sh - tr '\0' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 - tr '\0' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 + tr '\000' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 + tr '\000' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } -- cgit v1.2.3 From e85fe4d85bc7654af20ccf8054ab6922665405e5 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 12 Mar 2008 17:31:06 -0400 Subject: more tr portability test script fixes Dealing with NULs is not always safe with tr. On Solaris, incoming NULs are silently deleted by both the System V and UCB versions of tr. When converting to NULs, the System V version works fine, but the UCB version silently ignores the request to convert the character. This patch changes all instances of tr using NULs to use "perl -pe 'y///'" instead. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/diff-lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/diff-lib.sh') diff --git a/t/diff-lib.sh b/t/diff-lib.sh index 7dc6d7eb1e..28b941c493 100644 --- a/t/diff-lib.sh +++ b/t/diff-lib.sh @@ -21,8 +21,8 @@ compare_diff_raw_z () { # Also we do not check SHA1 hash generation in this test, which # is a job for t0000-basic.sh - tr '\000' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 - tr '\000' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 + perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 + perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } -- cgit v1.2.3 From 3af828634fa5bdbca1b2061a81df8b3fa73b0d34 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 May 2008 22:28:56 -0700 Subject: tests: do not use implicit "git diff --no-index" As a general principle, we should not use "git diff" to validate the results of what git command that is being tested has done. We would not know if we are testing the command in question, or locating a bug in the cute hack of "git diff --no-index". Rather use test_cmp for that purpose. Signed-off-by: Junio C Hamano --- t/diff-lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/diff-lib.sh') diff --git a/t/diff-lib.sh b/t/diff-lib.sh index 28b941c493..4bddeb591e 100644 --- a/t/diff-lib.sh +++ b/t/diff-lib.sh @@ -11,7 +11,7 @@ compare_diff_raw () { sed -e "$sanitize_diff_raw" <"$1" >.tmp-1 sed -e "$sanitize_diff_raw" <"$2" >.tmp-2 - git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 + test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/' @@ -23,7 +23,7 @@ compare_diff_raw_z () { perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 - git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 + test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } compare_diff_patch () { @@ -37,5 +37,5 @@ compare_diff_patch () { /^[dis]*imilarity index [0-9]*%$/d /^index [0-9a-f]*\.\.[0-9a-f]/d ' <"$2" >.tmp-2 - git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 + test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } -- cgit v1.2.3