bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib-tool.py: Fix handling of --with-obsolete


From: Bruno Haible
Subject: gnulib-tool.py: Fix handling of --with-obsolete
Date: Fri, 12 Apr 2024 18:20:29 +0200

This test failure

$ ./test-cache-2-5.sh 
Files ./test-cache-2-5.result/lib/Makefile.gnulib and 
tmp1924205-result/lib/Makefile.gnulib differ
Only in ./test-cache-2-5.result/m4: ansi-c++.m4
Only in ./test-cache-2-5.result/m4: assert_h.m4
Only in ./test-cache-2-5.result/m4: c-bool.m4
Only in ./test-cache-2-5.result/m4: codeset.m4
Files ./test-cache-2-5.result/m4/gnulib-cache.m4 and 
tmp1924205-result/m4/gnulib-cache.m4 differ
Files ./test-cache-2-5.result/m4/gnulib-comp.m4 and 
tmp1924205-result/m4/gnulib-comp.m4 differ
Only in ./test-cache-2-5.result/m4: inttypes.m4
Only in ./test-cache-2-5.result/m4: limits-h.m4
Only in ./test-cache-2-5.result/m4: locale-fr.m4
Only in ./test-cache-2-5.result/m4: multiarch.m4
Only in ./test-cache-2-5.result/m4: std-gnu11.m4
Only in ./test-cache-2-5.result/m4: stdalign.m4
Only in ./test-cache-2-5.result/m4: stdint.m4
Only in ./test-cache-2-5.result/m4: stdlib_h.m4
Only in ./test-cache-2-5.result/m4: wchar_h.m4
Only in ./test-cache-2-5.result/m4: wint_t.m4
Only in ./test-cache-2-5.result: tests
FAIL: gnulib-tool's result has unexpected differences.
$ diff -u ./test-cache-2-5.result/m4/gnulib-cache.m4 
tmp1924205-result/m4/gnulib-cache.m4
--- ./test-cache-2-5.result/m4/gnulib-cache.m4  2024-04-12 13:35:00.797693967 
+0200
+++ tmp1924205-result/m4/gnulib-cache.m4        2024-04-12 17:23:31.040510993 
+0200
@@ -36,13 +36,7 @@
 #  --doc-base=doc \
 #  --tests-base=tests \
 #  --aux-dir=support \
-#  --with-tests \
 #  --with-obsolete \
-#  --with-c++-tests \
-#  --with-longrunning-tests \
-#  --with-privileged-tests \
-#  --with-unportable-tests \
-#  --with-all-tests \
 #  --lgpl \
 #  --makefile-name=Makefile.gnulib \
 #  --automake-subdir \
@@ -61,18 +55,12 @@
   unistd
 ])
 gl_WITH_OBSOLETE
-gl_WITH_CXX_TESTS
-gl_WITH_LONGRUNNING_TESTS
-gl_WITH_PRIVILEGED_TESTS
-gl_WITH_UNPORTABLE_TESTS
-gl_WITH_ALL_TESTS
 gl_AVOID([timevar])
 gl_SOURCE_BASE([lib])
 gl_M4_BASE([m4])
 gl_PO_BASE([po])
 gl_DOC_BASE([doc])
 gl_TESTS_BASE([tests])
-gl_WITH_TESTS
 gl_LIB([libgnu])
 gl_LGPL
 gl_MAKEFILE_NAME([Makefile.gnulib])

shows a side effect of --with-obsolete on the test categories.

