bug-gnulib
[Top][All Lists]
Advanced

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

gnulib-tool.py: Fix --extract-tests-module with a test module.


From: Collin Funk
Subject: gnulib-tool.py: Fix --extract-tests-module with a test module.
Date: Mon, 1 Apr 2024 02:12:14 -0700
User-agent: Mozilla Thunderbird

These two patches fix the last remaining test failures in the
gnulib-tool test suite.

The first patch addresses this:

$ env GNULIB_TOOL_IMPL=py ./test-extract-tests-module-3.sh 
cmp: EOF on ./test-extract-tests-module-3.output which is empty
--- ./test-extract-tests-module-3.output        2024-03-31 23:53:29.037177133 
-0700
+++ tmp605976-out       2024-04-01 01:44:05.294358174 -0700
@@ -0,0 +1 @@
+string-tests
FAIL: gnulib-tool's output has unexpected differences.

This fails because when given a test module gnulib-tool.sh and
gnulib-tool.py disagree on what to look up.

This:

    gnulib-tool.sh --extract-tests-module string-tests

looks up 'string-tests-tests'. In other words the test of the test of
the string module. :)

But this:

    gnulib-tool.py --extract-tests-module string-tests

looks up the 'string-tests' and prints it back to the user. This diff
should fix it:

diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 0d791fb664..ba92d8a933 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -308,10 +308,7 @@ class GLModule(object):
 
     def getTestsName(self) -> str:
         '''Return -tests version of the module name.'''
-        result = self.getName()
-        if not result.endswith('-tests'):
-            result += '-tests'
-        return result
+        return f'{self.name}-tests'

The only other place this is used is
GLModuleTable.transitive_closure() and it doesn't seem like this
change breaks anything there.

After this change, the test fails for the same reason as the other
failing test:

$ env GNULIB_TOOL_IMPL=py ./test-extract-tests-module-2.sh 
gnulib-tool: warning: file savewd-tests does not exist
FAIL: gnulib-tool succeeded but printed warnings.

$ env GNULIB_TOOL_IMPL=py ./test-extract-tests-module-3.sh 
gnulib-tool: warning: file string-tests-tests does not exist
FAIL: gnulib-tool succeeded but printed warnings.

When given "$module" gnulib-tool.sh looksup $module, applying any
diff's in the process. Then it only verifies the "$module-tests"
description exists. This differs from gnulib-tool.py which performs
the lookup and patching process to both "$module" and "$module-tests".
Consequently, errors and/or warnings occur when a test module is not
found, as seen in those test cases.

This diff fixes it:

diff --git a/pygnulib/main.py b/pygnulib/main.py
index 688ab249f3..55d635d074 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -1268,9 +1268,8 @@ def main() -> None:
         modulesystem = classes.GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
-            if module:
-                if module.getTestsModule():
-                    print(module.getTestsName())
+            if module and modulesystem.exists(module.getTestsName()):
+                print(module.getTestsName())
 
     elif mode == 'copy-file':
         srcpath = files[0]

Also, notice that "module != None" would break another test case
there (see GLModule.__ne__):

$ env GNULIB_TOOL_IMPL=py ./test-extract-tests-module-1.sh 
cmp: EOF on tmp608964-out which is empty
--- ./test-extract-tests-module-1.output        2024-03-31 23:53:29.037177133 
-0700
+++ tmp608964-out       2024-04-01 02:07:11.192876681 -0700
@@ -1 +0,0 @@
-string-tests
FAIL: gnulib-tool's output has unexpected differences.

Collin

Attachment: 0001-gnulib-tool.py-Fix-extract-tests-module-with-a-test-.patch
Description: Text Data

Attachment: 0002-gnulib-tool.py-Only-check-existence-for-extract-test.patch
Description: Text Data


reply via email to

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