How can one reliably run unittests

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Sep 3 03:06:27 UTC 2021


On Fri, Sep 03, 2021 at 01:12:13AM +0000, deadalnix via Digitalmars-d wrote:
> On Friday, 3 September 2021 at 00:09:37 UTC, H. S. Teoh wrote:
> > Would this satisfy everybody?
> > 
> 
> 1/ make module the default. This is really the sensible behavior.
> Changing imports really change the list of test that are run,
> especially not recursively.

Making module the default would break existing usage. But whatever, the
important thing is to implement -unittest=xxx first, then changing the
default is a 1-line change later.


> 2/ the `-main` problem remains.

Even though it's kinda related, -main is really an orthogonal issue.
I've also run into the problem myself where -main is needed when your
modules don't contain main() but must be suppressed or worked around
when it does declare main().  This should be fixed so that -main
*optionally* inserts an empty main(), e.g., as a weak symbol, or
whatever, so that the existence of a real main() doesn't cause a linker
error.


> 3/ it still isn't possible to run the unit tests of several modules in
> one go by passing a list of modules to the compiler (in the same way
> you can compile several modules in one go and generate an object file
> for all of them at once).

Of course you can.  Under my proposal:

	dmd -unittest=module -i -run mod1.d mod2.d mod3.d main.d


T

-- 
Democracy: The triumph of popularity over principle. -- C.Bond


More information about the Digitalmars-d mailing list