bug-gnulib
[Top][All Lists]
Advanced

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

Re: warnings in unit tests


From: Bruno Haible
Subject: Re: warnings in unit tests
Date: Wed, 09 Jun 2021 16:17:27 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; )

Bernhard Voelker wrote:
> One little aspect of the tests code is that people might look (also) there to
> learn how to use a certain gnulib module, and then copy/paste the code from
> there into their projects.

Yes, a secondary value of the unit tests is to show how the APIs can be
correctly used. (For example, the unit tests of the 'list' and 'hamt' modules.)

> That's at least true for the good test cases, surely not for those provoking 
> errors.
> This means it may be worthwhile to have at least the good test cases in a 
> warning-
> free shape (which I think it most often already is).

Yes, the parts of the unit tests that exercise the normal use of an API should
normally compile without warnings with '-Wall'.

The parts that exercise corner cases (NULL pointer accesses, invalid arguments,
endless loops, endless recursions, etc.), on the other hand, can produce 
warnings,
from compilers and from static analysis tools.

That's one reason why we cannot tolerate '-Werror' on gnulib tests.

The other reason is that every package maintainer has their preferred set of
warnings — that's what the 'manywarnings' module is made for —, but it does
not make sense for package maintainers to enforce the absence of certain
warnings on code that 1) they don't maintain, 2) does not end up in the
binaries produced (installed) by their package.

Bruno




reply via email to

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