]> Savannah Git Hosting - gnulib.git/commitdiff
test-framework-sh: Avoid test suite failures on MSYS2.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Dec 2024 11:03:22 +0000 (12:03 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 25 Dec 2024 14:31:10 +0000 (15:31 +0100)
* 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
modules/update-copyright-tests
tests/init.sh
tests/test-update-copyright.sh

index 5dabbd7f179a19f129d7fa8bf1df03ed3238d523..103417b791cfc3b660f8f351615db9c1e4da99c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-12-22  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        test-framework-sh: Avoid test suite failures on MSYS2.
index 3fab6f068927c6c729a3eec1043b0fdb48411376..98a63406fe1e70ffd6e80b86d3e1c107a57bcb63 100644 (file)
@@ -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`
index 80931d7c96da7710d3fa6cb622821f5eab3cc475..bf3ffc249e44a49bafdcf68d45a634b2e8bb07a2 100644 (file)
@@ -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_ ()
     {
index b2a7f2df8a77641e91eecb227afdb739081572c1..2c32fc1d3df86472956f58a3885b843239e961fd 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-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