-unittest doesn't work when linking against shared libraries

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 8 15:45:29 UTC 2017


On 12/7/17 9:15 PM, Jonathan M Davis wrote:
> On Thursday, December 07, 2017 14:34:01 Timothee Cour via Digitalmars-d
> wrote:
>> I have a simple test case to reproduce in
>> https://issues.dlang.org/show_bug.cgi?id=18046
>> this seems like a serious bug; what would be a workaround when dealing
>> with shared libraries?
> 
> If you're trying to unit test a shared library, I'd suggest just turning it
> into a static library for the tests. Alternatively, you can write the unit
> tests in an application that links against the shared library, but that
> means separating the tests from the code, which isn't ideal.

I think you misunderstand. If there is a shared library being linked 
against, then the tests in your application don't run (see the bug 
report). Definitely a serious bug. I would be interested how they work 
on Linux with shared libraries, maybe it's a mac thing.

I think this has to do with which library initializes the runtime first.

However, I think this is supposed to work, as the code clearly has 
references to dealing with multiple sections of moduleinfo.

-Steve


More information about the Digitalmars-d mailing list