How can one reliably run unittests
jfondren
julian.fondren at gmail.com
Thu Aug 26 23:46:00 UTC 2021
On Thursday, 26 August 2021 at 23:29:20 UTC, Dennis wrote:
> On Thursday, 26 August 2021 at 09:38:54 UTC, deadalnix wrote:
>> But having main declared twice is some special level of
>> nonsense. In what case could I possibly want two main?
>
> When there's both a main function and the `-main` flag, should
> `-main` do nothing or override the main function with an empty
> one?
In the -unittest usage, and without some code overriding the
runtime's testrunner, these are equivalent outcomes since dmd no
longer runs main after unittests:
```d
import std.stdio;
unittest { writeln("unittest"); }
void main() { writeln("main"); }
```
contrast:
```
$ dmd -unittest -run ignoremain.d
unittest
1 modules passed unittests
$ gdc -funittest -o not-ignored ignoremain.d
$ ./not-ignored
unittest
main
```
More information about the Digitalmars-d
mailing list