This patch fixes the failure of
'test-extract-recursive-link-directive-3.sh' in the gnulib-tool test
suite:

cmp: EOF on tmp529181-out which is empty
--- ./test-extract-recursive-link-directive-3.output    2024-03-20 
19:16:08.842291576 -0700
+++ tmp529181-out       2024-03-20 19:17:56.295403277 -0700
@@ -1,2 +0,0 @@
-$(MBRTOWC_LIB)
-$(SETLOCALE_LIB)
FAIL: gnulib-tool's output has unexpected differences.
FAIL: test-extract-recursive-link-directive-3.sh

Due to this typo

             for module in inmodules_this_round:
-                if self.getLink() != '':
+                if module.getLink() != '':

the only 'Link:' section checked is from the original module.
Therefore, for this test, the 'mbsinit' and 'setlocale' modules are
missed.

Since we want to remove duplicate link directives, I have also changed
the lists to sets.

Collin
From 3360beb64a6b1569131edf6644762046c9266082 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Wed, 20 Mar 2024 19:07:50 -0700
Subject: [PATCH] gnulib-tool.py: Fix --extract-recursive-link-directive.

* pygnulib/GLModuleSystem.py (GLModule.getLinkDirectiveRecursively):
Check the 'Link:' section of each individual module. Use sets instead of
lists to remove duplicates.
---
 ChangeLog                  |  7 +++++++
 pygnulib/GLModuleSystem.py | 10 +++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4f92f28c31..87ad8b94d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-20  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Fix --extract-recursive-link-directive.
+	* pygnulib/GLModuleSystem.py (GLModule.getLinkDirectiveRecursively):
+	Check the 'Link:' section of each individual module. Use sets instead of
+	lists to remove duplicates.
+
 2024-03-20  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Make --extract-filelist match gnulib-tool.sh.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 4e970efeb9..b8e41408e7 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -387,7 +387,7 @@ class GLModule(object):
             inmodules_this_round = inmodules
             inmodules = set()  # Accumulator, queue for next round
             for module in inmodules_this_round:
-                if self.getLink() != '':
+                if module.getLink() != '':
                     # The module description has a 'Link:' field. Ignore the dependencies.
                     outmodules.add(module)
                 else:
@@ -398,12 +398,12 @@ class GLModule(object):
             inmodules = inmodules.difference(handledmodules)
 
         # Remove whitespace from sections.
-        link_sections = [ module.getLink().strip()
-                          for module in outmodules ]
+        link_sections = { module.getLink().strip()
+                          for module in outmodules }
         # Sort the link directives.
-        directives = sorted([ line
+        directives = sorted({ line
                               for section in link_sections
-                              for line in section.splitlines() ])
+                              for line in section.splitlines() })
         return lines_to_multiline(directives)
 
     def getShellFunc(self):
-- 
2.44.0

Reply via email to