DMD: how to restore old unittest+main

Steven Schveighoffer schveiguy at gmail.com
Thu Aug 13 14:46:45 UTC 2020


On 8/13/20 5:02 AM, Nils Lankila wrote:
> On Thursday, 13 August 2020 at 08:49:21 UTC, WebFreak001 wrote:
>> On Thursday, 13 August 2020 at 07:52:07 UTC, novice3 wrote:
>>> Hello.
>>>
>>> I don't use dub.
>>> I use Windows and *.d file association to compile small apps by dmd 
>>> with "-i -unittest -g" switches.
>>> Now i update dmd, and found, that apps compiled with "-unittest" not 
>>> runs main().
>>>
>>> How i can restore old behaviour (run all unittests then main())
>>> *without use "--DRT-testmode=run-main" switch every time then i start 
>>> compiled app.exe*?
>>> I want just press Enter on app.d file, then press Enter on app.exe.
>>> Any advises?
>>>
>>> Thanks.
>>
>> Try
>>
>> version (unittest) extern(C) __gshared string[] rt_options = [ 
>> "testmode=run-main" ];
> 
> Yeah that works but we should really have a way to do this 
> programmatically, in a way it is already, but by calling function, not 
> by the bias of a string that get parsed.

https://dlang.org/phobos/core_runtime.html#.Runtime.extendedModuleUnitTester

Though I highly recommend using the rt_options mechanism if all you are 
after is the original behavior, it's much simpler.

-Steve


More information about the Digitalmars-d-learn mailing list