How can one reliably run unittests
deadalnix
deadalnix at gmail.com
Tue Aug 24 17:45:20 UTC 2021
On Tuesday, 24 August 2021 at 15:54:25 UTC, Joseph Rushton
Wakeling wrote:
> That particular problem has a well known workaround -- prepend
> the `main` function with `version` statements to exclude it
> from `unittest` builds:
>
> ```D
> version (unittest) {} else
> void main ()
> {
> ...
> }
> ```
>
> Obviously that assumes you control all the codebases that
> define a `main`, and it doesn't solve the problem of building
> everything twice, but it should cover a lot of use-cases.
True, and I'm sure that with an endless bag of trick, this could
be made to work. this is missing the point, though.
The compiler KNOWS if there is a main or not. The compiler KNOWS
if I want unittests or not. Yet it's going to do retarded stuff
unless one uses a bunch of workarounds.
It's like we have this car, the engine works, the break are in
order and so on, except the steering wheel is at the back seat
and everybody tells you that you can still drive by passing your
head through the window and look forward this way.
This just doesn't make sense.
More information about the Digitalmars-d
mailing list