>       * tests/init.sh (setup_): Adjust also top_builddir, if set.

Oops, this patch broke the GNU gettext tests. Basically, top_builddir needs
to be set appropriately in the TESTS_ENVIRONMENT in the Makefile.
Attempting to modify it in setup_() does not work when it comes to
variables like LIBINTL and LTLIBINTL.


2025-08-04  Bruno Haible  <[email protected]>

        nlcanon tests: Fix last commit.
        * tests/init.sh (setup_): Revert last change.
        * modules/test-framework-sh (Makefile.am): Augment TESTS_ENVIRONMENT
        here.
        * modules/nlcanon-tests (Makefile.am): Don't augment TESTS_ENVIRONMENT
        here.

diff --git a/modules/nlcanon-tests b/modules/nlcanon-tests
index bfcecda38e..23a733e628 100644
--- a/modules/nlcanon-tests
+++ b/modules/nlcanon-tests
@@ -6,5 +6,3 @@ test-framework-sh
 
 Makefile.am:
 TESTS += test-nlcanon.sh
-TESTS_ENVIRONMENT += \
-  top_builddir='@top_builddir@'
diff --git a/modules/test-framework-sh b/modules/test-framework-sh
index 249f426608..2a10d461ff 100644
--- a/modules/test-framework-sh
+++ b/modules/test-framework-sh
@@ -9,6 +9,12 @@ Depends-on:
 configure.ac:
 
 Makefile.am:
+# The value of top_builddir, determined by Autoconf and stored in the Makefile,
+# consists of n times '..', where n is the depth of the $(srcdir) under
+# $(top_srcdir). Here we need one more '..', because the test framework
+# (init.sh) arranges to run the tests in a subdirectory of depth 1 under the
+# directory where the Makefile sits.
+TESTS_ENVIRONMENT += top_builddir='../@top_builddir@'
 
 Include:
 
diff --git a/tests/init.sh b/tests/init.sh
index d3ce11dbee..d695020545 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -428,21 +428,13 @@ setup_ ()
   test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
     || fail_ "failed to create temporary directory in $initial_cwd_"
   cd "$test_dir_" || fail_ "failed to cd to temporary directory"
-  # Set variables srcdir, builddir, and optionally top_builddir,
-  # for the convenience of the test.
+  # Set variables srcdir, builddir, for the convenience of the test.
   case $srcdir in
     /* | ?:*) ;;
     *) srcdir="../$srcdir" ;;
   esac
   builddir=".."
   export srcdir builddir
-  if test -n "$top_builddir"; then
-    case $top_builddir in
-      /* | ?:*) ;;
-      *) top_builddir="../$top_builddir" ;;
-    esac
-    export top_builddir
-  fi
 
   # As autoconf-generated configure scripts do, ensure that IFS
   # is defined initially, so that saving and restoring $IFS works.




Reply via email to