ctest - Serbipunk/notes GitHub Wiki

run all

$ 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

list and config

To see the list of test cases or configuration details with ctest, you can use the following commands:

  1. List all test cases:

    ctest -N

    This will print the names of all the test cases without executing them.

  2. 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.

  3. 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.

  4. 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!

run a specific case

Sure! Here's the translated version:


To run a specific test case via the command line, you can use the following methods:

1. Run a test by name:

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.

2. Run a test by index:

ctest -I <start_index>,<end_index>,<stride>

Example:

ctest -I 3,3

This command runs only the third test (indexes start from 1).

3. Run tests with specific labels:

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.

4. Enable verbose output for detailed logs:

To see detailed logs while running a specific test, use the --verbose option:

ctest -R MyTestCase --verbose

5. Directly run a test executable:

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.

⚠️ **GitHub.com Fallback** ⚠️