Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass argument from ctest to gtest

I am using gtest to write unit tests for my application. I also have ctest that runs all executables added by add_test CMake command. Is it possible to pass gtest variables through ctest when test execution starts?

I would like to for example sometimes filter out tests with --gtest_filter flag but I don't know how or if this is even possible through ctest? I have tried the following ways:

ctest --gtest_filter=AppTest.*
ctest --test-arguments="--gtest_filter=AppTest.*"

But both still run all tests instead the filtered ones.

Thanks!

like image 751
drodil Avatar asked Oct 31 '17 12:10

drodil


2 Answers

For example, to make tests' output verbose:

$ make test ARGS="-V"

To run a particular test:

$ ctest -R <regex>

NB: You can have a look at this for some examples.

like image 158
Misha Tavkhelidze Avatar answered Sep 25 '22 12:09

Misha Tavkhelidze


Take a look at CMakes's add_test add_test.

To filter out tests from CTest you can use -L ctest

like image 43
Th. Thielemann Avatar answered Sep 26 '22 12:09

Th. Thielemann