Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 64.

2024-03-18 Thread Collin Funk
Hi Bruno,

On 3/18/24 4:05 AM, Bruno Haible wrote:
> Thanks a lot. Yes, things get tricky if, after after some refactoring, the
> function names don't fit the semantics any more.

Yeah, how we have it now should match gnulib-tool.sh, but the naming
is a bit misleading. I'll keep it in the back of my head and maybe
eventually I will think of a good solution.

> I've applied your patch, together with a comment update:

I was about to fix the docstring right before I noticed the issues. I
forgot to come back and fix it. Thanks for fixing that.

Collin



Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 64.

2024-03-18 Thread Bruno Haible
Hi Collin,

> after the change that this patch is following the function names are
> slightly misleading since:
> 
>  GLModule.isNonTests() != (not GLModule.isTests())
> 
> Instead we have 3 separate unique operations in gnulib-tool.sh:
> 
> 1. func_verify_tests_module
> 2. func_verify_nontests_module
> 3. case "$module" in *-tests ) ... ;;
> 
> Which are equivalent to the following in Python:
> 
> 1. GLModule.isTests()
> 2. GLModule.isNonTests()
> 3. GLModule.getName().endswith('-tests')
> 
> I think I found all of them.

Thanks a lot. Yes, things get tricky if, after after some refactoring, the
function names don't fit the semantics any more.

You did the right thing is copying the logic from gnulib-tool.sh, even
though the function names are suboptimal.

I've applied your patch, together with a comment update:


2024-03-18  Bruno Haible  

gnulib-tool.py: Tweak last commit.
* pygnulib/GLModuleSystem.py (GLModule.isTests, GLModule.isNonTests):
Update comments.

diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 2c5f36b6b0..4e4306fe37 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -307,14 +307,15 @@ class GLModule(object):
 def isTests(self):
 '''GLModule.isTests() -> bool
 
-Check whether module is a -tests version of module.'''
+Check whether module is a *-tests module or a module of
+applicability 'all'.'''
 result = self.getApplicability() != 'main'
 return result
 
 def isNonTests(self):
-'''GLModule.isTests() -> bool
+'''GLModule.isNonTests() -> bool
 
-Check whether module is not a -tests version of module.'''
+Check whether module is not a *-tests module.'''
 result = not self.getName().endswith('-tests')
 return result
 






[PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 64.

2024-03-17 Thread Collin Funk
Here is a patch fixing another item in gnulib-tool.py.TODO. It is more
complex than the original since the change uncovered a few issues.

When changing GLModule.isTests() to check the Applicability of the
module:

  File "/home/collin/.local/src/gnulib/pygnulib/GLModuleSystem.py", line 501, 
in getApplicability
if self.isTests():
   ^^
RecursionError: maximum recursion depth exceeded

Which is interesting, but an easy fix. We can't use GLModule.isTests()
there since it depends on the result of GLModule.getApplicability().
This matches 'func_get_applicability' in gnulib-tool.sh which just
tests that the name ends with '-tests'.

Then running Emacs merge-gnulib script, there are many added diff
lines because of the gen-header and snippet/* modules. This is because
after the change that this patch is following the function names are
slightly misleading since:

 GLModule.isNonTests() != (not GLModule.isTests())

Instead we have 3 separate unique operations in gnulib-tool.sh:

1. func_verify_tests_module
2. func_verify_nontests_module
3. case "$module" in *-tests ) ... ;;

Which are equivalent to the following in Python:

1. GLModule.isTests()
2. GLModule.isNonTests()
3. GLModule.getName().endswith('-tests')

I think I found all of them. Luckily there are only a few
'Applicability: all' modules, so it should be easy to tell if this
issue pops up again.

CollinFrom 059a70104a83ad033974fc13433cb1994683b994 Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Sun, 17 Mar 2024 20:09:12 -0700
Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 64.

Follow gnulib-tool change
2021-12-25  Bruno Haible  
gnulib-tool: Respect applicability 'all' without --single-configure.

* pygnulib/GLModuleSystem.py (GLModule.isTests): Treat modules with
applicability 'all' like 'tests' modules, not like 'main' modules.
(GLModule.isNonTests): Treat all modules not ending in '-tests' as
non-test modules.
(GLModule.getApplicability): Don't use GLModule.isTests(). Because it
depends on the result of this function, using it would cause a
RecursionError exception.
(GLModule.getDependencies): Respect the difference between
module.isTests(), module.isNonTests(), and
module.getName().endswith('-tests').
(GLModule.getAutomakeSnippet_Unconditional, GLModule.getLicense)
(GLModuleTable.add_dummy): Likewise.
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Likewise.
---
 ChangeLog  | 20 
 gnulib-tool.py.TODO| 11 ---
 pygnulib/GLEmiter.py   |  4 ++--
 pygnulib/GLModuleSystem.py | 14 +++---
 4 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a54938bcc8..6b6cd48157 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2024-03-17  Collin Funk  
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 64.
+	Follow gnulib-tool change
+	2021-12-25  Bruno Haible  
+	gnulib-tool: Respect applicability 'all' without --single-configure.
+	* pygnulib/GLModuleSystem.py (GLModule.isTests): Treat modules with
+	applicability 'all' like 'tests' modules, not like 'main' modules.
+	(GLModule.isNonTests): Treat all modules not ending in '-tests' as
+	non-test modules.
+	(GLModule.getApplicability): Don't use GLModule.isTests(). Because it
+	depends on the result of this function, using it would cause a
+	RecursionError exception.
+	(GLModule.getDependencies): Respect the difference between
+	module.isTests(), module.isNonTests(), and
+	module.getName().endswith('-tests').
+	(GLModule.getAutomakeSnippet_Unconditional, GLModule.getLicense)
+	(GLModuleTable.add_dummy): Likewise.
+	* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Likewise.
+
 2024-03-17  Bruno Haible  
 
 	gnulib-tool.py: Handle empty lists of lines consistently.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 8178b2fbfd..976439e2be 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -88,17 +88,6 @@ Date:   Sat Dec 25 14:30:57 2021 +0100
 
 
 
-commit 83948c64d10c77fb964e6523a9524729d6a66f32
-Author: Bruno Haible 
-Date:   Sat Dec 25 12:19:13 2021 +0100
-
-gnulib-tool: Respect applicability 'all' without --single-configure.
-
-* gnulib-tool (func_verify_tests_module): Treat modules with
-applicability 'all' like 'tests' modules, not like 'main' modules.
-
-
-
 commit 4bdc327dbda59dcdbfa0f983a4f35c4a4ec3578c
 Author: Bruno Haible 
 Date:   Sun Dec 19 12:49:16 2021 +0100
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 97a5b5f62e..f4db15481f 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -797,7 +797,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 # Compute allsnippets variable.
 allsnippets = ''
 for module in modules:
-if not module.isTests():
+if module.isNonTests():