Does "dub test" run tests?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 20 00:58:09 PDT 2017


On Monday, March 20, 2017 07:51:09 Russel Winder via Digitalmars-d-learn 
wrote:
> I have a Meson build for a D program project with a single main.d file
> that has some unit tests. Both executable and test executable are
> created and work as expected.
>
> I created a minimal Dub file for this project. Using Dub the program
> runs as expected. However when I run "dub test" it claims to be running
> "dub -b unittest" and then proceeds to run the program not the tests.
>
> In main.d I have:
>
>     ... some most excellent D code …
>
>     version(unittest) {
>       ... the unit tests ...
>     }
>     else {
>       ... the application main ...
>     }
>
> so whilst the Meson/Ninja "ldc2 -unittest --main" thing works fine, Dub
> doesn't do the right thing. Or more likely I am just missing something
> obvious.

I haven't spent the time to dig in and report it properly, but based on some
of what I saw recently on a project I have, the module with main in it
didn't have its tests run, as if dub's didn't compile it when compiling the
unit tests. The tests in the other modules were definitely run though. So, I
think that dub probably does have a bug with regards to how it handles the
module with main in it.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list