Should unittests run as logical part of compilation?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Jan 26 20:02:29 PST 2014


On 1/26/14 12:43 PM, Steven Schveighoffer wrote:
> On Sat, 25 Jan 2014 17:55:30 -0500, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> What do you think? Logistically it shouldn't be too hard to arrange
>> things to cater to this approach.
>
> After reading other opinions, this is what I think:
>
> 1. unit tests should be built as a separate binary. So when you build
> foo with -unittest, you get foo_unittest in addition to foo.
> 2. If you want to run unit tests, run foo_unittest. If you want simply
> the program, run foo.

Makes sense, though we could massage the unittests into the executable.

> I don't see a huge need for having unit tests run before the normal
> program. But maybe we should add a switch to make that work.

Guess we'd need to keep things running as they do for backwards 
compatibility.

> Building and running it as part of compilation seems like an incorrect
> function of the compiler. This is best left to an IDE/build script.
> Also, building unit tests still needs to be opt-in. Some projects can
> take a long time to build unit tests (dcollections takes about 20x
> longer to compile unit tests, last time I checked), and a quick
> compile-test-debug cycle is a key feature of D.

Yah it should be all nicely controllable by the build system.


Andrei




More information about the Digitalmars-d mailing list