These two patches add the notice banners when running 'make all' and
'make check'. I'm hoping to get around to implementing the
substitutions needed for header files soon. Until then this can be
used to build a package that will configure for testing:

gnulib-tool.py --create-testdir --dir test-python readme-release
gnulib-tool --create-testdir --dir test-shell readme-release
git diff --no-index test-python/gltests/Makefile.am 
test-shell/gltests/Makefile.am

Then you can do:

cd test-python
./configure
make all
make check

To see if all the banners print correctly. The library is just the
dummy module and the tests are vc-list-files.

Collin
From 1ec490bdc80f64d63ce7177114fcecfc50d460db Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 5 Mar 2024 23:47:08 -0800
Subject: [PATCH 3/4] gnulib-tool.py: Follow gnulib-tool changes, part 43.

Follow gnulib-tool change
2021-06-10  Bruno Haible  <br...@clisp.org>
Clarify that compiler warnings in the Gnulib tests can be ignored.

* pygnulib/GLEmiter.py (GLEmiter.initmacro_start): Add boolean argument
to control whether gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS should
be required.
(GLEmiter.tests_Makefile_am): Emit overrides for CFLAGS and CXXFLAGS.
Emit a dependency of 'all' on 'all-notice' that prints a warning that
compiler warnings can be ignored for tests.
* pygnulib/GLImport.py (GLImport.gnulib_comp): Add boolean argument to
tell whether a tests Makefile.am is being emitted. Update calls to
GLEmiter.initmacro_start.
(GLImport.execute): Update calls to GLEmiter.initmacro_start.
* pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
---
 ChangeLog             | 18 +++++++++++++++++
 gnulib-tool.py.TODO   | 17 ----------------
 pygnulib/GLEmiter.py  | 46 +++++++++++++++++++++++++++++++++++++++----
 pygnulib/GLImport.py  | 14 ++++++++-----
 pygnulib/GLTestDir.py |  6 +++---
 5 files changed, 72 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cfba30ce3e..53234e7de6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2024-03-05  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 43.
+	Follow gnulib-tool change
+	2021-06-10  Bruno Haible  <br...@clisp.org>
+	Clarify that compiler warnings in the Gnulib tests can be ignored.
+	* pygnulib/GLEmiter.py (GLEmiter.initmacro_start): Add boolean argument
+	to control whether gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS should
+	be required.
+	(GLEmiter.tests_Makefile_am): Emit overrides for CFLAGS and CXXFLAGS.
+	Emit a dependency of 'all' on 'all-notice' that prints a warning that
+	compiler warnings can be ignored for tests.
+	* pygnulib/GLImport.py (GLImport.gnulib_comp): Add boolean argument to
+	tell whether a tests Makefile.am is being emitted. Update calls to
+	GLEmiter.initmacro_start.
+	(GLImport.execute): Update calls to GLEmiter.initmacro_start.
+	* pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
+
 2024-03-05  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Fix gnulib-cache.m4 output.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 42728ed60d..a15bfc948a 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -551,23 +551,6 @@ Date:   Thu Jun 10 21:43:59 2021 +0200
 
 --------------------------------------------------------------------------------
 
