Should unittests run as logical part of compilation?

Steven Schveighoffer schveiguy at yahoo.com
Sun Jan 26 12:43:39 PST 2014


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.

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.

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.

-Steve


More information about the Digitalmars-d mailing list