From 8feea9a035bea5041151828b99ba7ac557024a6a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 28 Jan 2012 23:29:16 +0100 Subject: [PATCH] test-framework-sh: Fix test failure with AIX 7.1 diff. * tests/init.sh (compare_): Don't use 'diff -u' if it inserts a space in column 1, like 'diff -c' does. * tests/test-init.sh (test_compare): Don't repeat the test from init.sh whether 'diff -u' is used. Instead, test whether the output contains some '@' character. --- ChangeLog | 9 +++++++++ tests/init.sh | 5 ++++- tests/test-init.sh | 19 +++++++++---------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30be2b810..2154aafbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-01-28 Bruno Haible + + test-framework-sh: Fix test failure with AIX 7.1 diff. + * tests/init.sh (compare_): Don't use 'diff -u' if it inserts a space + in column 1, like 'diff -c' does. + * tests/test-init.sh (test_compare): Don't repeat the test from init.sh + whether 'diff -u' is used. Instead, test whether the output contains + some '@' character. + 2012-01-28 Paul Eggert strtoimax: eliminate need for stdint.h, inttypes.h checks diff --git a/tests/init.sh b/tests/init.sh index 5985552ac..ae867144d 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -255,7 +255,10 @@ compare_dev_null_ () return 2 } -if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null`; then +if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null` \ + && diff -u Makefile "$0" 2>/dev/null | grep '^[+]#!' >/dev/null; then + # diff accepts the -u option and does not (like AIX 7 'diff') produce an + # extra space on column 1 of every content line. if test -z "$diff_out_"; then compare_ () { diff -u "$@"; } else diff --git a/tests/test-init.sh b/tests/test-init.sh index c644609fe..a2825cc76 100755 --- a/tests/test-init.sh +++ b/tests/test-init.sh @@ -50,20 +50,19 @@ EOF case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac compare empty in >out 2>err && fail=1 - # Remove the TAB-date suffix on each --- and +++ line, - # for both the expected and the actual output files. - # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ: - # -@@ -0,0 +1 @@ - # +@@ -1,0 +1,1 @@ - cat <<\EOF > exp + # Compare against expected output only if compare is using diff -u. + if grep @ out >/dev/null; then + # Remove the TAB-date suffix on each --- and +++ line, + # for both the expected and the actual output files. + # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ: + # -@@ -0,0 +1 @@ + # +@@ -1,0 +1,1 @@ + sed 's/ .*//;/^@@/d' out > k && mv k out + cat <<\EOF > exp --- empty +++ in +xyz EOF - sed 's/ .*//;/^@@/d' out > k && mv k out - - # Compare against expected output only if compare is using diff -u. - if diff -u out out < /dev/null > /dev/null 2>&1; then compare exp out || fail=1 fi case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac -- 2.11.0