| Thread overview | |||||
|---|---|---|---|---|---|
|
November 14, 2013 Only run code if *not* unittesting | ||||
|---|---|---|---|---|
| ||||
Hey there, So I'd like to limit code execution in my main function to only execute if I haven't passed the --unittest flag during compilation. Is this possible? | ||||
November 14, 2013 Re: Only run code if *not* unittesting | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jared | There's a version(unittest), so
version(unittest)
{}
else
{
/* only run when unittesting */
}
should work for you.
| |||
November 14, 2013 Re: Only run code if *not* unittesting | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Thursday, 14 November 2013 at 21:02:21 UTC, Adam D. Ruppe wrote:
> There's a version(unittest), so
>
> version(unittest)
> {}
> else
> {
> /* only run when unittesting */
> }
>
> should work for you.
That worked... except backwards:
version(unittest) {
/* executed when --unittest flag used */
} else {
/* executed all other times */
}
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply