Can we get unitests to not run with program start ?

Basile B. via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 26 01:15:44 PDT 2016


On Wednesday, 26 October 2016 at 05:24:45 UTC, deadalnix wrote:
> Seriously that makes no sense, almost everybody has it own hack 
> to have a different main when building for unitests, and we 
> look like clown.
> [...]
> Can I have my unittest build do not complain if there is no 
> main and not run main ?

What would be possible is a "-fdmain" switch (force dummy main). 
Its role would be: if a functionDeclaration named "main" is 
present then this normal "main" is not used (technically erased 
from the AST or something like that). Then acts like "-main".

If I understand correctly the real problem happens when modules 
have to be tested but the real program "main()" must be skipped. 
All the other scenarios can be handled easily. For example an IDE 
can lookup in the AST and automatically add "-main" when the 
"main" declaration misses (and obviously if "-unittest" is 
defined).


More information about the Digitalmars-d mailing list