Repository navigation
Add unit tests infrastructure - #95
Conversation
In contrast with the existing integration/regression tests, it will enable more fine-grained testing of components.
We cannot link the unit_tests executable against the dynamic library target since most of the symbols (i.e. functions) we wish to test are not part of the dynamic library API and hence are hidden by visibility specification. To circumvent this issue we introduce an internal 'core' STATIC library that allows us to share code and dependencies between executable targets.
Ad above, just providing a static library as a dependency of a dynamic library runs into an issue that there are no "extra" sources in the dynamic library target. CMake complains about lack of sources in that case :-/ |
|
thanks @Mikolaj-A-Kowalski this will be extremely useful for the |
jatkinson1000
left a comment
There was a problem hiding this comment.
This seems sensible to me @Mikolaj-A-Kowalski and happy for merge.
Given the small source size I think a double compile is acceptable for now, and allows for a smoother integration with existing tests(?).
Happy for you to leave the dummy test for now and remove in a subsequent PR.
I see the building of unit tests is done, but are unit tests also included in the running (via ctest or similar)? Yes I think so, my CMake was a little fuzzy!
NetCDF and Zoltan are already a dependency of the internal static library and do not need to be attached to its consumers.
Doctest headers are already provided by the dependency on the doctest target.
Adds a skeleton (for now basically empty) to enable unit testing.
Developing the tripolar functionality I have found myself in want of being able to test the components of the algorithm (utility functions basically). The existing /integration/regression test suite is not really fit for that purpose.
Since the
testfolder is busy as it is I though it will be cleaner to put unit tests in a separate directory.Naturally things refuse to be easy and there is a complication related to how we compile the project.
We cannot link the
unit_testsexecutable against the shared library target because most of the functions that we wish to test are not part of the library's public API and hence are compiled with "hidden" visibility. As the result, if we try to use them in tests, this results in linking errors (symbols not being found due to visibility).The solution at the moment is to introduce a 2nd, static library, which we can use to collect all sources, include directories and dependencies and feed them when compiling executables (
decomptool andunit_testsfor the moment).To discuss in review
-fPICat the moment, but it is not something we need to do)