The implementation of --with-obsolete is bogus: In the code it is treated as
if it were a test category. Which it isn't: any module can be marked as
"obsolete". This patch fixes it.


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

        gnulib-tool.py: Fix handling of --with-obsolete.
        * pygnulib/constants.py (TESTS): Remove 'obsolete' category.
        * pygnulib/GLConfig.py (GLConfig.__init__): Add optional incobsolete
        parameter.
        (GLConfig.default): Handle 'incobsolete'.
        (GLConfig.checkIncObsolete, GLConfig.setIncObsolete,
        GLConfig.resetIncObsolete): New methods.
        * pygnulib/GLModuleSystem.py (GLModuleSystem.transitive_closure): For
        incobsolete, use new GLConfig methods.
        * pygnulib/GLImport.py (GLImport.__init__, GLImport.actioncmd,
        GLImport.gnulib_cache): Likewise.
        * pygnulib/main.py (main): Pass the incobsolete value to the GLConfig
        constructor.

diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index e0530c9886..90b7bd984a 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -68,6 +68,7 @@ class GLConfig:
                  modules: list[str] | None = None,
                  avoids: list[str] | None = None,
                  files: list[str] | None = None,
+                 incobsolete: bool | None = None,
                  incl_test_categories: list[int] | tuple[int] | None = None,
                  excl_test_categories: list[int] | tuple[int] | None = None,
                  libname: str | None = None,
@@ -143,6 +144,10 @@ class GLConfig:
         self.resetFiles()
         if files != None:
             self.setFiles(files)
+        # incobsolete
+        self.resetIncObsolete()
+        if incobsolete != None:
+            self.setIncObsolete(incobsolete)
         # test categories to include
         self.resetInclTestCategories()
         if incl_test_categories != None:
@@ -313,8 +318,8 @@ class GLConfig:
             elif key in ['localpath', 'modules', 'avoids', 'tests',
                          'incl_test_categories', 'excl_test_categories']:
                 return []
