From 613c0ad3a35aa029b28d06771a106c4aa039b5f5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Dec 2024 12:03:22 +0100 Subject: [PATCH] test-framework-sh: Avoid test suite failures on MSYS2. * tests/init.sh (compare_) [MSys]: Use a temporary file on MSYS2. * tests/test-update-copyright.sh: Use the test framework. (compare): Remove function. * modules/update-copyright-tests (Depends-on): Add test-framework-sh. --- ChangeLog | 8 ++++++++ modules/update-copyright-tests | 1 + tests/init.sh | 23 ++++++++++++++++++++++- tests/test-update-copyright.sh | 7 +------ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3406bd39f7..f04dc46a62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-12-22 Bruno Haible + + test-framework-sh: Avoid test suite failures on MSYS2. + * tests/init.sh (compare_) [MSys]: Use a temporary file on MSYS2. + * tests/test-update-copyright.sh: Use the test framework. + (compare): Remove function. + * modules/update-copyright-tests (Depends-on): Add test-framework-sh. + 2024-12-22 Bruno Haible test-framework-sh: Avoid test suite failures on MSYS2. diff --git a/modules/update-copyright-tests b/modules/update-copyright-tests index 3fab6f0689..98a63406fe 100644 --- a/modules/update-copyright-tests +++ b/modules/update-copyright-tests @@ -2,6 +2,7 @@ Files: tests/test-update-copyright.sh Depends-on: +test-framework-sh configure.ac: abs_aux_dir=`cd "$ac_aux_dir"; pwd` diff --git a/tests/init.sh b/tests/init.sh index 80931d7c96..bf3ffc249e 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -671,7 +671,28 @@ for diff_opt_ in -u -U3 -c '' no; do done if test "$diff_opt_" != no; then if test -z "$diff_out_"; then - compare_ () { LC_ALL=C diff $diff_opt_ "$@"; } + # diff on msys2 does not support the '-' argument for denoting stdin. + case `(uname -o) 2>/dev/null` in + Msys) + compare_ () + { + if test " $1" = " -"; then + cat > '(stdin)' + LC_ALL=C diff $diff_opt_ '(stdin)' "$2" + elif test " $2" = " -"; then + cat > '(stdin)' + LC_ALL=C diff $diff_opt_ "$1" '(stdin)' + else + LC_ALL=C diff $diff_opt_ "$@" + fi + } + ;; + *) + compare_ () + { + LC_ALL=C diff $diff_opt_ "$@" + } + esac else compare_ () { diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh index 329b5f7381..a3af0cce0b 100755 --- a/tests/test-update-copyright.sh +++ b/tests/test-update-copyright.sh @@ -16,12 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -diffout=`diff -u /dev/null /dev/null 2>&1` -if test x"$diffout" = x"" && test $? -eq 0; then - compare() { diff -u "$@"; } -else - compare() { cmp "$@"; } -fi +. "${srcdir=.}/init.sh"; path_prepend_ . # Ensure the update-copyright program gets found. PATH=$abs_aux_dir:$PATH -- 2.39.5