www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - -unittest and main

reply Bill Baxter <dnewsgroup billbaxter.com> writes:
I find it inconvenient that -unittest doesn't automatically supply a 
main() if there isn't one.  For instance if I just want to test one 
module of my library I end up going into the code, adding "void 
main(){}" and then "dmd -unittest -run module" then go back and remove 
the "void main(){}" line.

Ideally dmd would just realize that if there's no main and I'm doing 
-unittest, it should add one for me.

Second best would be a -main flag that says 'create a trivial main for 
me' so I could say  "dmd -unittest -main -run module".

Is there some other way to do this that I'm missing?

--bb
Nov 07 2006
parent Chris Nicholson-Sauls <ibisbasenji gmail.com> writes:
Bill Baxter wrote:
 I find it inconvenient that -unittest doesn't automatically supply a 
 main() if there isn't one.  For instance if I just want to test one 
 module of my library I end up going into the code, adding "void 
 main(){}" and then "dmd -unittest -run module" then go back and remove 
 the "void main(){}" line.
 
 Ideally dmd would just realize that if there's no main and I'm doing 
 -unittest, it should add one for me.
 
 Second best would be a -main flag that says 'create a trivial main for 
 me' so I could say  "dmd -unittest -main -run module".
 
 Is there some other way to do this that I'm missing?
 
 --bb
None that I haven't missed as well. Some of us have been wanting a feature like your '-main' switch for some time now. (Or at the very least for -unittest to implicitly behave this way.) -- Chris Nicholson-Sauls
Nov 07 2006