This unit test fails:

$ ./test-cache-2-11.sh 
Files ./test-cache-2-11.result/lib/Makefile.gnulib and 
tmp2051058-result/lib/Makefile.gnulib differ
Files ./test-cache-2-11.result/m4/gnulib-cache.m4 and 
tmp2051058-result/m4/gnulib-cache.m4 differ
FAIL: gnulib-tool's result has unexpected differences.
$ diff -u ./test-cache-2-11.result/m4/gnulib-cache.m4 
tmp2051058-result/m4/gnulib-cache.m4
--- ./test-cache-2-11.result/m4/gnulib-cache.m4 2024-04-12 13:37:25.739149311 
+0200
+++ tmp2051058-result/m4/gnulib-cache.m4        2024-04-12 22:42:50.965325657 
+0200
@@ -53,7 +53,6 @@
 #  --witness-c-macro=IN_PROG \
 #  --vc-files \
 #  --avoid=stddef \
-#  --avoid=timevar \
 #  unistd
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
@@ -67,7 +66,7 @@
 gl_WITH_PRIVILEGED_TESTS
 gl_WITH_UNPORTABLE_TESTS
 gl_WITH_ALL_TESTS
-gl_AVOID([stddef timevar])
+gl_AVOID([stddef])
 gl_SOURCE_BASE([lib])
 gl_M4_BASE([m4])
 gl_PO_BASE([po])

The reason is that, after computing the union of the avoids from gnulib-cache.m4
and from the command-line parameters — which yields ['stddef','timevar'] —
this value is overridden by the command-line parameters. This patch fixes it.


2024-04-12  Bruno Haible  <br...@clisp.org>

        gnulib-tool.py: Implement --add-import --avoid correctly.
        * pygnulib/GLConfig.py (GLConfig.update): Don't test for the unused key
        'tests'.
        * pygnulib/GLImport.py (GLImport.__init__): Don't merge back those
        values which were already considered by taking the union.

diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index ab1cb218be..c9248453aa 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -290,7 +290,7 @@ class GLConfig:
                     if self.isdefault(key, dest):
                         value = src
                     else:  # if not self.isdefault(key, dest)
-                        if key in ['modules', 'avoids', 'tests']:
+                        if key in ['modules', 'avoids']:
                             value = sorted(set(src + dest))
                         else:
                             value = dest
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index c931536ea9..210768bd68 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -259,14 +259,15 @@ class GLImport:
             # Merge the configuration found on disk.
             self.config.update(self.cache)
 
+            self.config.setModules(modules)
+
             # Merge with the configuration from the command-line parameters;
             # they override the configuration found on disk.
             for key in config.keys():
-                value = config[key]
-                if not config.isdefault(key, value):
-                    self.config.update_key(config, key)
-
-            self.config.setModules(modules)
+                if key not in ['modules', 'avoids']:
+                    value = config[key]
+                    if not config.isdefault(key, value):
+                        self.config.update_key(config, key)
 
         # Determine whether --automake-subdir/--automake-subdir-tests are 
supported.
         if self.config['automake_subdir'] or 
self.config['automake_subdir_tests']:




Reply via email to