CTest
This page outlines how the Launchable CLI interfaces with CTest.
This is a reference page. See Getting started, Sending data to Launchable, and Subsetting your test runs for more comprehensive usage guidelines.

Recording test results

After running tests, point the CLI to your test report files to collect test results and train the model:
1
launchable record tests --build <BUILD NAME> ctest Testing/**/Test.xml
Copied!
You might need to take extra steps to make sure that launchable record tests always runs even if the build fails. See Always record tests.

Subsetting your test runs

The high level flow for subsetting is:
    1.
    Get the full list of tests/test paths and pass that to launchable subset
    with an optimization target for the subset
    2.
    launchable subset will get a subset from the Launchable platform and output
    that list to text files
    3.
    Pass the text files into your test runner to run only those tests
To retrieve a subset of tests, first list all the tests you would normally run and pass that to launchable subset:
1
# --show-only=json-v1 option outputs test list as JSON
2
ctest --show-only=json-v1 > test_list.json
3
launchable subset \
4
--build <BUILD NAME> \
5
--confidence <TARGET> \
6
--output-regex-files \
7
--output-regex-files-dir=subsets \
8
ctest test_list.json
Copied!
    The --build should use the same <BUILD NAME> value that you used before in
    launchable record build.
    The --confidence option should be a percentage; we suggest 90% to start.
    You can also use --time or --target; see [Subsetting your test
    runs](../../actions/subsetting-your-test-runs.md) for more info.
    The --output-regex-files instructs CLI to write the regular expression for
    the subset tests into the directory specified in --output-regex-files-dir.
This creates files under the subsets directory. There are two sets of files. subset_N are the files that contain regular expressions of the chosen subset of tests. rest_N are the files for non-chosen tests.
1
# run the tests
2
for file in subset/subset_*; do
3
ctest -T test --no-compress-output -R "$(cat "$file")"
4
done
Copied!

Obsolete usage

CTest has a size limit on the regular expression used for specifying which tests to run (-R argument in ctest). This causes an issue when running subsets. To address this issue, the CLI learned to split the regular expression into multiple files. The following usage is now obsolete. Please migrate to the new usage described above.
To retrieve a subset of tests, first list all the tests you would normally run and pass that to launchable subset:
1
# --show-only=json-v1 option outputs test list as JSON
2
ctest --show-only=json-v1 > test_list.json
3
launchable subset \
4
--build <BUILD NAME> \
5
--confidence <TARGET> \
6
ctest test_list.json > launchable-subset.txt
Copied!
    The --build should use the same <BUILD NAME> value that you used before in launchable record build.
    The --confidence option should be a percentage; we suggest 90% to start. You can also use --time or --target; see Subsetting your test runs for more info.
This creates a file called launchable-subset.txt that you can pass into your command to run tests:
1
# run the tests
2
ctest -T test --no-compress-output -R $(cat launchable-subset.txt)
Copied!
Last modified 14d ago