-commit 16c3e1868a15a5946c0f0f7df6e107e9b3c6389d
-Author: Bruno Haible <br...@clisp.org>
-Date:   Thu Jun 10 21:26:53 2021 +0200
-
-    Clarify that compiler warnings in the Gnulib tests can be ignored.
-
-    * gnulib-tool (func_emit_tests_Makefile_am): Emit overrides for CFLAGS
-    and CXXFLAGS. Emit a dependency of 'all' on 'all-notice' that prints a
-    notice.
-    (func_emit_initmacro_start): Add a second argument. If it is true, emit
-    code to require gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS.
-    (func_import, func_create_testdir): All callers updated.
-    * m4/gnulib-common.m4 (gl_CC_ALLOW_WARNINGS, gl_CXX_ALLOW_WARNINGS): New
-    macros.
-
---------------------------------------------------------------------------------
-
 commit 4b071c115309079528db7b60e8d2ffb22b129088
 Author: Paul Eggert <egg...@cs.ucla.edu>
 Date:   Mon Apr 26 23:31:29 2021 -0700
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index ee963e69d7..1d1463851b 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -457,13 +457,20 @@ USE_MSGCTXT = no\n"""
                 emit += '%s\n' % constants.substart('lib/', sourcebase, file)
         return emit
 
-    def initmacro_start(self, macro_prefix_arg):
-        '''GLEmiter.initmacro_start(macro_prefix_arg) -> str
+    def initmacro_start(self, macro_prefix_arg, gentests):
+        '''GLEmiter.initmacro_start(macro_prefix_arg, gentests) -> str
 
-        Emit the first few statements of the gl_INIT macro.'''
+        Emit the first few statements of the gl_INIT macro.
+
+        macro_prefix_arg is the prefix of gl_EARLY and gl_INIT macros to use.
+        gentests is True if a tests Makefile.am is being generated, False
+          otherwise.'''
         if type(macro_prefix_arg) is not str:
             raise TypeError('macro_prefix_arg must be a string, not %s'
                             % type(macro_prefix_arg).__name__)
+        if type(gentests) is not bool:
+            raise TypeError('gentests must be a bool, not %s'
+                            % type(gentests).__name__)
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
         emit = ''
         # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
@@ -495,6 +502,9 @@ USE_MSGCTXT = no\n"""
         # Scope the GNULIB_<modulename> variables.
         emit += "  m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [%s])\n" % module_indicator_prefix
         emit += "  gl_COMMON\n"
+        if gentests:
+            emit += '  AC_REQUIRE([gl_CC_ALLOW_WARNINGS])\n'
+            emit += '  AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])\n'
         return emit
 
     def initmacro_end(self, macro_prefix_arg):
@@ -1112,7 +1122,27 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                     emit += '%s += %s\n' % (dictionary['var'], val)
                     dictionary.pop('var')
 
-        emit += '\nAM_CPPFLAGS = \\\n'
+        # Insert a '-Wno-error' option in the compilation commands emitted by
+        # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
+        # Why?
+        # 1) Because parts of the Gnulib tests exercise corner cases (invalid
+        #    arguments, endless recursions, etc.) that a compiler may warn about,
+        #    even with just the normal '-Wall' option.
+        # 2) Because every package maintainer has their preferred set of warnings
+        #    that they may want to enforce in the main source code of their package.
+        #    But Gnulib tests are maintained in Gnulib and don't end up in binaries
+        #    that that package installs; therefore it does not make sense for
+        #    package maintainers to enforce the absence of warnings on these tests.
+        # Why before @CFLAGS@?
+        # - Because "the user is always right": If a user adds '-Werror' to their
+        #   CFLAGS, they have asked for errors, they will get errors. But they have
+        #   no right to complain about these errors, because Gnulib does not support
+        #   '-Werror'.
+        emit += '\n'
+        emit += 'CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@ @CFLAGS@\n'
+        emit += 'CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@\n'
+        emit += '\n'
+        emit += 'AM_CPPFLAGS = \\\n'
         if for_test:
             emit += '  -DGNULIB_STRICT_CHECKING=1 \\\n'
         if witness_c_macro:
@@ -1160,6 +1190,14 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         all_snippets = all_snippets.replace('$(top_srcdir)/build-aux/',
                                             '$(top_srcdir)/%s/' % auxdir)
         emit += all_snippets
