Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] diff for test harness (was: There seems to be a problem with the test harness on Solaris 11.4)



On 11/7/2022 1:39 PM, Clinton Bunch wrote:
On 11/6/2022 1:32 PM, Clinton Bunch wrote:
On 11/6/2022 1:09 PM, Bart Schaefer wrote:
On Sun, Nov 6, 2022 at 10:35 AM Clinton Bunch <cdb_zsh@xxxxxxxxxxx> wrote:
Solaris 11.4 at least also has GNU diff as gdiff.
Use of "diff -a" hasn't changed since at least 2017.  Is it possible
that there's been a default (or your own) PATH change causing the
POSIX diff to be found in preference?




I'm working on a patch to check if diff supports -a, check if gdiff is in the path.  If both of those fail, do we want to run without -a or abort and kindly suggest they install GNU diff?

Here's a patch that has configure check for an appropriate diff in the path and if it fails to find one runs diff without -a in the test harness

diff --git a/Config/defs.mk.in b/Config/defs.mk.in
index 2bc17482a..c979307f7 100644
--- a/Config/defs.mk.in
+++ b/Config/defs.mk.in
@@ -75,6 +75,7 @@ IMPOPT          = @IMPOPT@
 
 # utilities
 AWK             = @AWK@
+DIFF            = @DIFF@
 ANSI2KNR        = @ANSI2KNR@
 YODL            = @YODL@ @YODL_OPTIONS@
 YODL2TXT        = @YODL@2txt
diff --git a/Test/Makefile.in b/Test/Makefile.in
index 09f37bf53..636746a45 100644
--- a/Test/Makefile.in
+++ b/Test/Makefile.in
@@ -53,6 +53,7 @@ check test:
 	if ZTST_testlist="`for f in $(sdir)/$(TESTNUM)*.ztst; \
            do echo $$f; done`" \
 	 ZTST_srcdir="$(sdir)" \
+	 ZTST_diff_pg="$(DIFF)" \
 	 ZTST_exe=$(dir_top)/Src/zsh@EXEEXT@ \
 	 $(dir_top)/Src/zsh@EXEEXT@ +Z -f $(sdir)/$$ZTST_handler; then \
 	 stat=0; \
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index ea1b016d5..96a138483 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -382,7 +382,7 @@ ZTST_diff() {
       diff_ret=1
     fi
   else
-    diff_out=$(diff -a "$@")
+    diff_out=$(${=ZTST_diff_pg}  "$@")
     diff_ret="$?"
     if [[ "$diff_ret" != "0" ]]; then
       print -r -- "$diff_out"
diff --git a/configure.ac b/configure.ac
index 074141d38..7e9426148 100644
--- a/configure.ac
+++ b/configure.ac
@@ -611,6 +611,19 @@ AC_PROG_AWK                 dnl Check for mawk,gawk,nawk, then awk.
 AC_PROG_LN                  dnl Check for working ln, for "make install"
 AC_PROG_LN_S                dnl Use ln -s/ln/cp for "make install.runhelp"
 AC_PROG_EGREP               dnl sets $EGREP to grep -E or egrep
+
+dnl check for diff that supports -a
+AC_CACHE_CHECK([for diff that supports -a],[ac_cv_path_DIFF],
+    [AC_PATH_PROGS_FEATURE_CHECK([DIFF],[diff gdiff],
+       [[
+	    echo "abcdef" > conftest.$$
+	    echo "abcdef" > conftest2.$$
+	    $ac_path_DIFF -a conftest.$$ conftest2.$$ > /dev/null 2>&1
+	    test "x$?" = x0 \
+            && ac_cv_path_DIFF="$ac_path_DIFF -a" ac_path_DIFF_found=:]],
+	[ac_cv_path_DIFF="diff"])])
+AC_SUBST([DIFF],[$ac_cv_path_DIFF])
+
 AC_CHECK_PROGS([YODL], [yodl], [: yodl])
 
 YODL_OPTIONS=''


Messages sorted by: Reverse Date, Date, Thread, Author