]> 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 13:47:41 +0000 (14:47 +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 3406bd39f7a091ccddeb12ce103b9cbf7bd02477..f04dc46a62def5ba501aa4c31bde3a20953637d6 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 329b5f7381408cdd7f24e4e94c92330618c699fd..a3af0cce0b7a3516d98a3b0483d9a92125782a68 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