Named constructors

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jan 10 18:49:35 UTC 2019


On Thu, Jan 10, 2019 at 06:29:27PM +0000, Atila Neves via Digitalmars-d wrote:
> On Thursday, 10 January 2019 at 16:33:51 UTC, H. S. Teoh wrote:
[...]
> > Recently I've started to compile unittests separately from the final
> > executable. The default behaviour of running unittests before main()
> > is nice for one-off scripts and short-term projects, but for serious
> > code I'm finding more and more that it makes more sense to compile
> > and run unittests separately.  I haven't gotten to the point of
> > evading linker tax, though.
> > 
> > But I surmise it should be relatively easy to just compile modules
> > separately with -unittest -run, using -i to automatically pick up
> > imports. Put this in a test target in your build script and have the
> > tests built and run incrementally. Not sure how much time will be
> > saved, due to -i potentially causing the same tests to run multiple
> > times. I should try this out on one of my larger projects to see how
> > it does.
[...]
> I _only_ build unit tests apart from the production code now. I'm
> toying with not using `unittest` at all since I can reflect and find
> tests on my own, and I don't have to pay the compile time tax of
> importing a phobos module with `-unittest`.

The last time somebody looked, the real problem wasn't that Phobos (or
any 3rd party library) unittests were being compiled over and over; it
was caused by a change in template instantiation behaviour when
-unittest is specified, such that many more templates are instantiated
that probably don't need to be, thus causing the observed compile-time
spike.  There's a reason it was done this way, but I'm here gnashing my
teeth wishing that there was a way to turn off this annoying behaviour.


T

-- 
Why waste time learning, when ignorance is instantaneous? -- Hobbes, from Calvin & Hobbes


More information about the Digitalmars-d mailing list