-            elif key in ['libtool', 'gnu_make', 'automake_subdir',
-                         'automake_subdir_tests', 'conddeps',
+            elif key in ['incobsolete', 'libtool', 'gnu_make',
+                         'automake_subdir', 'automake_subdir_tests', 
'conddeps',
                          'libtests', 'dryrun']:
                 return False
             elif key in ['copymode', 'lcopymode']:
@@ -644,6 +649,23 @@ class GLConfig:
         '''Reset the list of files.'''
         self.table['files'] = []
 
+    # Define incobsolete methods.
+    def checkIncObsolete(self) -> bool:
+        '''Check if user enabled inclusion of obsolete dependencies.'''
+        return self.table['incobsolete']
+
+    def setIncObsolete(self, value: bool) -> None:
+        '''Enable / disable inclusion of obsolete dependencies.'''
+        if type(value) is bool:
+            self.table['incobsolete'] = value
+        else:  # if type(value) is not bool
+            raise TypeError('value must be a bool, not %s'
+                            % type(value).__name__)
+
+    def resetIncObsolete(self) -> None:
+        '''Reset inclusion of obsolete dependencies.'''
+        self.table['incobsolete'] = False
+
     # Define incl_test_categories methods
     def checkInclTestCategory(self, category: int) -> bool:
         '''Tests whether the given test category is included.'''
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index aa8acaa2e7..bc575eaa1f 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -134,7 +134,7 @@ class GLImport:
                 self.cache.enableInclTestCategory(TESTS['tests'])
                 data = data.replace('gl_WITH_TESTS', '')
             if 'gl_WITH_OBSOLETE' in data:
-                self.cache.enableInclTestCategory(TESTS['obsolete'])
+                self.cache.setIncObsolete(True)
                 data = data.replace('gl_WITH_OBSOLETE', '')
             if 'gl_WITH_CXX_TESTS' in data:
                 self.cache.enableInclTestCategory(TESTS['c++-test'])
@@ -421,7 +421,7 @@ class GLImport:
         actioncmd += ' \\\n#  --aux-dir=%s' % auxdir
         if self.config.checkInclTestCategory(TESTS['tests']):
             actioncmd += ' \\\n#  --with-tests'
-        if self.config.checkInclTestCategory(TESTS['obsolete']):
+        if self.config.checkIncObsolete():
             actioncmd += ' \\\n#  --with-obsolete'
         if self.config.checkInclTestCategory(TESTS['c++-test']):
             actioncmd += ' \\\n#  --with-c++-tests'
@@ -505,7 +505,6 @@ class GLImport:
         GLConfig: destdir, localpath, tests, sourcebase, m4base, pobase, 
docbase,
         testsbase, conddeps, libtool, macro_prefix, podomain, vc_files.'''
         emit = ''
-        moduletable = self.moduletable
         actioncmd = self.actioncmd()
         localpath = self.config['localpath']
         sourcebase = self.config['sourcebase']
@@ -545,7 +544,7 @@ class GLImport:
         emit += 'gl_MODULES([\n'
         emit += '  %s\n' % '\n  '.join(modules)
         emit += '])\n'
-        if self.config.checkInclTestCategory(TESTS['obsolete']):
+        if self.config.checkIncObsolete():
             emit += 'gl_WITH_OBSOLETE\n'
         if self.config.checkInclTestCategory(TESTS['cxx-tests']):
             emit += 'gl_WITH_CXX_TESTS\n'
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index d258fd903f..0399a708d0 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -871,7 +871,7 @@ class GLModuleTable:
                         statuses = depmodule.getStatuses()
                         for word in statuses:
                             if word == 'obsolete':
-                                if not 
self.config.checkInclTestCategory(TESTS['obsolete']):
+                                if not self.config.checkIncObsolete():
                                     include = False
                             elif word == 'c++-test':
                                 if 
self.config.checkExclTestCategory(TESTS['c++-test']):
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 014dcce947..dc1297d529 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -108,19 +108,18 @@ MODES['verbose-max'] = 2
 TESTS = \
     {
         'tests':             0,
-        'obsolete':          1,
-        'c++-test':          2,
-        'cxx-test':          2,
-        'c++-tests':         2,
-        'cxx-tests':         2,
-        'longrunning-test':  3,
-        'longrunning-tests': 3,
-        'privileged-test':   4,
-        'privileged-tests':  4,
-        'unportable-test':   5,
-        'unportable-tests':  5,
-        'all-test':          6,
-        'all-tests':         6,
+        'c++-test':          1,
+        'cxx-test':          1,
+        'c++-tests':         1,
+        'cxx-tests':         1,
+        'longrunning-test':  2,
+        'longrunning-tests': 2,
+        'privileged-test':   3,
+        'privileged-tests':  3,
+        'unportable-test':   4,
+        'unportable-tests':  4,
+        'all-test':          5,
+        'all-tests':         5,
     }
 
 # Define AUTOCONF minimum version
diff --git a/pygnulib/main.py b/pygnulib/main.py
index 9fadd4a4ea..08c4c89cf8 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -748,6 +748,7 @@ def main() -> None:
         testsbase = cmdargs.testsbase[0]
     dryrun = cmdargs.dryrun
     verbose = -cmdargs.quiet + cmdargs.verbose
+    incobsolete = cmdargs.obsolete
     inctests = cmdargs.inctests
     # Canonicalize the inctests variable.
     if inctests == None:
@@ -758,8 +759,6 @@ def main() -> None:
     incl_test_categories = []
     if inctests:
         incl_test_categories.append(constants.TESTS['tests'])
-    if cmdargs.obsolete:
-        incl_test_categories.append(constants.TESTS['obsolete'])
     if cmdargs.inc_cxx_tests:
         incl_test_categories.append(constants.TESTS['cxx-tests'])
     if cmdargs.inc_longrunning_tests:
@@ -826,6 +825,7 @@ def main() -> None:
         pobase=pobase,
         docbase=docbase,
         testsbase=testsbase,
+        incobsolete=incobsolete,
         incl_test_categories=incl_test_categories,
         excl_test_categories=excl_test_categories,
         libname=libname,






reply via email to

[Prev in Thread] Current Thread [Next in Thread]