bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.
@ 2024-02-21 20:28 Collin Funk
  2024-02-22  0:10 ` Bruno Haible
  0 siblings, 1 reply; 7+ messages in thread
From: Collin Funk @ 2024-02-21 20:28 UTC (permalink / raw)
  To: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

Slowly trying to sync the output of gnulibtool.py.
I am hesitant to change the TODO file until we can better testing
everything. This patch should (hopefully) fix the following commit entries:

16c3e1868a15a5946c0f0f7df6e107e9b3c6389d
d465dd70e1ec5fe332160780eb66511028f5897b
39d08c09b444db57f45804bfe86ee17203c45a8a
3a24ff8a1045d8d38824088c0984bb59d0192e65

Also, is there a preference against using f-strings [1] or is it just
because the code is old? I find them to be much more readable than the
older syntax for formatting.

[1] https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings

[-- Attachment #2: 0001-gnulib-tool.py-Improve-output-of-testdir-Makefile.am.patch --]
[-- Type: text/x-patch, Size: 4490 bytes --]

From 159fec290bd19f20f98fce1de053cff2bc69d67d Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Wed, 21 Feb 2024 12:21:24 -0800
Subject: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.

* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am):
Add 'all-notice' rule as dependency of 'all' which prints a
notice. Add 'check-notice' as a dependency of 'check-am' which
prints a notice. Demand Automake >= 1.14, for %reldir%. Add
overrides for CFLAGS and CXX_FLAGS in test directories.
---
 ChangeLog            |  7 +++++++
 pygnulib/GLEmiter.py | 29 +++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e313032178..cff7a2ef05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2024-02-21  Collin Funk  <collin.funk1@gmail.com>
 
+	gnulib-tool.py: Improve output of testdir Makefile.am.
+	* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am):
+	Add 'all-notice' rule as dependency of 'all' which prints a
+	notice. Add 'check-notice' as a dependency of 'check-am' which
+	prints a notice. Demand Automake >= 1.14, for %reldir%. Add
+	overrides for CFLAGS and CXX_FLAGS in test directories.
+
 	gnulib-tool.py: Fix undefined variable while emitting testdir.
 	* pygnulib/GLTestDir.py (GLTestDir.execute): Fix undefined
 	variable refrence caused by commit
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index f83aa40ea9..3f103c101d 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -987,7 +987,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         subdir_options = ''
         if uses_subdirs:
             subdir_options = ' subdir-objects'
-        emit += 'AUTOMAKE_OPTIONS = 1.9.6 foreign%s\n\n' % subdir_options
+        emit += 'AUTOMAKE_OPTIONS = 1.14 foreign%s\n\n' % subdir_options
         if for_test and not single_configure:
             emit += 'ACLOCAL_AMFLAGS = -I %s/%s\n\n' % (testsbase_inverse, m4base)
 
@@ -1001,6 +1001,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         emit += 'noinst_PROGRAMS =\n'
         if not for_test:
             emit += 'check_PROGRAMS =\n'
+        emit += 'EXTRA_PROGRAMS =\n'
         emit += 'noinst_HEADERS =\n'
         emit += 'noinst_LIBRARIES =\n'
         if libtests:
@@ -1036,7 +1037,15 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                     emit += '%s += %s\n' % (dictionary['var'], dictionary['val'])
                     dictionary.pop('var')
 
-        emit += '\nAM_CPPFLAGS = \\\n'
+        emit += '\n'
+        if not for_test:
+            cflags_for_gnulib_code = " $(GL_CFLAG_GNULIB_WARNINGS)"
+        else:
+            cflags_for_gnulib_code = ""
+        emit += 'CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@%s @CFLAGS@\n' % cflags_for_gnulib_code
+        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:
@@ -1084,6 +1093,22 @@ 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"
+        # 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.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.
  2024-02-21 20:28 [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am Collin Funk
@ 2024-02-22  0:10 ` Bruno Haible
  2024-02-22  1:43   ` Collin Funk
  0 siblings, 1 reply; 7+ messages in thread
From: Bruno Haible @ 2024-02-22  0:10 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Collin Funk

Hi Collin,

> I am hesitant to change the TODO file until we can better testing
> everything.

My main test case is as written at the top of gnulib-tool.py.TODO: A
particular checkout of wget2, with a particular gnulib-tool invocation.
Make 20 or 50 copies of this directory; then run each gnulib-tool.py
with and without some modifications, on two different copies, then
"diff -r -u", and you'll see the effect of the modifications.

Collin Funk wrote:
> This patch should (hopefully) fix the following commit entries:
> 
> 16c3e1868a15a5946c0f0f7df6e107e9b3c6389d
> d465dd70e1ec5fe332160780eb66511028f5897b
> 39d08c09b444db57f45804bfe86ee17203c45a8a
> 3a24ff8a1045d8d38824088c0984bb59d0192e65

I'm a bit unhappy with this way of working. Your patches surely
go into the right direction, but I would prefer to receive them
  1) one by one,
  2) with the corresponding gnulib-tool.py.TODO entry removal.
Because if we don't keep track of which entries are still left, it
opens the door to confusion (was a patch applied? was it applied
but not tested? was only a partial translation of the commit to
python achieved?).

> Also, is there a preference against using f-strings [1] or is it just
> because the code is old? I find them to be much more readable than the
> older syntax for formatting.
> 
> [1] https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings

It looks like the f-strings were introduced in Python 3.6 [1], and
Python 3.6 or newer is available on the vast majority of distros [2].
So, there is no technical reason not to use f-strings. And it appears
to have become mainstream style of Python coding. So, please go ahead
and use f-strings in new code, if you want.

We _may_ also refactor the existing code to use f-strings later, when
the Python rewrite is complete. But now is not the right moment for
that.

Bruno

[1] https://peps.python.org/pep-0498/
[2] https://repology.org/project/python/versions





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.
  2024-02-22  0:10 ` Bruno Haible
