On Mon, Feb 5, 2018, at 22:15 CST, Weixiong Zheng <[email protected]> wrote:
> Hello All,
>
> I am trying to get unit test work for my project. It works until reaching
> the point of reading input data. I tried to specify the directory using
> getcwd() though it didn't work with ctest. I noticed there was another user
> having the same issue and the resolution was to use SOURCE_DIR directly in
> *.cc file. It turns out it was not recognized. Any quick idea how to fix it
> would be appreciated. Thanks!
SOURCE_DIR is defined when compiling the *.cc file of a test [1]. For
example, if you have the test layout
my_test.cc
my_test.output
and you call DEAL_II_PICKUP_TESTS() in that subdirectory. In that case
the my_test.cc file will be compiled with a compiler flag similar to
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
It is not available in any other compilation unit (i.e. *.cc file). Or
for the second class of tests where you specify a *.prm file [2].
Best,
Matthias
[1] The SOURCE_DIR preprocessor definition is set up in line 266 of the
macro cmake/macros/macro_deal_ii_add_test.cmake.
[2] In this case a test gets the full path to the parameter file as
first argument. So simply stripping of the filename should be enough to
get the source directory of the tests.
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.