How to force run a disabled test from ctest?

Viewed 37

I have a c++ project that leverages cmake, ctest, and gtest.

One of my tests needs to be disabled for the purposes of regressions, but I would like to run it manually.

I disabled it by using the gtest trick of naming the test DISABLED_test_name.

When I try to run it, I see the following:

$ ctest -R aie2_210a_ddr_2kernel_ddr_gmio_bd_api.maize_xrt --verbose
UpdateCTestConfiguration  from :/scratch/bryanloz/aie_controller_hax/test/build/DartConfiguration.tcl
Parse Config file:/scratch/bryanloz/aie_controller_hax/test/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/scratch/bryanloz/aie_controller_hax/test/build/DartConfiguration.tcl
Parse Config file:/scratch/bryanloz/aie_controller_hax/test/build/DartConfiguration.tcl
Test project /scratch/bryanloz/aie_controller_hax/test/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 8
    Start 8: aie2_210a_ddr_2kernel_ddr_gmio_bd_api.maize_xrt
1/1 Test #8: aie2_210a_ddr_2kernel_ddr_gmio_bd_api.maize_xrt ...***Not Run (Disabled)   0.00 sec
No tests were found!!!

How do I override this behavior?

1 Answers

You can use --gtest_also_run_disabled_tests. This command line flag forcibly runs all the DISABLED_ tests.

Note that if you have multiple disabled tests and you only want to enable one of them using the command line, you can combine this flag with --gtest_filter.

Edit for CTest:

I am not familiar with CTest, but apparently there is not an easy way to pass command-line arguments in CTest at runtime. Maybe you can use this workaround to do so, or find the executable and pass the argument to it directly See this answer.

As an alternative to passing the command line argument, you can set the GTEST_ALSO_RUN_DISABLED_TESTS environment variable to a value other than 0. See this.

Related