[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib-tool.py: Don't fail when given a bad module name.
From: |
Bruno Haible |
Subject: |
Re: gnulib-tool.py: Don't fail when given a bad module name. |
Date: |
Sun, 21 Apr 2024 13:37:18 +0200 |
Hi Collin,
> When using --create-testdir with a bad module name:
>
> $ gnulib-tool.py --create-testdir --dir aaa bad-module-name
> gnulib-tool: warning: module bad-module-name doesn't exist
> Traceback (most recent call last):
> File "/home/collin/.local/src/gnulib/.gnulib-tool.py", line 30, in <module>
> main.main_with_exception_handling()
> File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 1382, in
> main_with_exception_handling
> main()
> File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 1075, in main
> testdir.execute()
> File "/home/collin/.local/src/gnulib/pygnulib/GLTestDir.py", line 209, in
> execute
> requested_licence = requested_module.getLicense()
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> AttributeError: 'NoneType' object has no attribute 'getLicense'
>
> This patch removes None from the list of GLModule objects before using
> them.
Good point. Thanks, patch applied with one tweak:
> I also documented the meaning of a None return in
> GLModuleSystem.find() since this problem occurred in GLImport
> previously.
When documenting a function or program, it is sometimes possible to state
the same condition with and without referring to the internals of the
function / program. It is better to document it without reference to the
internals.
In this case, one can say
if the module description file could not be found
or
if the module description file does not exist
The former makes an implicit statement that the function is searching
for the file. The latter does not; it does not say or hint to as what
function internally does. Thus it is better to use the latter wording.
I also tried the behaviour on gnulib-tool.sh, and got this confusing
output:
$ ./gnulib-tool.sh --create-testdir --dir=../testdir2 --single-configure foobar
signbit
./gnulib-tool.sh: *** file /GNULIB/gnulib-git/./modules/foobar not found
./gnulib-tool.sh: *** Stop.
gnulib-tool: warning: module foobar lacks a License
./gnulib-tool.sh: *** file /GNULIB/gnulib-git/./modules/foobar not found
./gnulib-tool.sh: *** Stop.
gnulib-tool: warning: module foobar doesn't exist
gnulib-tool: warning: module foobar doesn't exist
Module list with included dependencies (indented):
absolute-header
c99
extern-inline
...
It says "Stop." twice but does not actually stop :) Fixed as follows.
2024-04-21 Bruno Haible <bruno@clisp.org>
gnulib-tool.sh: In --create-testdir, just warn about a bad module name.
* gnulib-tool.sh (func_create_testdir): Validate the modules list.
diff --git a/gnulib-tool.sh b/gnulib-tool.sh
index 5f0c6f530e..b486e99b1e 100755
--- a/gnulib-tool.sh
+++ b/gnulib-tool.sh
@@ -6504,6 +6504,9 @@ func_create_testdir ()
# Except lib-ignore, which leads to link errors when Sun C++ is used.
FIXME.
modules=`func_all_modules`
modules=`for m in $modules; do case $m in config-h |
non-recursive-gnulib-prefix-hack | timevar | mountlist | lib-ignore) ;; *) echo
$m;; esac; done`
+ else
+ # Validate the list of specified modules.
+ modules=`for module in $modules; do func_verify_module; if test -n
"$module"; then echo "$module"; fi; done`
fi
specified_modules="$modules"