DUB "Error: only one `main` allowed."

tastyminerals tastyminerals at gmail.com
Wed Aug 11 14:08:58 UTC 2021


On Wednesday, 11 August 2021 at 11:44:42 UTC, Steven 
Schveighoffer wrote:
> On 8/11/21 5:31 AM, tastyminerals wrote:
>> [...]
>
> `dub -b unittest` should work (you don't need the extra build 
> type stuff)
>
> dub test does something funky -- it removes the *whole module* 
> where your main function is (if you identify it, or if it's 
> `app.d`) and then builds its own main module. Why does it do 
> this? Legacy reasons, the runtime used to run main after 
> running unittests, which dub didn't want to do. It also is 
> useful on a library where there is no main function.
>
> However, dub with a build type of `unittest` just enables the 
> unittest switch, and builds all your stuff as normal.
>
> -Steve

I see. Thank you for a detailed answer! I just with this was 
somehow reflected in the DUB docs...


More information about the Digitalmars-d-learn mailing list