Named unittests

H. S. Teoh hsteoh at quickfur.ath.cx
Sat May 18 15:32:32 UTC 2019


On Sat, May 18, 2019 at 10:56:16AM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> On 5/18/19 2:20 PM, Adam D. Ruppe wrote:
[...]
> > Actually, right after I went to bed, I realized the solution to
> > everyone's problem.
> > 
> > We all want `-unittest=package,list` to control which tests are run.
> 
> Doesn't that seem a bit much? It seems to me you either want to run
> unittests or not, why run just a few? Going with the typechecking
> metaphor - do we want to check some modules but not others?

This is actually one of the big warts in D's otherwise very nice
built-in unittests: when you compile with -unittest, it compiles ALL
unittests, including those of 3rd party libraries that you really don't
care about.  You *really* want to be able to say "hey, compile *my*
unittests, which are in modules X, Y, Z, and don't bother with
everything else, 'cos they are external code that have already been
unittested to death".  I'm really *not* interested in running Phobos
unittests for the 100th time which the CI's have already run 1000 times
over, every single darned time I compile my own code!


> If including/excluding certain unittests is needed e.g. for time
> reasons, "version" seems the right tool for the job. Or compiling some
> modules with -unittest and others without. But that should be the
> special case, not something supported at the command line level.
[...]

Wrong. Compiling with -unittest currently compiles unittests for ALL
imports.  Meaning, (practically) all Phobos unittests get compiled and
run as soon as you have the audacity to `import std.xyz` (Phobos being
the tangled hairball of dependencies that it is right now).  Using
"version" is really not practical since I'd have to modify Phobos code
everytime I compile my own code and/or have knowledge of Phobos internal
details such as version identifiers to turn unittests on/off.

This isn't just Phobos, of course, but any 3rd party library the code
may depend on. I shouldn't have to know secret magic version identifiers
for every single 3rd party library I use just so I can turn off their
unittests!

Far from being the special case, this should be the *default* behaviour:
nobody wants to recompile and rerun 3rd party unittests for the 100th
time which the upstream authors should already have done; they want to
unittest their *own* code.


T

-- 
Too many people have open minds but closed eyes.


More information about the Digitalmars-d mailing list