Unittesting in static libraries
Steven Schveighoffer
schveiguy at yahoo.com
Mon Sep 19 03:55:08 PDT 2011
On Sat, 17 Sep 2011 01:34:35 -0400, Rainer Schuetze <r.sagitario at gmx.de>
wrote:
> I think the main issue here is that a module that is compiled to a
> library, is split into a lot of small "object files" (one for each
> function or global variable) before being combined to the library. This
> allows the linker to just take the actually referenced parts and leave
> out anything that is never called.
>
> The unit tests are only referenced from the module info, so it might
> work if you have a reference to it in your main executable.
> Another workaround would be to build the library in two steps, compiling
> to normal object files first, then binding these to a library (shameless
> ad: "separate compile and link" in Visual D):
>
> dmd -unittest -c -od. test1.d test2.d
> dmd -lib -oftest.lib test1.obj test1.obj
>
> so it avoids breaking up the modules. the -od. is needed to not just
> build a single object file.
The output from these lines should be identical to:
dmd -unittest -oftest.lib -lib test1.d test2.d
If it's not, that's a bug.
-Steve
More information about the Digitalmars-d
mailing list