@ 2024-02-22  1:43   ` Collin Funk
  2024-02-22  1:55     ` Bruno Haible
  0 siblings, 1 reply; 7+ messages in thread
From: Collin Funk @ 2024-02-22  1:43 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

On 2/21/24 4:10 PM, Bruno Haible wrote:
> I'm a bit unhappy with this way of working. Your patches surely
> go into the right direction, but I would prefer to receive them
>   1) one by one,
>   2) with the corresponding gnulib-tool.py.TODO entry removal.
> Because if we don't keep track of which entries are still left, it
> opens the door to confusion (was a patch applied? was it applied
> but not tested? was only a partial translation of the commit to
> python achieved?).

I was having similar thoughts while writing the ChangeLog entry. Your
method sounds much better. I'll rewrite them and submit each patch
individually even if the change is a single line. Should I mention the
commit being removed from the gnulib-tool.py.TODO file in the ChangeLog
and commit message? I think it might help tracking down any issues that
might come up later.

> It looks like the f-strings were introduced in Python 3.6 [1], and
> Python 3.6 or newer is available on the vast majority of distros [2].
> So, there is no technical reason not to use f-strings. And it appears
> to have become mainstream style of Python coding. So, please go ahead
> and use f-strings in new code, if you want.
> 
> We _may_ also refactor the existing code to use f-strings later, when
> the Python rewrite is complete. But now is not the right moment for
> that.

Sounds good. I think I will just try to match surrounding code for now.
Python 3.8 is the lowest version still supported [1]. I'll reference
documents from that version when making changes. Older versions will
probably still work but it is nice to have a point of reference.

[1] https://devguide.python.org/versions/

Thanks for the advice,
Collin





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.
  2024-02-22  1:43   ` Collin Funk
@ 2024-02-22  1:55     ` Bruno Haible
  2024-02-22  5:49       ` Collin Funk
  0 siblings, 1 reply; 7+ messages in thread
From: Bruno Haible @ 2024-02-22  1:55 UTC (permalink / raw)
  To: bug-gnulib, Collin Funk

Hi Collin,

> Should I mention the
> commit being removed from the gnulib-tool.py.TODO file in the ChangeLog
> and commit message? I think it might help tracking down any issues that
> might come up later.

Yes, please. But for long-time storage I'm not a fan of commit ids
(I've seen too many packages move from one VCS to another VCS in the past...),
but rather like in
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=948345cceab85ab699910a795d6b69ea2be6e300
with the two first lines from the ChangeLog entry:

  Follow gnulib-tool change
  <date and author of that commit>
  <one-line summary of that commit>

Thanks!

Bruno





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.
  2024-02-22  1:55     ` Bruno Haible
@ 2024-02-22  5:49       ` Collin Funk
  2024-02-22 16:53         ` Bruno Haible
  0 siblings, 1 reply; 7+ messages in thread
From: Collin Funk @ 2024-02-22  5:49 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

