How do you work with unittest libraries in dub packages?

Christian Köstlin christian.koestlin at gmail.com
Tue Apr 4 21:07:15 UTC 2023


Recently Dmytro Katyukha brought up an issue in one of my dub packages
that is supposed to be used as a library. He even went the whole way and
came up with a simple reduced example: 
https://gitlab.com/gizmomogwai/colored/-/merge_requests/3#note_1341026928.

The problem here is, that my dub package uses unit_threaded in the
unittest configuration, and only imports unit_threaded in a `version 
(unittest)` block. Previously I imported unit_threaded only in the 
individual testfunctions themselves, but I thought to reduce some typing.

When my library is now used in another project (that does not depend on 
unit_threaded) `dub test` seems to still compile my library with the 
unittest version, but it would not run the unittests of my library. So 
in the end `dub test` fails for the dependent project (as it is not 
providing unit_threaded).

Is this behavior expected?
What would be best practice to work around that?

Kind regards,
Christian


More information about the Digitalmars-d-learn mailing list