ctest - Serbipunk/notes GitHub Wiki
$ cd $BUILD_DIR
$ ctest --verbose .
...
14: Test command: /home/liam/ilab-makeup-transfer-sdk/cmake-build-release/modules/ilab-makeup-transfer-sdk-face3dmesh/ilab-makeup-transfer-sdk-face3dmesh-test "MultiLinearVideoReconstructor::UpdateExpressDim" "--reporter JUnit" "--out /home/liam/ilab-makeup-transfer-sdk/cmake-build-release/modules/ilab-makeup-transfer-sdk-face3dmesh/JUNIT-MultiLinearVideoReconstructor__UpdateExpressDim.xml"
14: Working Directory: /home/liam/ilab-makeup-transfer-sdk/cmake-build-release/modules/ilab-makeup-transfer-sdk-face3dmesh
14: Test timeout computed to be: 1500 14/43 Test #14: MultiLinearVideoReconstructor::UpdateExpressDim ...***Failed 0.09 sec
To see the list of test cases or configuration details with ctest
, you can use the following commands:
-
List all test cases:
ctest -N
This will print the names of all the test cases without executing them.
-
List tests with more details:
ctest -N --verbose
This command gives detailed information about each test, including how each test is configured and additional information if available.
-
List configuration and available options:
-
From the build directory:
cat CMakeCache.txt
This file contains configuration information about the CMake project, which
ctest
uses for its tests. -
Direct CMake test list: You can also query tests directly from CMake if you’re in a CMake project:
cmake --build . --target help
This will show the available targets, including testing-related ones.
-
-
See configuration variables in ctest:
ctest --print-labels
This prints labels associated with tests, often helpful for filtering or organizing test cases.
Let me know if you need further details about any of these steps!
Sure! Here's the translated version:
To run a specific test case via the command line, you can use the following methods:
ctest -R <test_name>
The -R
flag matches tests whose names contain <test_name>
.
Example:
ctest -R MyTestCase
This will run all tests with names that include MyTestCase
.
ctest -I <start_index>,<end_index>,<stride>
Example:
ctest -I 3,3
This command runs only the third test (indexes start from 1).
If your tests are defined with labels, you can run them using the -L
option:
ctest -L <label_name>
Example:
ctest -L integration
This command runs all tests labeled with integration
.
To see detailed logs while running a specific test, use the --verbose
option:
ctest -R MyTestCase --verbose
If you know the path to the test executable, you can run it directly:
./path/to/test_executable --gtest_filter=<TestName>
Example:
./tests/my_test --gtest_filter=MyTestCase.*
This is particularly useful for projects using the Google Test framework.