Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 13, 2020 DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
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. |
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to novice3 | 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.
Is there a reason you need to run all unittests every time you want to run the program?
I personally compile with -unittest to make sure all my unittests pass, then recompile without the -unittest flag if I actually want to run the program. This way, time isn't wasted running unittests every time the program is run.
|
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan | On Thursday, 13 August 2020 at 08:30:44 UTC, Jonathan wrote:
> Is there a reason you need to run all unittests every time you want to run the program?
App will be used by other peoples,
and i will release it after developing without unittests.
Release is rare action for me.
Running while developing is frequent action.
I want see is all ok - unittests and main{} - for every test run while develop whithout special efforts from me.
Then release with some efforts (compile without "-unittest", with "-release" switch etc).
|
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to novice3 | 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" ];
|
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan | On Thursday, 13 August 2020 at 08:30:44 UTC, Jonathan wrote:
> Is there a reason you need to run all unittests every time you want to run the program?
Starting app with unittests while develop - frequent event for me.
Releasing app - rare event for me.
I want do frequent action without efforts (just start and see all ok - unitests and main),
and can do rare action (release) with some efforts (compile with other switches).
|
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to WebFreak001 | On Thursday, 13 August 2020 at 08:49:21 UTC, WebFreak001 wrote:
> Try
>
> version (unittest) extern(C) __gshared string[] rt_options = ["testmode=run-main" ];
Thanks! It works as needed.
|
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to WebFreak001 | 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.
|
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nils Lankila | On Thursday, 13 August 2020 at 09:02:28 UTC, Nils Lankila wrote:
> programmatically, in a way it is already, but by calling function
Better with compiler switch, may be...
|
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nils Lankila | 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 |
August 13, 2020 Re: DMD: how to restore old unittest+main | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan | On Thu, Aug 13, 2020 at 08:30:44AM +0000, Jonathan via Digitalmars-d-learn wrote: [...] > Is there a reason you need to run all unittests every time you want to run the program? During development, this is a valuable time-saver: instead of compiling twice, once with -unittest and once without, then running each individually, it helps to have unittests run before main() so that any regressions are immediately noticed, and if unittests pass, then main() runs and manual testing can proceed. Obviously, for release builds unittests are useless, so in that case there's no need to include unittests before running main(). > I personally compile with -unittest to make sure all my unittests pass, then recompile without the -unittest flag if I actually want to run the program. This way, time isn't wasted running unittests every time the program is run. Lots of time is wasted if you have to compile twice, once with -unittest and once without, while you're in the code-compile-test cycle and need to run main() for manual testing. (Not everything is testable with unittests!) T -- "Holy war is an oxymoron." -- Lazarus Long |
Copyright © 1999-2021 by the D Language Foundation