Beta 2.090.0

Steven Schveighoffer schveiguy at gmail.com
Sun Dec 22 23:05:20 UTC 2019


On 12/22/19 5:22 PM, Per Nordlöw wrote:
> On Sunday, 22 December 2019 at 15:23:32 UTC, Martin Nowak wrote:
>> Glad to announce the first beta for the 2.090.0 release, ♥ to the 48 
>> contributors.
>>
>> http://dlang.org/download.html#dmd_beta
>> http://dlang.org/changelog/2.090.0.html
>>
>> As usual please report any bugs at
>> https://issues.dlang.org
>>
> 
> I've gotten very used to running my app via
> 
>      dub run --compiler=dmd --build=unittest
> 
> in order to, with short iterations, run tests and the application at the 
> same time.
> 
> Changing this behaviour via
> 
> https://dlang.org/changelog/2.090.0.html#unittest-default
> 
> is, to me, an usually disruptive change.

It's a long overdue change IMO. The original intention was to have it 
switched on version 2.080, but I forgot about it. Most of the time, if 
you are unittesting, you aren't building exactly production code, so 
there's no reason to run the main function.

Most people used to do this:

```
version(unittest) void main() {}
else
int main(string[] args) {
    ... // normal application
}
```

Which is somewhat embarrassing for the language to have to do this.

> 
> I tried changing to
> 
>      dub run --compiler=dmd --build=unittest -- --DRT-testmode=run-main
> 
> but it still doesn't run the application after the unittests are run.

The issue is that dub is built with D! So dub is actually consuming that 
option without trying to.

There's an open bug on it: https://github.com/dlang/dub/issues/1280

> Have I missed something or is this a known problem with dub? If so, do I 
> have any alternative to brute-forcing the problem with
> 
>      dub run --compiler=dmd --build=unittest
>      dub run --compiler=dmd --build=debug
> 
> which, for me, doubles my development iteration time.

Option a: don't use dub run.

dub build --compiler=dmd --build=unittest && ./application 
--DRT-testmode=run-main

Option b: you can also set a DRT switch inside your code:

https://dlang.org/phobos/rt_config.html

e.g.:

extern(C) __gshared string[] rt_options = [ "testmode=run-main"];

There are far more people who run unittests as a separate step from 
running their application. If unittests pass, then there's no 
distinguishable output from a build without unittests. I can totally 
imagine accidentally shipping code with unittests in it without 
intending to.

But I can totally see your use case during development. It should work 
with dub run, I hope it gets fixed.

-Steve


More information about the Digitalmars-d-announce mailing list