unit test broken [DUB bug?]

Steven Schveighoffer schveiguy at gmail.com
Mon Dec 13 20:50:04 UTC 2021


On 12/12/21 12:54 AM, Chris Katko wrote:
> Running 64-bit Linux
> ```
> dmd --version
> DMD64 D Compiler v2.098.0-beta.2
> 
> dub --version
> DUB version 1.27.0-beta.2, built on Sep  7 2021
> ```
> 
> the following code 'compiles' in one project.
> 
> ```d
> unittest
> {
> gasdindgaslkdgansklnasgdlknaglkgansklsdg;
> }
> 
> void main(){} // compiles, links, and 'runs unit tests'
> ```
> 
> dub
> [shows compiling, linking, then runs]
> 
> dub test
> 
> ```
> Running dfile-test-library
> All unit tests have been run successfully.
> ```
> 

`dub test` adds its own main file, and removes yours. So essentially, 
it's not building your app.d file at all.

`dub test` is a utility used to test libraries, which typically do not 
have a main function. It's definitely suspect for dub to do this, and 
it's based on historical baggage.

To test an application with dub, use `dub -b unittest`, which builds the 
application the same as always, just with the `-unittest` switch.

-Steve


More information about the Digitalmars-d-learn mailing list