On 2/21/24 5:55 PM, Bruno Haible wrote:
> Yes, please. But for long-time storage I'm not a fan of commit ids
> (I've seen too many packages move from one VCS to another VCS in the past...),
> but rather like in
> https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=948345cceab85ab699910a795d6b69ea2be6e300
> with the two first lines from the ChangeLog entry:
> 
>   Follow gnulib-tool change
>   <date and author of that commit>
>   <one-line summary of that commit>

Okay, here is a patch to make sure I am understanding correctly. Thanks
for the help. The GNU ChangeLog stuff is new too me. I left the commit
message without a part number. I wasn't sure if you wanted to continue
them/restart since all of them are your patches from ~2 years ago. Feel
free to add one if you would like and I'll see it before submitting another.

Thanks,
Collin

[-- Attachment #2: 0001-gnulib-tool.py-Follow-gnulib-tool-changes.patch --]
[-- Type: text/x-patch, Size: 3375 bytes --]

From f6051b9bb07b5474879f4f462984b8a1f02aa221 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Wed, 21 Feb 2024 21:32:10 -0800
Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes.

Follow gnulib-tool change
2017-06-12 Bruno Haible <bruno@clisp.org>
gnulib-tool: Clean up after autotools.

* pygnulib/GLTestDir.py (GLTestDir.execute): Remove
unnessecary autom4te.cache directory generated by Autotools.
(GLMegaTestDir.execute): Likewise.
---
 ChangeLog             | 10 ++++++++++
 gnulib-tool.py.TODO   | 11 -----------
 pygnulib/GLTestDir.py |  4 ++++
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1ab1246616..7862120eb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-21  Collin Funk  <collin.funk1@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes.
+	Follow gnulib-tool change
+	2017-06-12 Bruno Haible <bruno@clisp.org>
+	gnulib-tool: Clean up after autotools.
+	* pygnulib/GLTestDir.py (GLTestDir.execute): Remove
+	unnessecary autom4te.cache directory generated by Autotools.
+	(GLMegaTestDir.execute): Likewise.
+
 2024-02-21  Bruno Haible  <bruno@clisp.org>
 
 	c-strtof: New module.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index da6df2ab90..1b4fe26cfc 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -818,17 +818,6 @@ Date:   Sun Oct 29 16:57:32 2017 +0100
 
 --------------------------------------------------------------------------------
 
-commit 87d14d357f694338acdb8745cea7304ff623ce47
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Mon Jun 12 01:38:57 2017 +0200
-
-    gnulib-tool: Clean up after autotools.
-
-    * gnulib-tool (func_create_testdir, func_create_megatestdir): Remove
-    useless directory left over by the Autotools.
-
---------------------------------------------------------------------------------
-
 commit 30459fe101541698ec704acb224946d73676750e
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Thu Jun 8 15:09:31 2017 +0200
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 144798bd01..3bb99c59cc 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -21,6 +21,7 @@ import re
 import sys
 import codecs
 import subprocess as sp
+import shutil
 from . import constants
 from .GLError import GLError
 from .GLConfig import GLConfig
@@ -675,6 +676,7 @@ class GLTestDir(object):
         # automake
         args = [UTILS['automake'], '--add-missing', '--copy']
         constants.execute(args, verbose)
+        shutil.rmtree('autom4te.cache')
         os.chdir(DIRS['cwd'])
         if inctests and not single_configure:
             # Do not use "${AUTORECONF} --force --install", because it may invoke
@@ -705,6 +707,7 @@ class GLTestDir(object):
             # automake
             args = [UTILS['automake'], '--add-missing', '--copy']
             constants.execute(args, verbose)
+            shutil.rmtree('autom4te.cache')
             os.chdir(DIRS['cwd'])
 
         # Need to run configure and make once, to create built files that are to be
@@ -994,4 +997,5 @@ class GLMegaTestDir(object):
         constants.execute(args, verbose)
         args = [UTILS['automake'], '--add-missing', '--copy']
         constants.execute(args, verbose)
+        shutil.rmtree('autom4te.cache')
         sp.call(['rm', '-rf', self.config['tempdir']], shell=False)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.
  2024-02-22  5:49       ` Collin Funk
@ 2024-02-22 16:53         ` Bruno Haible
  2024-02-22 18:23           ` Collin Funk
  0 siblings, 1 reply; 7+ messages in thread
From: Bruno Haible @ 2024-02-22 16:53 UTC (permalink / raw)
  To: bug-gnulib, Collin Funk

Collin Funk wrote:
> Okay, here is a patch to make sure I am understanding correctly.

Thanks, applied!

> Thanks
> for the help. The GNU ChangeLog stuff is new too me. I left the commit
> message without a part number. I wasn't sure if you wanted to continue
> them/restart since all of them are your patches from ~2 years ago.

I added the part number, since it gives us a certain feeling of how far we
have gotten along. Also, I copy&pasted the date+author line from
the ChangeLog; the 'git log' contains the same data with slightly different
formatting.

> The GNU ChangeLog stuff is new too me.

You can exploit 80 columns, in the ChangeLog, including the leading tab.
No need to restrict yourself to 72 columns here.

Bruno





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.
  2024-02-22 16:53         ` Bruno Haible
@ 2024-02-22 18:23           ` Collin Funk
  0 siblings, 0 replies; 7+ messages in thread
From: Collin Funk @ 2024-02-22 18:23 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

On 2/22/24 8:53 AM, Bruno Haible wrote:
> I added the part number, since it gives us a certain feeling of how far we
> have gotten along. Also, I copy&pasted the date+author line from
> the ChangeLog; the 'git log' contains the same data with slightly different
> formatting.

Sounds good to me. I'll number them next time and use the date+author
line from the ChangeLog.

> You can exploit 80 columns, in the ChangeLog, including the leading tab.
> No need to restrict yourself to 72 columns here.

Ah, I see. I felt like I was running out of room to quickly... I changed
my Emacs settings for editing ChangeLog's so it should be fixed now.

Thanks,
Collin


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-22 18:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-21 20:28 [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am Collin Funk
2024-02-22  0:10 ` Bruno Haible
2024-02-22  1:43   ` Collin Funk
2024-02-22  1:55     ` Bruno Haible
2024-02-22  5:49       ` Collin Funk
2024-02-22 16:53         ` Bruno Haible
2024-02-22 18:23           ` Collin Funk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).