How can one reliably run unittests
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Aug 25 22:48:15 UTC 2021
On Wed, Aug 25, 2021 at 03:44:40PM -0700, Walter Bright via Digitalmars-d wrote:
> On 8/25/2021 2:05 PM, Paul Backus wrote:
> > The problem with -main is that it's too blunt an instrument: it will
> > add a main function whether the code you're compiling already has
> > one or not. That means you have to keep track of which modules have
> > main functions and which ones don't, so that you (or more
> > realistically, your build system) can add -main only when it's
> > necessary.
>
> That problem has never occurred to me, and has never happened to me,
> yet I use -main all the time.
>
> One way to resolve it is just put your main() in a separate module.
This always happens to me, so much so that I've come to insert the
following as boilerplate to all my code:
version(unittest){} else
int main(string[] args) { ... }
T
--
LINUX = Lousy Interface for Nefarious Unix Xenophobes.
More information about the Digitalmars-d
mailing list