From: Collin Funk <collin.funk1@gmail.com>
To: bug-gnulib@gnu.org
Subject: gnulib-tool.py: Fix --extract-tests-module with a test module.
Date: Mon, 1 Apr 2024 02:12:14 -0700 [thread overview]
Message-ID: <c4592706-e479-4929-8f67-4f24bb6a3925@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3325 bytes --]
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 #2: 0001-gnulib-tool.py-Fix-extract-tests-module-with-a-test-.patch --]
[-- Type: text/x-patch, Size: 1574 bytes --]
From e60b3061664938559ae7ef561d3b11f87130c21a Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Mon, 1 Apr 2024 01:18:17 -0700
Subject: [PATCH 1/2] gnulib-tool.py: Fix --extract-tests-module with a test
module.
* pygnulib/GLModuleSystem.py (GLModule.getTestsName): Return the module
name with '-tests' appended to it unconditionally.
---
ChangeLog | 6 ++++++
pygnulib/GLModuleSystem.py | 5 +----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5381e276c6..056f8827dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-01 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Fix --extract-tests-module with a test module.
+ * pygnulib/GLModuleSystem.py (GLModule.getTestsName): Return the module
+ name with '-tests' appended to it unconditionally.
+
2024-03-31 Collin Funk <collin.funk1@gmail.com>
gnulib-tool.py: Use case-sensitive sorting for files.
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'
def getTestsModule(self) -> GLModule | None:
'''Return -tests version of the module as GLModule.'''
--
2.44.0
[-- Attachment #3: 0002-gnulib-tool.py-Only-check-existence-for-extract-test.patch --]
[-- Type: text/x-patch, Size: 1573 bytes --]
From ed6d4e855f1e06fc81ac31060be6cb61f23ba965 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Mon, 1 Apr 2024 01:40:01 -0700
Subject: [PATCH 2/2] gnulib-tool.py: Only check existence for
--extract-tests-module.
* pygnulib/main.py (main): Check that the test module exists instead of
looking it up and patching it if diff's are found.
---
ChangeLog | 6 ++++++
pygnulib/main.py | 5 ++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 056f8827dc..95b034ca21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-01 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Only check existence for --extract-tests-module.
+ * pygnulib/main.py (main): Check that the test module exists instead of
+ looking it up and patching it if diff's are found.
+
2024-04-01 Collin Funk <collin.funk1@gmail.com>
gnulib-tool.py: Fix --extract-tests-module with a test module.
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]
--
2.44.0
next reply other threads:[~2024-04-01 9:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 9:12 Collin Funk [this message]
2024-04-01 13:25 ` gnulib-tool.py: Fix --extract-tests-module with a test module Bruno Haible
2024-04-01 21:01 ` Collin Funk
2024-04-01 22:11 ` packages tests Bruno Haible
2024-04-01 22:31 ` Collin Funk
2024-04-02 2:49 ` gnulib-tool.py: Don't default to 'build-aux' for --auxdir Collin Funk
2024-04-02 12:22 ` Bruno Haible
2024-04-02 17:14 ` Collin Funk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c4592706-e479-4929-8f67-4f24bb6a3925@gmail.com \
--to=collin.funk1@gmail.com \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).