+        # Arrange to print a message before compiling the files in this directory.
+        emit += 'all: all-notice\n'
+        emit += 'all-notice:\n'
+        emit += '\t@echo \'## ---------------------------------------------------- ##\'\n'
+        emit += '\t@echo \'## ------------------- Gnulib tests ------------------- ##\'\n'
+        emit += '\t@echo \'## You can ignore compiler warnings in this directory.  ##\'\n'
+        emit += '\t@echo \'## ---------------------------------------------------- ##\'\n'
+        emit += '\n'
         emit += '# Clean up after Solaris cc.\n'
         emit += 'clean-local:\n'
         emit += '\trm -rf SunWS_cache\n\n'
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index a3623a9da1..5ffeaf26dc 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -555,12 +555,16 @@ class GLImport(object):
             emit += 'gl_VC_FILES([%s])\n' % vc_files
         return constants.nlconvert(emit)
 
-    def gnulib_comp(self, files):
+    def gnulib_comp(self, files, gentests):
         '''GLImport.gnulib_comp(files) -> str
 
         Emit the contents of generated $m4base/gnulib-comp.m4 file.
         GLConfig: destdir, localpath, tests, sourcebase, m4base, pobase, docbase,
-        testsbase, conddeps, libtool, macro_prefix, podomain, vc_files.'''
+        testsbase, conddeps, libtool, macro_prefix, podomain, vc_files.
+
+        files is the list of files to use.
+        gentests is True if a tests Makefile.am is being generated, False
+          otherwise.'''
         emit = ''
         assistant = self.assistant
         moduletable = self.moduletable
@@ -641,7 +645,7 @@ AC_DEFUN([%s_INIT],
         if auxdir != 'build-aux':
             replace_auxdir = True
         emit += '  gl_m4_base=\'%s\'\n' % m4base
-        emit += self.emitter.initmacro_start(macro_prefix)
+        emit += self.emitter.initmacro_start(macro_prefix, False)
         emit += '  gl_source_base=\'%s\'\n' % sourcebase
         if witness_c_macro:
             emit += '  m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [%s])\n' % witness_c_macro
@@ -654,7 +658,7 @@ AC_DEFUN([%s_INIT],
         emit += self.emitter.initmacro_end(macro_prefix)
         emit += '  gltests_libdeps=\n'
         emit += '  gltests_ltlibdeps=\n'
-        emit += self.emitter.initmacro_start('%stests' % macro_prefix)
+        emit += self.emitter.initmacro_start('%stests' % macro_prefix, gentests)
         emit += '  gl_source_base=\'%s\'\n' % testsbase
         # Define a tests witness macro that depends on the package.
         # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by
@@ -1260,7 +1264,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         # Create m4/gnulib-comp.m4.
         basename = joinpath(m4base, 'gnulib-comp.m4')
         tmpfile = self.assistant.tmpfilename(basename)
-        emit = self.gnulib_comp(filetable['all'])
+        emit = self.gnulib_comp(filetable['all'], gentests)
         with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
             file.write(emit)
         filename, backup, flag = self.assistant.super_update(basename, tmpfile)
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 5f290c30c3..296356bd91 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -465,7 +465,7 @@ class GLTestDir(object):
                 emit += 'AC_DEFUN([gl_INIT], [\n'
                 replace_auxdir = True
                 emit += "gl_m4_base='../%s'\n" % m4base
-                emit += self.emitter.initmacro_start(macro_prefix)
+                emit += self.emitter.initmacro_start(macro_prefix, True)
                 # We don't have explicit ordering constraints between the various
                 # autoconf snippets. It's cleanest to put those of the library before
                 # those of the tests.
@@ -585,7 +585,7 @@ class GLTestDir(object):
         else:  # auxdir == 'build-aux'
             replace_auxdir = False
         emit += 'gl_m4_base=\'%s\'\n' % m4base
-        emit += self.emitter.initmacro_start(macro_prefix)
+        emit += self.emitter.initmacro_start(macro_prefix, False)
         emit += 'gl_source_base=\'%s\'\n' % sourcebase
         if single_configure:
             emit += self.emitter.autoconfSnippets(main_modules, main_modules, moduletable,
@@ -597,7 +597,7 @@ class GLTestDir(object):
         if single_configure:
             emit += '  gltests_libdeps=\n'
             emit += '  gltests_ltlibdeps=\n'
-            emit += self.emitter.initmacro_start('%stests' % macro_prefix)
+            emit += self.emitter.initmacro_start('%stests' % macro_prefix, True)
             emit += '  gl_source_base=\'%s\'\n' % testsbase
             # Define a tests witness macro.
             emit += '  %stests_WITNESS=IN_GNULIB_TESTS\n' % macro_prefix
-- 
2.44.0

From 8661bf5da0c9cfad0f4b7a729d6cbdaf308cf2d4 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Wed, 6 Mar 2024 00:09:20 -0800
Subject: [PATCH 4/4] gnulib-tool.py: Follow gnulib-tool changes, part 44.

Follow gnulib-tool changes
2021-06-10  Bruno Haible  <br...@clisp.org>
Clarify where to report test failures from Gnulib tests.
2021-06-11  Bruno Haible  <br...@clisp.org>
Make message in last commit more precise.

* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Emit a dependency
of 'check-am' on 'check-notice' that prints a notice describing where to
report test failures.
---
 ChangeLog            | 12 ++++++++++++
 gnulib-tool.py.TODO  | 22 ----------------------
 pygnulib/GLEmiter.py |  8 ++++++++
 3 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 53234e7de6..44e86f7f52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-03-06  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 44.
+	Follow gnulib-tool changes
+	2021-06-10  Bruno Haible  <br...@clisp.org>
+	Clarify where to report test failures from Gnulib tests.
+	2021-06-11  Bruno Haible  <br...@clisp.org>
+	Make message in last commit more precise.
+	* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Emit a dependency
+	of 'check-am' on 'check-notice' that prints a notice describing where to
+	report test failures.
+
 2024-03-05  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 43.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index a15bfc948a..8548013005 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -529,28 +529,6 @@ Date:   Sun Aug 8 03:52:01 2021 +0200
 
 --------------------------------------------------------------------------------
 
-commit 39d08c09b444db57f45804bfe86ee17203c45a8a
-Author: Bruno Haible <br...@clisp.org>
-Date:   Fri Jun 11 15:55:33 2021 +0200
-
-    Make message in last commit more precise.
-
-    Suggested by Eric Blake.
-
-    * gnulib-tool (func_emit_tests_Makefile_am): Add more precision to
-    'check-notice' message.
-
-commit d465dd70e1ec5fe332160780eb66511028f5897b
-Author: Bruno Haible <br...@clisp.org>
-Date:   Thu Jun 10 21:43:59 2021 +0200
-
-    Clarify where to report test failures from Gnulib tests.
-
-    * gnulib-tool (func_emit_tests_Makefile_am): Emit a dependency of
-    'check-am' on 'check-notice' that prints a notice.
-
---------------------------------------------------------------------------------
-
 commit 4b071c115309079528db7b60e8d2ffb22b129088
 Author: Paul Eggert <egg...@cs.ucla.edu>
 Date:   Mon Apr 26 23:31:29 2021 -0700
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 1d1463851b..8316d0af5c 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -1198,6 +1198,14 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         emit += '\t@echo \'## You can ignore compiler warnings in this directory.  ##\'\n'
         emit += '\t@echo \'## ---------------------------------------------------- ##\'\n'
         emit += '\n'
+        # Arrange to print a message before executing the tests in this directory.
+        emit += 'check-am: check-notice\n'
+        emit += 'check-notice:\n'
+        emit += '\t@echo \'## ---------------------------------------------------------------------- ##\'\n'
+        emit += '\t@echo \'## ---------------------------- Gnulib tests ---------------------------- ##\'\n'
+        emit += '\t@echo \'## Please report test failures in this directory to <bug-gnulib@gnu.org>. ##\'\n'
+        emit += '\t@echo \'## ---------------------------------------------------------------------- ##\'\n'
+        emit += '\n'
         emit += '# Clean up after Solaris cc.\n'
         emit += 'clean-local:\n'
         emit += '\trm -rf SunWS_cache\n\n'
-- 
2.44.0

Reply via email to