www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Run only "unittest", skip "main"

reply "tcak" <tcak gmail.com> writes:
Is there any way to run only unittest codes, and ignore main 
function?

DMD is running both of them when I use -unittest.
Jan 24 2015
parent reply "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Sat, Jan 24, 2015 at 06:15:29PM +0000, tcak via Digitalmars-d-learn wrote:
 Is there any way to run only unittest codes, and ignore main function?
 
 DMD is running both of them when I use -unittest.
version(unittest) { void main() {} } else { void main() { /* real main code here */ } } T -- The volume of a pizza of thickness a and radius z can be described by the following formula: pi zz a. -- Wouter Verhelst
Jan 24 2015
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Sat, 24 Jan 2015 10:52:26 -0800, H. S. Teoh via Digitalmars-d-learn
wrote:

 On Sat, Jan 24, 2015 at 06:15:29PM +0000, tcak via Digitalmars-d-learn
 wrote:
 Is there any way to run only unittest codes, and ignore main function?
=20
 DMD is running both of them when I use -unittest.
=20 version(unittest) { void main() {} } else { void main() { /* real main code here */ } }
real PITA and uglyness, btw.=
Jan 24 2015
parent reply "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Sat, Jan 24, 2015 at 07:02:35PM +0000, ketmar via Digitalmars-d-learn wrote:
 On Sat, 24 Jan 2015 10:52:26 -0800, H. S. Teoh via Digitalmars-d-learn
 wrote:
 
 On Sat, Jan 24, 2015 at 06:15:29PM +0000, tcak via Digitalmars-d-learn
 wrote:
 Is there any way to run only unittest codes, and ignore main
 function?
 
 DMD is running both of them when I use -unittest.
version(unittest) { void main() {} } else { void main() { /* real main code here */ } }
real PITA and uglyness, btw.
I know. One idea is to make `-main` automatically suppress any user-defined main, then you can compile with `dmd -main -unittest` to make it only run unittests. But I don't know if the dmd devs will approve of that... T -- The irony is that Bill Gates claims to be making a stable operating system and Linus Torvalds claims to be trying to take over the world. -- Anonymous
Jan 24 2015
parent ketmar <ketmar ketmar.no-ip.org> writes:
On Sat, 24 Jan 2015 11:11:35 -0800, H. S. Teoh via Digitalmars-d-learn
wrote:

 On Sat, Jan 24, 2015 at 07:02:35PM +0000, ketmar via Digitalmars-d-learn
 wrote:
 On Sat, 24 Jan 2015 10:52:26 -0800, H. S. Teoh via Digitalmars-d-learn
 wrote:
=20
 On Sat, Jan 24, 2015 at 06:15:29PM +0000, tcak via
 Digitalmars-d-learn wrote:
 Is there any way to run only unittest codes, and ignore main
 function?
=20
 DMD is running both of them when I use -unittest.
=20 version(unittest) { void main() {} } else { void main() { /* real main code here */ } }
=20 real PITA and uglyness, btw.
=20 I know. =20 One idea is to make `-main` automatically suppress any user-defined main, then you can compile with `dmd -main -unittest` to make it only run unittests. =20 But I don't know if the dmd devs will approve of that...
that would be very handy. i completely forgot about '-main' key for dmd.=20 thank you, now i gone creating another nice patch. ;-)=
Jan 24 2015