CTEST(1)

🌸 NAME 🌸

okay so bestie, meet ctest β€” the CMake test driver program, aka the ctest - CTest Command-Line Reference. ✨ She's the one who actually runs your tests and tells you what happened.

πŸŽ€ Contents πŸŽ€

here's the whole map of this page, iykyk πŸ—ΊοΈ

  • ctest(1)
    • Synopsis
    • Description
    • Run Tests
    • View Help
    • Label Matching
    • Label and Subproject Summary
    • Build and Test Mode
    • Dashboard Client
      • Dashboard Client Steps
      • Dashboard Client Modes
      • Dashboard Client via CTest Command-Line
      • Dashboard Client via CTest Script
    • Dashboard Client Configuration
      • CTest Start Step
      • CTest Update Step
      • CTest Configure Step
      • CTest Build Step
      • CTest Test Step
      • CTest Coverage Step
      • CTest MemCheck Step
      • CTest Submit Step
    • Show as JSON Object Model
    • Resource Allocation
      • Resource Specification File
      • RESOURCE_GROUPS Property
      • Environment Variables
      • Dynamically-Generated Resource Specification File
    • Job Server Integration
    • See Also

πŸ’… SYNOPSIS πŸ’…

okay there are like four whole moods here, each with its own shape:

Run Tests

ctest [<options>...] [--test-dir <path-to-build>] [-- <test-args>...]

Build and Test Mode

ctest --build-and-test <path-to-source> <path-to-build>
      --build-generator <generator> [<options>...]
     [--build-options <opts>...]
     [--test-command <command> [<args>...]]

Dashboard Client

ctest -D <dashboard>            [-- <dashboard-options>...]
ctest -M <model> -T <action>    [-- <dashboard-options>...]
ctest [-M <model>] -T Configure --source-dir <path-to-source>
                                [--build-dir <path-to-build>]
                                [-- <dashboard-options>...]
ctest -S <script>               [-- <dashboard-options>...]
ctest -SP <script>              [-- <dashboard-options>...]

View Help

ctest --help[-<topic>]

πŸ¦‹ DESCRIPTION πŸ¦‹

so the ctest executable is literally the CMake test driver program. 🫢 When a build tree gets generated by CMake for a project that uses the enable_testing() and add_test() commands, that tree has testing support baked right in. This program runs those tests and reports the results back to you. iconic behaviour, honestly.


πŸ”₯ RUN TESTS πŸ”₯

ctest runs the tests defined by a CTestTestfile.cmake file β€” which is typically chillin' in a build tree generated by cmake(1):

ctest [<options>...] [--test-dir <path-to-build>] [-- <test-args>...]

if all tests pass, the exit code is 0 β€” slay. πŸ’– the exit code is non-zero in these situations tho:

  • an error occurs, like failing to process invalid arguments. πŸ’€
  • Added in version 4.4: no arguments are given and no CTestTestfile.cmake exists.
  • the --no-tests=error argument is given and no tests are executed β€” e.g. when CTestTestfile.cmake defines no tests, or when the given arguments exclude all the tests.
  • at least one test fails. 😭

the options for running tests are:

  • --preset <preset>, --preset=<preset> β€” use a test preset to specify test options. The project binary directory is inferred from the configurePreset key. πŸŽ€
    • Added in version 3.30: the --test-dir option may be specified with a different binary directory than the one specified by the configurePreset key.
    • Changed in version 4.4: if --presets-file is specified, neither of CMakePresets.json nor CMakeUserPresets.json are required to be present. Otherwise, they are required to be present in the top level source directory. In prior versions, this was strictly required.
  • --presets-file <file>, --presets-file=<file> β€” Added in version 4.4. reads presets from the given <file>. The specified path may be absolute or relative to the current working directory. If --presets-file is given, presets defined in CMakePresets.json and CMakeUserPresets.json will be ignored. ✨
  • --list-presets β€” lists the available test presets. The current working directory must contain CMakePresets.json and/or CMakeUserPresets.json.
    • Changed in version 4.4: if --presets-file is specified, neither of CMakePresets.json nor CMakeUserPresets.json are required to be present, and only presets defined in the given <file> will be listed. Otherwise, they are required to be present in the top level source directory. In prior versions, this was strictly required.
  • -C <cfg>, --build-config <cfg> β€” choose the configuration to test. Some CMake-generated build trees can have multiple build configurations in the same tree, and this option lets you specify which one should be tested. Example configurations are Debug and Release. 🎯
  • --progress β€” enable short progress output from tests. When the output of ctest is being sent directly to a terminal, the progress through the set of tests is reported by updating the same line rather than printing start and end messages for each test on new lines. This can significantly reduce the verbosity of the test output. Test completion messages are still output on their own line for failed tests, and the final test summary will also still be logged. πŸ‘‘ This option can also be enabled by setting the environment variable CTEST_PROGRESS_OUTPUT.
  • -V, --verbose β€” enable verbose output from tests. Test output is normally suppressed and only summary information is displayed, but this option will show all test output. 🫢
  • -VV, --extra-verbose β€” enable more verbose output from tests. Test output is normally suppressed and only summary information is displayed; this option will show even more test output. πŸ”₯
  • --debug β€” displays more verbose internals of CTest. Heads up: this feature will result in a large number of output that is mostly useful for debugging dashboard problems. πŸ™ˆ
  • --output-on-failure β€” output anything outputted by the test program if the test should fail. This option can also be enabled by setting the CTEST_OUTPUT_ON_FAILURE environment variable.
  • --stop-on-failure β€” stop running the tests when the first failure happens. βœ‹
  • -F β€” enable failover. This option allows CTest to resume a test set execution that was previously interrupted. If no interruption occurred, the -F option will have no effect. 🧚
  • -j [<level>], --parallel [<level>] β€” run tests in parallel, optionally limited to a given level of parallelism. Added in version 3.29: the <level> may be omitted, or 0, in which case:
    • under Job Server Integration, parallelism is limited by available job tokens.
    • otherwise, if the value is omitted, parallelism is limited by the number of processors, or 2, whichever is larger.
    • otherwise, if the value is 0, parallelism is unbounded. This option may instead be specified by the CTEST_PARALLEL_LEVEL environment variable β€” see the documentation of that variable for how it interacts with a test preset's jobs field. This option can be used with the PROCESSORS test property. See the Label and Subproject Summary.
  • --resource-spec-file <file> β€” run CTest with resource allocation enabled, using the resource specification file specified in <file>. When ctest is run as a Dashboard Client, this sets the ResourceSpecFile option of the CTest Test Step. πŸŽ€
  • --test-load <level> β€” while running tests in parallel (e.g. with -j), try not to start tests when they may cause the CPU load to pass above a given threshold. When ctest is run as a Dashboard Client, this sets the TestLoad option of the CTest Test Step.
  • -Q, --quiet β€” make CTest quiet. This option will suppress all the output. The output log file will still be generated if the --output-log is specified. Options such as --verbose, --extra-verbose, and --debug are ignored if --quiet is specified. 🀫
  • -O <file>, --output-log <file> β€” output to log file. This option tells CTest to write all its output to a <file> log file.
  • --output-junit <file> β€” Added in version 3.21. write test results in JUnit format. This option tells CTest to write test results to <file> in JUnit XML format. If <file> already exists, it will be overwritten. If using the -S option to run a dashboard script, use the OUTPUT_JUNIT keyword with the ctest_test() command instead. ⭐
  • -N, --show-only[=<format>] β€” disable actual execution of tests. This option tells CTest to list the tests that would be run but not actually run them. Useful in conjunction with the -R and -E options. πŸ’… Added in version 3.14: the --show-only option accepts a <format> value. <format> can be one of the following values:
    • human β€” human-friendly output. This is not guaranteed to be stable. This is the default.
    • json-v1 β€” dump the test information in JSON format. See Show as JSON Object Model.
  • -L <regex>, --label-regex <regex> β€” run tests with labels matching regular expression as described under string(REGEX). This option tells CTest to run only the tests whose labels match the given regular expression. When more than one -L option is given, a test will only be run if each regular expression matches at least one of the test's labels (i.e. the multiple -L labels form an AND relationship). See Label Matching. 🌈
  • -R <regex>, --tests-regex <regex> β€” run tests matching regular expression. This option tells CTest to run only the tests whose names match the given regular expression. 🎯
  • -E <regex>, --exclude-regex <regex> β€” exclude tests matching regular expression. This option tells CTest to NOT run the tests whose names match the given regular expression. 🚫
  • -LE <regex>, --label-exclude <regex> β€” exclude tests with labels matching regular expression.

So -LE is literally telling CTest to NOT run any test whose labels match the regex you handed it πŸ™…β€β™€οΈ. And the spicy part: when you stack more than one -LE, a test only gets excluded if each regex matches at least one of that test's labels β€” meaning multiple -LE labels form an AND relationship, not an OR. Periodt. Peep Label Matching for the full tea πŸ«–.

  • --tests-from-file <filename> β€” bestie, this one's new in version 3.29 ✨. It tells CTest to run the tests listed in the file you give it. The file's gotta have one exact test name per line, and any line that doesn't exactly match a real test name just gets ignored (no drama, no error). You can totally combine it with the other options like -R, -E, -L, or -LE πŸŽ€.
  • --exclude-from-file <filename> β€” also added in version 3.29 πŸ’…. Same energy as above but the opposite: it tells CTest to NOT run the tests listed in the file. One exact test name per line, lines that don't match anything get ignored, and yes it stacks with -R, -E, -L, or -LE πŸ¦‹.
  • -FA <regex>, --fixture-exclude-any <regex> β€” excludes fixtures matching <regex> from automatically adding any tests to the test set. So like, normally if a test in your set requires a particular fixture, that fixture's setup and cleanup tests get auto-added for you. This option blocks that auto-add for fixtures matching the regex. Heads up though: all other fixture behavior is retained, including test dependencies and skipping tests that have fixture setup tests that fail πŸ‘‘.
  • -FS <regex>, --fixture-exclude-setup <regex> β€” same as -FA except only matching setup tests are excluded 🧚.
  • -FC <regex>, --fixture-exclude-cleanup <regex> β€” same as -FA except only matching cleanup tests are excluded 🌸.
  • -I [Start,End,Stride,test#,test#|Test file], --tests-information β€” run a specific number of tests by number, iconic behavior tbh. CTest runs tests starting at number Start, ending at number End, incrementing by Stride. Any extra numbers after Stride are treated as individual test numbers. Start, End, or Stride can each be left empty πŸ™ˆ. Optionally you can pass a file containing the exact same syntax as the command line.
  • -U, --union β€” takes the union of -I and -R, bestie. By default, when you specify both -R and -I, you get the intersection of tests. Say -U and you get the union instead πŸ’œ.
  • --rerun-failed β€” run only the tests that failed previously, no cap 😭. It tells CTest to perform only the tests that failed during its previous run. And here's the thing: when this option is specified, CTest ignores all other options intended to modify the list of tests to run (-L, -R, -E, -LE, -I, etc). Also, if CTest runs and nothing fails, then subsequent calls with --rerun-failed will run the set of tests that most recently failed (if any) πŸ”₯.
  • --repeat <mode>:<n> β€” run tests repeatedly based on the given <mode> up to <n> times. The modes are:
    • until-fail β€” require each test to run <n> times without failing in order to pass. Super useful for finding sporadic failures in test cases πŸ’€.
    • until-pass β€” allow each test to run up to <n> times in order to pass. It repeats tests if they fail for any reason. Useful for tolerating sporadic failures in test cases πŸ“.
    • after-timeout β€” allow each test to run up to <n> times in order to pass, but it repeats tests only if they timeout. Useful for tolerating sporadic timeouts on busy machines 🌈.
  • --repeat-until-fail <n> β€” literally just equivalent to --repeat until-fail:<n>. Shortcut slay ✨.
  • --max-width <width> β€” set the max width for a test name to output. It sets the maximum width for each test name shown in the output, so you can widen the output to avoid clipping the test name β€” which, honestly, can be very annoying 😀.
  • --interactive-debug-mode <0|1> β€” disable (0) or enable (1) interactive debug mode. This makes CTest run tests either interactive or non-interactive. In dashboard mode (Experimental, Nightly, Continuous), the default is non-interactive. In non-interactive mode, the environment variable DASHBOARD_TEST_FROM_CTEST is set πŸŽ€.

Interactive Mode allows Windows Error Reporting (WER) to show debug popup windows and to create core dumps. To enable core dumps in tests, use interactive mode, and follow the Windows documentation on Collecting User-Mode Dumps: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps πŸ“.

Changed in version 4.0: Windows Error Reporting (WER) is enabled in interactive mode, so test processes may show debug popup windows and create core dumps. This was made possible by updates to libuv πŸ‘‘

Changed in version 3.11: Windows Error Reporting (WER) is disabled in both interactive and non-interactive modes, so test processes do not show popup windows or create core dumps. This is due to launching test processes with libuv.

  • --no-label-summary β€” disable timing summary information for labels. It tells CTest not to print summary info for each label associated with the tests run. If there are no labels on the tests, nothing extra gets printed πŸ’…. See Label and Subproject Summary.
  • --no-subproject-summary β€” disable timing summary information for subprojects. Same deal: CTest won't print summary info for each subproject associated with the tests run. If there are no subprojects on the tests, nothing extra is printed πŸ¦‹. See Label and Subproject Summary.
  • --test-dir <path-to-build> β€” added in version 3.20 ✨. Specifies the directory to look for tests in, typically a CMake project build directory. If you don't specify it, the current directory is used. Also see --build-dir 🌸.
  • --test-output-size-passed <size> β€” added in version 3.4. Limit the output for passed tests to <size> bytes πŸ“.
  • --test-output-size-failed <size> β€” added in version 3.4. Limit the output for failed tests to <size> bytes πŸ“.
  • --test-output-truncation <mode> β€” added in version 3.24. Truncate the tail (that's the default), middle, or head of test output once the maximum output size is reached βœ‚οΈ.
  • --overwrite <option-name> β€” overwrite a CTest configuration option. By default CTest uses configuration options from the configuration file; this option will overwrite that configuration option πŸ’….
  • --force-new-ctest-process β€” Ignored. This option once disabled a now-removed optimization for tests running ctest itself. It's giving retired icon πŸ’€.
  • --schedule-random β€” use a random order for scheduling tests. It runs the tests in a random order, and it's commonly used to detect implicit dependencies in a test suite πŸ”₯.
  • --schedule-random-seed <seed> β€” added in version 4.1. Override the random order seed. It exists so you can recreate failures that came from the random order of execution via --schedule-random πŸŽ€.
  • --submit-index <index> β€” legacy option for an old Dart2 dashboard server feature. Do not use 🚫. Genuinely, don't.
  • --timeout <seconds> β€” set the default test timeout. This effectively sets a timeout on all tests that don't already have a timeout set on them via the TIMEOUT property ⏰.
  • --stop-time <time> β€” set a time at which all tests should stop running. It sets a real time of day at which all tests should timeout. Example: 7:00:00 -0400. Any time format understood by the curl date parser is accepted. Local time is assumed if no timezone is specified πŸ•°οΈ.
  • --print-labels β€” print all available test labels. This option will not run any tests; it simply prints the list of all labels associated with the test set 🏷️.
  • --no-tests=<action> β€” specify behavior when no tests are executed, e.g. when CTestTestfile.cmake defines no tests, or when the given arguments exclude all tests. The <action> may be one of:
    • error β€” consider running no tests to be an error. This is the default when running ctest -S scripts 😱.
    • ignore β€” consider running no tests to be normal. This is the default when running tests via the ctest command line, even when running as a dashboard client 🫢.

Added in version 3.26. This option can also be set by setting the CTEST_NO_TESTS_ACTION environment variable. See the documentation of that variable for how it interacts with a test preset's noTestsAction field πŸ’œ.

  • --collect-instrumentation <build> β€” added in version 4.0. Manually collect instrumentation data from the specified build directory. See the Indexing section of CMake instrumentation for more details πŸ”.
  • -- <test-args>... β€” added in version 4.4 ✨. Forward extra arguments to test executables. Everything after -- is appended to the end of every executed test's command line. This is useful for passing options to test frameworks like Google Test or doctest. For example:
ctest -R my_test -- --gtest_filter=SomeTest.Case
ctest --verbose -- --success

All selected tests receive the same extra arguments β€” use -R or -L to limit which tests are executed 🎯. A bare -- with no following arguments is silently ignored πŸ™ˆ. And when both <test-args> and testPassthroughArguments are provided, the test preset arguments will appear first, followed by the <test-args> 🌟.


πŸ” VIEW HELP πŸ”

okay bestie, if you just wanna peek at version info or print out selected pages of the CMake docs, these are your girlies πŸ‘‡

  • -version[=json-v1] [<file>], --version[=json-v1] [<file>], /V[=json-v1] [<file>], /version[=json-v1] [<file>] β€” shows the program name/version banner and then dips out. If you throw json-v1 at it, you get the extended version info in JSON format instead β€” and that JSON contains the versions for CMake and all its dependencies. Want it in a file? Pass a named <file> and that's where it goes.
✨ the JSON output format is described in machine-readable form by this JSON schema. iykyk.
  • -h, -H, --help, -help, -usage, /? β€” prints usage info and exits. Usage is the basic command line interface and its options, so it's giving "here's the vibe of the CLI" 🫢
  • --help <keyword> [<file>] β€” prints help for one CMake keyword. <keyword> can be a property, variable, command, policy, generator or module (so many options, we love a versatile icon πŸ’…). The relevant manual entry for <keyword> gets printed in a human-readable text format, and the output goes to a named <file> if you give one.
πŸ¦‹ Changed in version 3.28: prior to CMake 3.28, this option supported command names only. glow-up fr fr.
  • --help-full [<file>] β€” prints all the help manuals and exits. All of them in a human-readable text format. Output to a named <file> if given. this is the "give me everything" option πŸ“
  • --help-manual <man> [<file>] β€” prints one help manual and exits. The specified manual comes out in a human-readable text format, and yes, output goes to a named <file> if given.
  • --help-manual-list [<file>] β€” lists the help manuals that are available and exits. The list contains all manuals for which help may be obtained by using the --help-manual option followed by a manual name. Output to a named <file> if given.
  • --help-command <cmd> [<file>] β€” prints help for one command and exits. The cmake-commands(7) manual entry for <cmd> gets printed in a human-readable text format, and the output is printed to a named <file> if given.
  • --help-command-list [<file>] β€” lists commands with help available and exits. The list contains all commands for which help may be obtained by using the --help-command option followed by a command name. Output to a named <file> if given.
  • --help-commands [<file>] β€” prints the cmake-commands manual and exits. That's the cmake-commands(7) manual, printed in a human-readable text format, with output to a named <file> if given.
  • --help-module <mod> [<file>] β€” prints help for one module and exits. The cmake-modules(7) manual entry for <mod> is printed in a human-readable text format, output to a named <file> if given.
  • --help-module-list [<file>] β€” lists modules with help available and exits. The list contains all modules for which help may be obtained by using the --help-module option followed by a module name. Output to a named <file> if given.
  • --help-modules [<file>] β€” prints the cmake-modules manual and exits. That's cmake-modules(7), human-readable text format, output to a named <file> if given.
  • --help-policy <cmp> [<file>] β€” prints help for one policy and exits. The cmake-policies(7) manual entry for <cmp> gets printed in a human-readable text format, output to a named <file> if given.
  • --help-policy-list [<file>] β€” lists policies with help available and exits. The list contains all policies for which help may be obtained by using the --help-policy option followed by a policy name. Output to a named <file> if given.
  • --help-policies [<file>] β€” prints the cmake-policies manual and exits. cmake-policies(7), human-readable text format, output to a named <file> if given.
  • --help-property <prop> [<file>] β€” prints help for one property and exits. The cmake-properties(7) manual entries for <prop> are printed in a human-readable text format, output to a named <file> if given. (yes, entries, plural β€” it said what it said ✨)
  • --help-property-list [<file>] β€” lists properties with help available and exits. The list contains all properties for which help may be obtained by using the --help-property option followed by a property name. Output to a named <file> if given.
  • --help-properties [<file>] β€” prints the cmake-properties manual and exits. cmake-properties(7), human-readable text format, output to a named <file> if given.
  • --help-variable <var> [<file>] β€” prints help for one variable and exits. The cmake-variables(7) manual entry for <var> is printed in a human-readable text format, output to a named <file> if given.
  • --help-variable-list [<file>] β€” lists variables with help available and exits. The list contains all variables for which help may be obtained by using the --help-variable option followed by a variable name. Output to a named <file> if given.
  • --help-variables [<file>] β€” prints the cmake-variables manual and exits. cmake-variables(7), human-readable text format, output to a named <file> if given.

🏷️ LABEL MATCHING 🏷️

so tests can have labels attached to them, right? and you can include or exclude tests from a run by filtering on those labels. each individual filter is a regular expression applied to the labels attached to a test β€” regex girlies rise πŸ™Œ

When -L is used, for a test to be included in a test run, each regular expression must match at least one label. Using more than one -L option means "match all of these" β€” it's giving AND energy, not OR energy.

The -LE option works just like -L, but it excludes tests rather than including them. A test is excluded if each regular expression matches at least one label.

If a test has no labels attached to it, then -L will never include that test, and -LE will never exclude that test. no cap, that's just how it is πŸ’€

As an example of tests with labels, consider five tests, with the following labels:

  • test1 has labels tuesday and production
  • test2 has labels tuesday and test
  • test3 has labels wednesday and production
  • test4 has label wednesday
  • test5 has labels friday and test

Running ctest with -L tuesday -L test will select test2, which has both labels. Running CTest with -L test will select test2 and test5, because both of them have a label that matches that regular expression.

Because the matching works with regular expressions, take note that running CTest with -L es will match all five tests 😭 (the regex said what it said). To select the tuesday and wednesday tests together, use a single regular expression that matches either of them, like -L "tue|wed".


πŸ“Š LABEL AND SUBPROJECT SUMMARY πŸ“Š

CTest prints timing summary information for each LABEL and subproject associated with the tests run. Heads up: the label time summary will not include labels that are mapped to subprojects. ok noted 🫑

🌸 Added in version 3.22: labels added dynamically during test execution are also reported in the timing summary. See Additional Labels.

When the PROCESSORS test property is set, CTest will display a weighted test timing result in label and subproject summaries. The time is reported with sec * proc instead of just sec. fancy.

The weighted time summary reported for each label or subproject j is computed as:

Weighted Time Summary for Label/Subproject j =
    sum(raw_test_time[j,i] * num_processors[j,i], i=1...num_tests[j])

for labels/subprojects j=1...total

where:

  • raw_test_time[j,i]: Wall-clock time for the i test for the j label or subproject
  • num_processors[j,i]: Value of the CTest PROCESSORS property for the i test for the j label or subproject
  • num_tests[j]: Number of tests associated with the j label or subproject
  • total: Total number of labels or subprojects that have at least one test run

Therefore, the weighted time summary for each label or subproject represents the amount of time that CTest gave to run the tests for each label or subproject, and gives a good representation of the total expense of the tests for each label or subproject when compared to other labels or subprojects. it's basically a cost analysis moment πŸ’Έ

For example, if SubprojectA showed 100 sec*proc and SubprojectB showed 10 sec*proc, then CTest allocated approximately 10 times the CPU/core time to run the tests for SubprojectA than for SubprojectB (e.g. so if effort is going to be expended to reduce the cost of the test suite for the whole project, then reducing the cost of the test suite for SubprojectA would likely have a larger impact than effort to reduce the cost of the test suite for SubprojectB). main character energy from SubprojectA honestly πŸ‘‘

πŸ”¨ BUILD AND TEST MODE πŸ”¨

Okay bestie, so CTest doesn't just run tests β€” it also has a whole command-line signature that can configure (i.e. run cmake on), build, and/or execute a test. It's giving full-pipeline main character energy:

ctest --build-and-test <path-to-source> <path-to-build>
      --build-generator <generator>
      [<options>...]
      [--build-options <opts>...]
      [--test-command <command> [<args>...]]

The configure and test steps are optional (no pressure πŸ’…). The arguments to this command line are the source and binary directories. The --build-generator option must be provided to use --build-and-test β€” like, non-negotiable, it's the vibe check of this whole mode. And if --test-command is specified then that will be run after the build is complete. Other options that affect this mode include:

  • --build-and-test <path-to-source> <path-to-build> β€” switch into the build and test mode. That's the on switch, bestie ✨
  • --build-target <tgt> β€” specify a specific target to build. The option can be given multiple times with different targets, in which case each target is built in turn. A clean will be done before building each target unless the --build-noclean option is given. If no --build-target is specified, the all target is built. (so iconic of it)
  • --build-nocmake β€” run the build without running cmake first. Skip the cmake step. We're going straight to the build, no preamble πŸƒβ€β™€οΈ
  • --build-run-dir <dir> β€” specify directory to run programs from. Directory where programs will be after it has been compiled. iykyk 🫢
  • --build-two-config β€” run CMake twice. Double the CMake, double the fun, lowkey.
  • --build-exe-dir <dir> β€” specify the directory for the executable.
  • --build-generator <generator-name> β€” specify the generator to use. See the cmake-generators(7) manual for the full deets πŸ’–
  • --build-generator-platform <platform-name> β€” specify the generator-specific platform.
  • --build-generator-toolset <toolset-name> β€” specify the generator-specific toolset.
  • --build-project <project-name> β€” specify the name of the project to build.
  • --build-makeprogram <program-name> β€” specify the explicit make program to be used by CMake when configuring and building the project. Only applicable for Makefile Generators and Ninja Generators β€” so don't come at it with anything else, fr fr.
  • --build-noclean β€” skip the make clean step. Dirty build era πŸ’…
  • --build-config-sample <exe-name> β€” a sample executable to use to determine the configuration that should be used (e.g. Debug, Release, etc.).
  • --build-options [<options>...] β€” additional options for configuring the build (i.e. for cmake(1), not for the build tool). Note that if this is specified, the --build-options keyword and its arguments must be the last option given on the command line, with the possible exception of --test-command. So like, put it at the end okay? πŸ™ˆ
  • --test-command <command> β€” the command to run as the test step with the --build-and-test option. All arguments following this keyword will be assumed to be part of the test command line, so it must be the last option given. Everything after it is lunch πŸ“
  • --test-timeout <timeout> β€” the time limit in seconds.

🌈 DASHBOARD CLIENT 🌈

Not me about to tell you CTest can be a whole CDash client 😭 CTest can operate as a client for the CDash software quality dashboard application. As a dashboard client, CTest performs a sequence of steps to configure, build, and test software, and then submits the results to a CDash server. Very demure, very submit-your-results-to-a-dashboard.

The command-line signature used to submit to CDash is:

ctest -D <dashboard>         [-- <dashboard-options>...]
ctest -M <model> -T <action> [-- <dashboard-options>...]
ctest -S <script>            [-- <dashboard-options>...]
ctest -SP <script>           [-- <dashboard-options>...]

Options for Dashboard Client include:

  • -D <dashboard>, --dashboard <dashboard> β€” execute dashboard test. This option tells CTest to act as a CDash client and perform a dashboard test. All tests are <Mode><Test>, where <Mode> can be Experimental, Nightly, and Continuous, and <Test> can be Start, Update, Configure, Build, Test, Coverage, and Submit. And if <dashboard> is not one of the recognized <Mode><Test> values, this will be treated as a variable definition instead (see the dashboard-options further below) β€” plot twist πŸ’€
  • -M <model>, --test-model <model> β€” sets the model for a dashboard. This option tells CTest to act as a CDash client where the <model> can be Experimental, Nightly, and Continuous. Combining -M and -T is similar to -D.
  • -T <action>, --test-action <action> β€” sets the dashboard action to perform. This option tells CTest to act as a CDash client and perform some action such as start, build, test etc. See Dashboard Client Steps for the full list of actions. Combining -M and -T is similar to -D.
  • -S <script>, --script <script> β€” execute a dashboard for a configuration. This option tells CTest to load in a configuration script which sets a number of parameters such as the binary and source directories. Then CTest will do what is required to create and run a dashboard. This option basically sets up a dashboard and then runs ctest -D with the appropriate options. So it's like the manager of the whole operation πŸ‘‘
  • -SP <script>, --script-new-process <script> β€” execute a dashboard for a configuration. This option does the same operations as -S but it will do them in a separate process. This is primarily useful in cases where the script may modify the environment and you do not want the modified environment to impact other -S scripts. Boundaries, bestie πŸ¦‹

πŸ’« The available <dashboard-options> are the following:

  • -D <var>:<type>=<value>, -D <var>=<value> β€” define a variable for dashboard client mode. Pass in variable values on the command line. Use in conjunction with -S to pass variable values to a dashboard script, or with -T to override Dashboard Client Configuration settings. Parsing -D arguments as variable values is only attempted if the value following -D does not match any of the known dashboard types. The <var>:<type>=<value> form accepts any variable name. The simpler <var>=<value> form (without a type) is accepted only for variables whose names begin with CTEST_. In both cases the value overrides the corresponding setting from the Dashboard Client Configuration file (e.g., DartConfiguration.tcl) when using -T.
Note: These definitions set CTest script variables (e.g., CTEST_BUILD_NAME), not CMake cache variables. To pass CMake cache variables to the configure step, consider using a CTest Script, a configure preset, or setting CTEST_CONFIGURE_COMMAND. Don't get it twisted πŸ™ˆ
  • --source-dir <path-to-source> β€” Added in version 4.4. Specify the project source directory. When combined with -T Configure, this allows CTest to perform an initial configure step for an empty binary directory. The binary directory defaults to the current working directory; use --build-dir to specify a different location. The binary directory is created automatically if it does not yet exist. When a configure preset is specified that defines a binaryDir, CTest uses that path as the binary directory automatically (without requiring --build-dir). An explicit --build-dir takes precedence over the preset's binaryDir. A CMake generator must also be specified. Use -D CTEST_CMAKE_GENERATOR=<gen> to supply one, or set CTEST_CONFIGURE_PRESET to specify a configure preset that includes a generator. See the CTest Configure Step settings for more details. Phew, that was a lot but we got there πŸ’–
  • --build-dir <path-to-build> β€” Added in version 4.4. Specify the project binary (build) directory. This is an alias for --test-dir intended for use with --source-dir when bootstrapping a build with -T Configure. It's giving alias energy πŸŽ€
  • --group <group> β€” specify the group to which to submit results. Submit dashboard to specified group instead of the default. By default, the dashboard is submitted to Nightly, Experimental, or Continuous group, but by specifying this option, the group can be arbitrary. This replaces the deprecated option --track. Despite the name change its behavior is unchanged β€” so like, same girl, different name πŸ’…
  • -A <file>, --add-notes <file> β€” add a notes file with submission. This option tells CTest to include a notes file when submitting dashboard. Notes? iconic.
  • --tomorrow-tag β€” Nightly or Experimental starts with next day tag. This is useful if the build will not finish in one day. Future-proofing, we love to see it ⭐
  • --extra-submit <file>[;<file>] β€” submit extra .xml part files to the dashboard. See the ctest_submit() command's PARTS ExtraFiles option.
  • --http-header <header> β€” Added in version 3.29. Append HTTP header when submitting to the dashboard. This option will cause CTest to append the specified header when submitting to the dashboard. This option may be specified more than once. Stack 'em up 🫢
  • --http1.0 β€” submit using HTTP 1.0. This option will force CTest to use HTTP 1.0 to submit files to the dashboard, instead of HTTP 1.1. Retro moment.
  • --no-compress-output β€” do not compress test output when submitting. This flag will turn off automatic compression of test output. Use this to maintain compatibility with an older version of CDash which doesn't support compressed test output. Shoutout to the legacy girlies 🌸

🧚 Dashboard Client Steps 🧚

CTest defines an ordered list of testing steps of which some or all may be run as a dashboard client:

Start β€” start a new dashboard submission to be composed of results recorded by the following steps. See the CTest Start Step section below. ✨

Update β€” update the source tree from its version control repository. Record the old and new versions and the list of updated source files. See the CTest Update Step section below. Literally keeping the receipts πŸ“

Configure β€” configure the software by running a command in the build tree. Record the configuration output log. See the CTest Configure Step section below.

  • Build β€” build the software by running a command in the build tree. Record the build output log and detect warnings and errors. See the CTest Build Step section below. πŸ› οΈ
  • Test β€” test the software by loading a CTestTestfile.cmake from the build tree and executing the defined tests. Record the output and result of each test. See the CTest Test Step section below. πŸ§ͺ
  • Coverage β€” compute coverage of the source code by running a coverage analysis tool and recording its output. See the CTest Coverage Step section below. πŸ“Š
  • MemCheck β€” run the software test suite through a memory check tool. Record the test output, results, and issues reported by the tool. See the CTest MemCheck Step section below. 🧠
  • Submit β€” submit results recorded from other testing steps to the software quality dashboard server. See the CTest Submit Step section below. πŸ“€

🌈 Dashboard Client Modes 🌈

CTest defines three modes of operation as a dashboard client, and they are literally each their own little vibe:

  • Nightly β€” this mode is intended to be invoked once per day, typically at night. It enables the Start, Update, Configure, Build, Test, Coverage, and Submit steps by default. Selected steps run even if the Update step reports no changes to the source tree. πŸŒ™
  • Continuous β€” this mode is intended to be invoked repeatedly throughout the day. It enables the Start, Update, Configure, Build, Test, Coverage, and Submit steps by default, but exits after the Update step if it reports no changes to the source tree. πŸ”
  • Experimental β€” this mode is intended to be invoked by a developer to test local changes. It enables the Start, Configure, Build, Test, Coverage, and Submit steps by default. πŸ§ͺ

πŸ’» Dashboard Client via CTest Command-Line πŸ’»

CTest can perform testing on an already-generated build tree. Run the ctest command with the current working directory set to the build tree and use one of these signatures:

ctest -D <mode>[<step>]
ctest -M <mode> [-T <step>]...

The --source-dir option additionally allows the Configure step to be performed on a build tree that does not yet exist, in which case the --build-dir option specifies where to create it:

ctest [-M <mode>] -T Configure
    --source-dir <path-to-source> [--build-dir <path-to-build>]
ctest --build-and-test <path-to-source> <path-to-build>

The <mode> must be one of the above Dashboard Client Modes, and each <step> must be one of the above Dashboard Client Steps. No cap. βœ…

CTest reads the Dashboard Client Configuration settings from a file in the build tree called either CTestConfiguration.ini or DartConfiguration.tcl (the names are historical). The format of the file is:

# Lines starting in '#' are comments.
# Other non-blank lines are key-value pairs.
<setting>: <value>

where <setting> is the setting name and <value> is the setting value.

In build trees generated by CMake, this configuration file is generated by the CTest module if included by the project. The module uses variables to obtain a value for each setting as documented with the settings below. πŸ’…

πŸ“œ Dashboard Client via CTest Script πŸ“œ

CTest can perform testing driven by a cmake-language(7) script that creates and maintains the source and build tree as well as performing the testing steps. Run the ctest command with the current working directory set outside of any build tree and use one of these signatures:

ctest -S <script>
ctest -SP <script>

The <script> file must call CTest Commands commands to run testing steps explicitly as documented below. The commands obtain Dashboard Client Configuration settings from their arguments or from variables set in the script. 🫢


πŸ› οΈ DASHBOARD CLIENT CONFIGURATION πŸ› οΈ

The Dashboard Client Steps may be configured by named settings as documented in the following sections. This is where the real customization main-character energy kicks in. ✨

🎬 CTest Start Step 🎬

Start a new dashboard submission to be composed of results recorded by the following steps.

In a CTest Script, the ctest_start() command runs this step. Arguments to the command may specify some of the step settings. The command first runs the command-line specified by the CTEST_CHECKOUT_COMMAND variable, if set, to initialize the source directory.

Configuration settings include:

  • BuildDirectory β€” the full path to the project build tree.
    • CTest Script variable: CTEST_BINARY_DIRECTORY
    • CTest module variable: PROJECT_BINARY_DIR
  • SourceDirectory β€” the full path to the project source tree.
    • CTest Script variable: CTEST_SOURCE_DIRECTORY
    • CTest module variable: PROJECT_SOURCE_DIR
  • CheckoutCommand β€” command-line to run before the start step to initialize the source directory, e.g. to perform an initial checkout from version control.
    • CTest Script variable: CTEST_CHECKOUT_COMMAND
    • CTest module variable: none

πŸ”„ CTest Update Step πŸ”„

In a CTest Script, the ctest_update() command runs this step. Arguments to the command may specify some of the step settings.

Configuration settings to specify the version control tool include:

  • BZRCommand β€” bzr command-line tool to use if source tree is managed by Bazaar.
    • CTest Script variable: CTEST_BZR_COMMAND
    • CTest module variable: none
  • BZRUpdateOptions β€” command-line options to the BZRCommand when updating the source.
    • CTest Script variable: CTEST_BZR_UPDATE_OPTIONS
    • CTest module variable: none
  • CVSCommand β€” cvs command-line tool to use if source tree is managed by CVS.
    • CTest Script variable: CTEST_CVS_COMMAND
    • CTest module variable: CVSCOMMAND
  • CVSUpdateOptions β€” command-line options to the CVSCommand when updating the source.
    • CTest Script variable: CTEST_CVS_UPDATE_OPTIONS
    • CTest module variable: CVS_UPDATE_OPTIONS
  • GITCommand β€” git command-line tool to use if source tree is managed by Git.
    • CTest Script variable: CTEST_GIT_COMMAND
    • CTest module variable: GITCOMMAND
    • The source tree is updated by git fetch followed by git reset --hard to the FETCH_HEAD. The result is the same as git pull except that any local modifications are overwritten. Use GITUpdateCustom to specify a different approach. ⚠️
  • GITInitSubmodules β€” if set, CTest will update the repository's submodules before updating.
    • CTest Script variable: CTEST_GIT_INIT_SUBMODULES
    • CTest module variable: CTEST_GIT_INIT_SUBMODULES
  • GITUpdateCustom β€” specify a custom command line (as a semicolon-separated list) to run in the source tree (Git work tree) to update it instead of running the GITCommand.
    • CTest Script variable: CTEST_GIT_UPDATE_CUSTOM
    • CTest module variable: CTEST_GIT_UPDATE_CUSTOM
  • GITUpdateOptions β€” command-line options to the GITCommand when updating the source.
    • CTest Script variable: CTEST_GIT_UPDATE_OPTIONS
    • CTest module variable: GIT_UPDATE_OPTIONS
  • HGCommand β€” hg command-line tool to use if source tree is managed by Mercurial.
    • CTest Script variable: CTEST_HG_COMMAND
    • CTest module variable: none
  • HGUpdateOptions β€” command-line options to the HGCommand when updating the source.
    • CTest Script variable: CTEST_HG_UPDATE_OPTIONS
    • CTest module variable: none
  • P4Client β€” value of the -c option to the P4Command.
    • CTest Script variable: CTEST_P4_CLIENT
    • CTest module variable: CTEST_P4_CLIENT
  • P4Command β€” p4 command-line tool to use if source tree is managed by Perforce.
    • CTest Script variable: CTEST_P4_COMMAND
    • CTest module variable: P4COMMAND
  • P4Options β€” command-line options to the P4Command for all invocations.
    • CTest Script variable: CTEST_P4_OPTIONS
    • CTest module variable: CTEST_P4_OPTIONS
  • P4UpdateCustom β€” specify a custom command line (as a semicolon-separated list) to run in the source tree (Perforce tree) to update it instead of running the P4Command.
    • CTest Script variable: none
    • CTest module variable: CTEST_P4_UPDATE_CUSTOM
  • P4UpdateOptions β€” command-line options to the P4Command when updating the source.
    • CTest Script variable: CTEST_P4_UPDATE_OPTIONS
    • CTest module variable: CTEST_P4_UPDATE_OPTIONS
  • SVNCommand β€” svn command-line tool to use if source tree is managed by Subversion.
    • CTest Script variable: CTEST_SVN_COMMAND
    • CTest module variable: SVNCOMMAND
  • SVNOptions β€” command-line options to the SVNCommand for all invocations.
    • CTest Script variable: CTEST_SVN_OPTIONS
    • CTest module variable: CTEST_SVN_OPTIONS
  • SVNUpdateOptions β€” command-line options to the SVNCommand when updating the source.
    • CTest Script variable: CTEST_SVN_UPDATE_OPTIONS
    • CTest module variable: SVN_UPDATE_OPTIONS
  • UpdateCommand β€” specify the version-control command-line tool to use without detecting the VCS that manages the source tree. πŸ‘‘

...more UpdateCommand sourcing, bestie πŸ’…:

  • CTest Script variable: CTEST_UPDATE_COMMAND
  • CTest module variable: <VCS>COMMAND when UPDATE_TYPE is <vcs>, else UPDATE_COMMAND

πŸŽ€ UpdateOptions

Command-line options that get handed to the UpdateCommand.

  • CTest Script variable: CTEST_UPDATE_OPTIONS
  • CTest module variable: <VCS>_UPDATE_OPTIONS when UPDATE_TYPE is <vcs>, else UPDATE_OPTIONS

πŸŒ€ UpdateType

Tells CTest which version-control system is managing your source tree, for when it can't sniff it out automatically. The value may be bzr, cvs, git, hg, p4, or svn.

  • CTest Script variable: none, detected from source tree
  • CTest module variable: UPDATE_TYPE if set, else CTEST_UPDATE_TYPE

πŸ™ˆ UpdateVersionOnly

Says "girl, just look" β€” you want the version control update command to only discover the current version that's checked out, and not update to a different version.

  • CTest Script variable: CTEST_UPDATE_VERSION_ONLY
  • ctest_update() option: VERSION_ONLY

πŸ“Œ UpdateVersionOverride

You straight up tell it the current version of your source tree.

When this variable is set to a non-empty string, CTest will report the value you specified rather than using the update command to discover the current version that is checked out. Use of this variable supersedes UpdateVersionOnly. Like UpdateVersionOnly, using this variable tells CTest not to update the source tree to a different version.

  • CTest Script variable: CTEST_UPDATE_VERSION_OVERRIDE
  • ctest_update() option: VERSION_OVERRIDE <version>

Additional configuration settings include:

πŸŒ™ NightlyStartTime

In the Nightly dashboard mode, this specifies the "nightly start time". With centralized version control systems (cvs and svn), the Update step checks out the version of the software as of this time, so that multiple clients all choose a common version to test. This is not well-defined in distributed version-control systems, so the setting is just ignored there (not its fault, it's trying its best 🫢).

  • CTest Script variable: CTEST_NIGHTLY_START_TIME
  • CTest module variable: NIGHTLY_START_TIME if set, else CTEST_NIGHTLY_START_TIME

πŸ› οΈ CTest Configure Step

In a CTest Script, the ctest_configure() command runs this step. Arguments to the command may specify some of the step settings.

Configuration settings include:

βš™οΈ ConfigureCommand

Command-line to launch the software configuration process. It will be executed in the location specified by the BuildDirectory setting.

  • CTest Script variable: CTEST_CONFIGURE_COMMAND
  • CTest module variable: CMAKE_COMMAND followed by PROJECT_SOURCE_DIR

🏷️ LabelsForSubprojects

Specify a semicolon-separated list of labels that will be treated as subprojects. This mapping will be passed on to CDash when configure, test or build results are submitted.

  • CTest Script variable: CTEST_LABELS_FOR_SUBPROJECTS
  • CTest module variable: CTEST_LABELS_FOR_SUBPROJECTS

See Label and Subproject Summary.

🧚 CMakeGenerator

The CMake generator to use for the configure step when ConfigureCommand is not set.

  • CTest Script variable: CTEST_CMAKE_GENERATOR
  • CTest module variable: none

🧚 CMakeGeneratorPlatform

The CMake generator platform to use for the configure step when ConfigureCommand is not set.

  • CTest Script variable: CTEST_CMAKE_GENERATOR_PLATFORM
  • CTest module variable: none

🧚 CMakeGeneratorToolset

The CMake generator toolset to use for the configure step when ConfigureCommand is not set.

  • CTest Script variable: CTEST_CMAKE_GENERATOR_TOOLSET
  • CTest module variable: none

🧱 CTest Build Step

In a CTest Script, the ctest_build() command runs this step. Arguments to the command may specify some of the step settings.

Configuration settings include:

🌈 DefaultCTestConfigurationType

When the build system to be launched allows build-time selection of the configuration (e.g. Debug, Release), this specifies the default configuration to be built when no -C option is given to the ctest command. The value will be substituted into the value of MakeCommand to replace the literal string ${CTEST_CONFIGURATION_TYPE} if it appears.

  • CTest Script variable: CTEST_CONFIGURATION_TYPE
  • CTest module variable: DEFAULT_CTEST_CONFIGURATION_TYPE, initialized by the CMAKE_CONFIG_TYPE environment variable

🏷️ LabelsForSubprojects

Yep, it's back β€” specify a semicolon-separated list of labels that will be treated as subprojects. This mapping will be passed on to CDash when configure, test or build results are submitted.

  • CTest Script variable: CTEST_LABELS_FOR_SUBPROJECTS
  • CTest module variable: CTEST_LABELS_FOR_SUBPROJECTS

See Label and Subproject Summary.

πŸ”¨ MakeCommand

Command-line to launch the software build process. It will be executed in the location specified by the BuildDirectory setting.

  • CTest Script variable: CTEST_BUILD_COMMAND
  • CTest module variable: MAKECOMMAND, initialized by the build_command() command

πŸš€ UseLaunchers

For build trees generated by CMake using one of the Makefile Generators or the Ninja generator, this specifies whether the CTEST_USE_LAUNCHERS feature is enabled by the CTestUseLaunchers module (also included by the CTest module). When enabled, the generated build system wraps each invocation of the compiler, linker, or custom command line with a "launcher" that communicates with CTest via environment variables and files to report granular build warning and error information. Otherwise, CTest must "scrape" the build output log for diagnostics β€” not the vibe, honestly 😭.

  • CTest Script variable: CTEST_USE_LAUNCHERS
  • CTest module variable: CTEST_USE_LAUNCHERS

🎏 BuildFlags

Additional flags to pass to the build tool when building the project. Only used when MakeCommand is not set explicitly.

  • CTest Script variable: CTEST_BUILD_FLAGS
  • CTest module variable: none

🎯 BuildTarget

Specify a specific target to build instead of the default target. Only used when MakeCommand is not set explicitly.

  • CTest Script variable: CTEST_BUILD_TARGET
  • CTest module variable: none

πŸ§ͺ CTest Test Step

In a CTest Script, the ctest_test() command runs this step. Arguments to the command may specify some of the step settings.

Configuration settings include:

πŸ“„ ResourceSpecFile

Specify a resource specification file.

  • CTest Script variable: CTEST_RESOURCE_SPEC_FILE
  • CTest module variable: CTEST_RESOURCE_SPEC_FILE

See Resource Allocation for more information.

🏷️ LabelsForSubprojects

Third time's the charm ✨ β€” specify a semicolon-separated list of labels that will be treated as subprojects. This mapping will be passed on to CDash when configure, test or build results are submitted.

  • CTest Script variable: CTEST_LABELS_FOR_SUBPROJECTS
  • CTest module variable: CTEST_LABELS_FOR_SUBPROJECTS

See Label and Subproject Summary.

βš–οΈ TestLoad

While running tests in parallel (e.g. with -j), try not to start tests when they may cause the CPU load to pass above a given threshold. Be considerate to your poor little processor πŸ’€.

  • CTest Script variable: CTEST_TEST_LOAD
  • CTest module variable: CTEST_TEST_LOAD

⏰ TimeOut

The default timeout for each test if not specified by the TIMEOUT test property or the --timeout flag.

  • CTest Script variable: CTEST_TEST_TIMEOUT
  • CTest module variable: DART_TESTING_TIMEOUT

πŸ“ CoverageTool

Added in version 4.4.

Specify the tool used for collecting coverage during the running of the tests. The tool may be one of:

LLVM-COV

This value indicates the usage of Clang's source-based code coverage which "operates on AST and preprocessor information directly". For more information, see the Clang Source-based Code Coverage documentation at https://clang.llvm.org/docs/SourceBasedCodeCoverage.html.

CTest will run each test with the LLVM_PROFILE_FILE environment variable set to <directory>/<test-name>_<process-id>.profraw, where <directory> is the absolute path to the directory where the CTestTestfile.cmake that describes the test is located. This configures Clang Source-based Code Coverage to uniquely identify the coverage information gathered by each test without any collisions.

Any existing <directory>/<test-name>_*.profraw files for a test are removed before running the test. Any existing LLVM_PROFILE_FILE environment variable is ignored.

Heads up bestie: if no value is specified, no work is done and nothing is added to the environment. Periodt. πŸ’…
  • CTest Script variable: CTEST_TEST_COVERAGE_TOOL
    • CTest module variable: CTEST_TEST_COVERAGE_TOOL

and if you wanna yeet extra test values up to CDash, go read up on Additional Test Measurements 🫢


πŸ’… CTest Coverage Step πŸ’…

okay so in a CTest Script, the step that does this is ctest_coverage(). Arguments you hand the command can set some of the step settings for you. Here's the config tea β˜•:

  • CoverageCommand β€” the command-line tool that actually performs the software coverage analysis. It gets executed in wherever the BuildDirectory setting points. ✨
    • CTest Script variable: CTEST_COVERAGE_COMMAND
    • CTest module variable: COVERAGE_COMMAND
  • CoverageExtraFlags β€” command-line options you wanna feed to the CoverageCommand tool. πŸŽ€
    • CTest Script variable: CTEST_COVERAGE_EXTRA_FLAGS
    • CTest module variable: COVERAGE_EXTRA_FLAGS
    • These options are literally the first arguments passed to CoverageCommand.
  • ExtraCoverageGlob β€” a semicolon-separated list of glob patterns for extra source files you want included in the coverage analysis. πŸ¦‹
    • CTest Script variable: CTEST_EXTRA_COVERAGE_GLOB
    • CTest module variable: none

🌸 CTest MemCheck Step 🌸

In a CTest Script, ctest_memcheck() runs this step, and arguments to the command may specify some of the step settings. Main-character settings include:

  • MemoryCheckCommand β€” the command-line tool that does the dynamic analysis. Your test command lines get launched through this tool. ngl that's kind of iconic. πŸ”₯
    • CTest Script variable: CTEST_MEMORYCHECK_COMMAND
    • CTest module variable: MEMORYCHECK_COMMAND
  • MemoryCheckCommandOptions β€” command-line options for the MemoryCheckCommand tool. They get placed prior to the test command line. πŸ‘‘
    • CTest Script variable: CTEST_MEMORYCHECK_COMMAND_OPTIONS
    • CTest module variable: MEMORYCHECK_COMMAND_OPTIONS
  • MemoryCheckType β€” specifies the type of memory checking to perform. 🧚
    • CTest Script variable: CTEST_MEMORYCHECK_TYPE
    • CTest module variable: MEMORYCHECK_TYPE
  • MemoryCheckSanitizerOptions β€” options handed to sanitizers when you're running with a sanitize-enabled build. πŸ’œ
    • CTest Script variable: CTEST_MEMORYCHECK_SANITIZER_OPTIONS
    • CTest module variable: MEMORYCHECK_SANITIZER_OPTIONS
  • MemoryCheckSuppressionFile β€” a file containing suppression rules for the MemoryCheckCommand tool. It gets passed along with options appropriate to the tool. πŸ™ˆ
    • CTest Script variable: CTEST_MEMORYCHECK_SUPPRESSIONS_FILE
    • CTest module variable: MEMORYCHECK_SUPPRESSIONS_FILE

Additional configuration settings include β€” yes there's more, stay with me bestie:

  • BoundsCheckerCommand β€” specify a MemoryCheckCommand that's known to be command-line compatible with Bounds Checker.
    • CTest Script variable: none
    • CTest module variable: none
  • PurifyCommand β€” specify a MemoryCheckCommand that's known to be command-line compatible with Purify.
    • CTest Script variable: none
    • CTest module variable: PURIFYCOMMAND
  • ValgrindCommand β€” specify a MemoryCheckCommand that's known to be command-line compatible with Valgrind.
    • CTest Script variable: none
    • CTest module variable: VALGRIND_COMMAND
  • ValgrindCommandOptions β€” command-line options for the ValgrindCommand tool. They get placed prior to the test command line.
    • CTest Script variable: none
    • CTest module variable: VALGRIND_COMMAND_OPTIONS
  • DrMemoryCommand β€” specify a MemoryCheckCommand that's known to be command-line compatible with DrMemory.
    • CTest Script variable: none
    • CTest module variable: DRMEMORY_COMMAND
  • DrMemoryCommandOptions β€” command-line options for the DrMemoryCommand tool. They get placed prior to the test command line.
    • CTest Script variable: none
    • CTest module variable: DRMEMORY_COMMAND_OPTIONS
  • CudaSanitizerCommand β€” specify a MemoryCheckCommand that's known to be command-line compatible with cuda-memcheck or compute-sanitizer.
    • CTest Script variable: none
    • CTest module variable: CUDA_SANITIZER_COMMAND
  • CudaSanitizerCommandOptions β€” command-line options for the CudaSanitizerCommand tool. They get placed prior to the test command line.
    • CTest Script variable: none
    • CTest module variable: CUDA_SANITIZER_COMMAND_OPTIONS

πŸ¦‹ CTest Submit Step πŸ¦‹

In a CTest Script, ctest_submit() runs this step, and arguments to the command may specify some of the step settings. Configuration settings include:

  • BuildName β€” describes the dashboard client platform with a short string (operating system, compiler, etc.). slay, label your build. πŸ’–
    • CTest Script variable: CTEST_BUILD_NAME
    • CTest module variable: BUILDNAME
  • CDashVersion β€” Legacy option. Not used. πŸ’€
    • CTest Script variable: none, detected from server
    • CTest module variable: CTEST_CDASH_VERSION
  • CTestSubmitRetryCount β€” specifies how many attempts to retry submission on network failure. πŸ”
    • CTest Script variable: none, use the ctest_submit() RETRY_COUNT option.
    • CTest module variable: CTEST_SUBMIT_RETRY_COUNT
  • CTestSubmitRetryDelay β€” specifies a delay before retrying submission on network failure. ⏳
    • CTest Script variable: none, use the ctest_submit() RETRY_DELAY option.
    • CTest module variable: CTEST_SUBMIT_RETRY_DELAY
  • CurlOptions β€” Deprecated since version 3.30: Use TLSVerify instead. Specifies a semicolon-separated list of options to control the Curl library that CTest uses internally to connect to the server. 🌈
    • CTest Script variable: CTEST_CURL_OPTIONS
    • CTest module variable: CTEST_CURL_OPTIONS
    • Possible options are:
      • CURLOPT_SSL_VERIFYPEER_OFF β€” Disable the CURLOPT_SSL_VERIFYPEER curl option.
      • CURLOPT_SSL_VERIFYHOST_OFF β€” Disable the CURLOPT_SSL_VERIFYHOST curl option.
⚠️ heads up bestie: CurlOptions is deprecated since version 3.30. Use TLSVerify instead, fr fr.
  • DropLocation β€” Legacy option. When SubmitURL is not set, it is constructed from DropMethod, DropSiteUser, DropSitePassword, DropSite, and DropLocation.
    • CTest Script variable: CTEST_DROP_LOCATION
    • CTest module variable: DROP_LOCATION if set, else CTEST_DROP_LOCATION
  • DropMethod β€” Legacy option. When SubmitURL is not set, it is constructed from DropMethod, DropSiteUser, DropSitePassword, DropSite, and DropLocation.
    • CTest Script variable: CTEST_DROP_METHOD
    • CTest module variable: DROP_METHOD if set, else CTEST_DROP_METHOD
  • DropSite β€” Legacy option. When SubmitURL is not set, it is constructed from DropMethod, DropSiteUser, DropSitePassword, DropSite, and DropLocation.
    • CTest Script variable: CTEST_DROP_SITE
    • CTest module variable: DROP_SITE if set, else CTEST_DROP_SITE
  • DropSitePassword β€” Legacy option. When SubmitURL is not set, it is constructed from DropMethod, DropSiteUser, DropSitePassword, DropSite, and DropLocation. 🀫
    • CTest Script variable: CTEST_DROP_SITE_PASSWORD
    • CTest module variable: DROP_SITE_PASSWORD if set, else CTEST_DROP_SITE_PASSWORD
  • DropSiteUser β€” Legacy option. When SubmitURL is not set, it is constructed from DropMethod, DropSiteUser, DropSitePassword, DropSite, and DropLocation.
    • CTest Script variable: CTEST_DROP_SITE_USER
    • CTest module variable: DROP_SITE_USER if set, else CTEST_DROP_SITE_USER
  • IsCDash β€” Legacy option. Not used.
    • CTest Script variable: CTEST_DROP_SITE_CDASH
    • CTest module variable: CTEST_DROP_SITE_CDASH
  • ScpCommand β€” Legacy option. Not used.
    • CTest Script variable: CTEST_SCP_COMMAND
    • CTest module variable: SCPCOMMAND
  • Site β€” describes the dashboard client host site with a short string (hostname, domain, etc.). 🏠
    • CTest Script variable: CTEST_SITE
    • CTest module variable: SITE, initialized by the site_name() command
  • SubmitURL β€” the http or https URL of the dashboard server to send the submission to. πŸ’Œ
    • CTest Script variable: CTEST_SUBMIT_URL
    • CTest module variable: SUBMIT_URL if set, else CTEST_SUBMIT_URL
  • SubmitInactivityTimeout β€” the time to wait for the submission, after which it is canceled if not completed. Specify a zero value to disable the timeout. βŒ›
    • CTest Script variable: CTEST_SUBMIT_INACTIVITY_TIMEOUT
  • CTest module variable: CTEST_SUBMIT_INACTIVITY_TIMEOUT

πŸ“ NotesFiles πŸ“

Okay so NotesFiles is literally a semicolon-separated list of notes files to upload with the submission. Semicolon-separated, bestie β€” don't forget that part. πŸ’…

  • CTest Script variable: CTEST_NOTES_FILES
  • CTest module variable: none

πŸ“¦ ExtraSubmitFiles πŸ“¦

ExtraSubmitFiles is a semicolon-separated list of extra .xml files to upload with the submission. Yes, extra. Yes, .xml. Yes, semicolon-separated again. πŸŽ€

  • CTest Script variable: CTEST_EXTRA_SUBMIT_FILES
  • CTest module variable: none

🧩 SubmitParts 🧩

SubmitParts is a semicolon-separated list of part names to submit. When it's set, only the named parts get submitted rather than all available parts. The valid names are the same as the PARTS option of ctest_submit(). iykyk. ✨

  • CTest Script variable: CTEST_SUBMIT_PARTS
  • CTest module variable: none

⏳ TimeLimit ⏳

TimeLimit is the maximum total time (in seconds) allowed for the entire dashboard run. CTest will not start additional steps once the remaining time drops below two minutes. So like… it's giving deadline energy fr fr. πŸ•°οΈ

  • CTest Script variable: CTEST_TIME_LIMIT
  • CTest module variable: none

πŸ” TLSVersion πŸ”

Added in version 3.30.

TLSVersion specifies a minimum TLS version allowed when submitting to a dashboard via https:// URLs. slay.

  • CTest Script variable: CTEST_TLS_VERSION
  • CTest module variable: CTEST_TLS_VERSION

Changed in version 3.31: The default is TLS 1.2. Previously, no minimum version was enforced by default.

πŸ›‘οΈ TLSVerify πŸ›‘οΈ

Added in version 3.30.

TLSVerify specifies a boolean value indicating whether to verify the server certificate when submitting to a dashboard via https:// URLs. Very important vibe check for certificates. πŸ’–

  • CTest Script variable: CTEST_TLS_VERIFY
  • CTest module variable: CTEST_TLS_VERIFY

Changed in version 3.31: The default is on. Previously, the default was off. Users may set the CMAKE_TLS_VERIFY environment variable to 0 to restore the old default.

🫠 TriggerSite 🫠

TriggerSite is a legacy option. Not used. It's just kinda sitting there, being iconic in a retired way. πŸ’€

  • CTest Script variable: CTEST_TRIGGER_SITE
  • CTest module variable: TRIGGER_SITE if set, else CTEST_TRIGGER_SITE

πŸ” SHOW AS JSON OBJECT MODEL πŸ”

Added in version 3.14.

When the --show-only=json-v1 command line option is given, the test information is output in JSON format. Version 1.0 of the JSON object model is defined as follows:

  • kind β€” The string "ctestInfo".
  • version β€” A JSON object specifying the version components. Its members are:
    • major β€” A positive integer specifying the major version component of the JSON object model.
    • minor β€” A non-negative integer specifying the minor version component of the JSON object model.
  • backtraceGraph β€” JSON object representing backtrace information with the following members:
    • commands β€” List of command names.
    • files β€” List of file names.
    • nodes β€” List of node JSON objects with members:
      • command β€” An optional member present when the node represents a command invocation within the file. The value is an unsigned integer 0-based index into the commands member of the backtraceGraph.
      • file β€” An unsigned integer 0-based index into the files member of the backtraceGraph.
      • line β€” An optional member present when the node represents a line within the file. The value is an unsigned integer 1-based line number in the file where the backtrace was added.
      • parent β€” An optional member present when the node is not the bottom of the call stack. The value is an unsigned integer 0-based index into the nodes member of the backtraceGraph representing the parent in the graph.
  • tests β€” A JSON array listing information about each test. Each entry is a JSON object with members:
    • name β€” Test name. This cannot be empty.
    • config β€” Optional field specifying the configuration for which the test will run. This will always match the -C option specified on the ctest command line. If no such option was given, this field will not be present.
    • command β€” Optional array where the first element is the test command and the remaining elements are the command arguments. Normally, this field should be present and non-empty, but in certain corner cases involving generator expressions, it is possible for a test to have no command and therefore this field can be missing.
    • backtrace β€” Index into the nodes member of the backtraceGraph.
    • properties β€” Optional array of test properties. Each array item will be a JSON object with the following members:
      • name β€” The name of the test property. This cannot be empty.
      • value β€” The property value, which can be a string, a number, a boolean, or an array of strings.

Added in version 4.1: The JSON output format is described in machine-readable form by this JSON schema. ate, no cap. πŸ‘‘


🧸 RESOURCE ALLOCATION 🧸

CTest provides a mechanism for tests to specify the resources that they need in a fine-grained way, and for users to specify the resources available on the running machine. This allows CTest to internally keep track of which resources are in use and which are free, scheduling tests in a way that prevents them from trying to claim resources that are not available. It's lowkey such a flex. πŸ’…

When the resource allocation feature is used, CTest will not oversubscribe resources. For example, if a resource has 8 slots, CTest will not run tests that collectively use more than 8 slots at a time. This has the effect of limiting how many tests can run at any given time, even if a high -j argument is used, if those tests all use some slots from the same resource. In addition, it means that a single test that uses more of a resource than is available on a machine will not run at all (and will be reported as Not Run). Not Run is literally its whole mood at that point. 😭

A common use case for this feature is for tests that require the use of a GPU. Multiple tests can simultaneously allocate memory from a GPU, but if too many tests try to do this at once, some of them will fail to allocate, resulting in a failed test, even though the test would have succeeded if it had the memory it needed. By using the resource allocation feature, each test can specify how much memory it requires from a GPU, allowing CTest to schedule tests in a way that running several of these tests at once does not exhaust the GPU's memory pool. Obsessed with the way this prevents chaos. 🌈

Please note that CTest has no concept of what a GPU is or how much memory it has. It does not have any way of communicating with a GPU to retrieve this information or perform any memory management, although the project can define a test that provides details about the test machine (see Dynamically-Generated Resource Specification File). Like, CTest is not snooping on your GPU β€” it does not know her. πŸ’€

CTest keeps track of a list of abstract resource types, each of which has a certain number of slots available for tests to use. Each test specifies the number of slots that it requires from a certain resource, and CTest then schedules them in a way that prevents the total number of slots in use from exceeding the listed capacity. When a test is executed, and slots from a resource are allocated to that test, tests may assume that they have exclusive use of those slots for the duration of the test's process. Exclusive use, periodt. ✨

The CTest resource allocation feature consists of at least two inputs:

  • The resource specification file, described below, which describes the resources available on the system.
  • The RESOURCE_GROUPS property of tests, which describes the resources required by the test.

When CTest runs a test, the resources allocated to that test are passed in the form of a set of environment variables as described below. Using this information to decide which resource to connect to is left to the test writer. That part is on you, bestie. 🫢

The RESOURCE_GROUPS property tells CTest what resources a test expects to use grouped in a way meaningful to the test. The test itself must read the environment variables to determine which resources have been allocated to each group. For example, each group may correspond to a process the test will spawn when executed. Group chat, but for resources. πŸ“±

Note that even if a test specifies a RESOURCE_GROUPS property, it is still possible for that test to run without any resource allocation (and without the corresponding environment variables) if the user does not pass a resource specification file. Passing this file, either through the --resource-spec-file command-line argument or the RESOURCE_SPEC_FILE argument to ctest_test(), is what activates the resource allocation feature. Tests should check the CTEST_RESOURCE_GROUP_COUNT environment variable to find out whether or not resource allocation is activated. This variable will always (and only) be defined if resource allocation is activated. If resource allocation is not activated, then the CTEST_RESOURCE_GROUP_COUNT variable will not exist, even if it exists for the parent ctest process. If a test absolutely must have resource allocation, then it can return a failing exit code or use the SKIP_RETURN_CODE or SKIP_REGULAR_EXPRESSION properties to indicate a skipped test. Clear? Clear. πŸ’–

🧚 Resource Specification File 🧚

The resource specification file is a JSON file which is passed to CTest in one of a number of ways. It can be specified on the command line with the --resource-spec-file option, it can be given using the RESOURCE_SPEC_FILE argument of ctest_test(), or it can be generated dynamically as part of test execution (see Dynamically-Generated Resource Specification File). Three paths, one JSON file, very main character energy. πŸ¦‹

okay so bestie, here's the resource-spec-file fallback tea β˜•: if a dashboard script is used and RESOURCE_SPEC_FILE is not specified, the value of CTEST_RESOURCE_SPEC_FILE in the dashboard script is used instead. If --resource-spec-file, RESOURCE_SPEC_FILE, and CTEST_RESOURCE_SPEC_FILE in the dashboard script are not specified, the value of CTEST_RESOURCE_SPEC_FILE in the CMake build is used instead. If none of these are specified, no resource spec file is used. That's the whole chain, no cap.

The resource specification file must be a JSON object. All examples in this document assume the following resource specification file:

{
  "version": {
    "major": 1,
    "minor": 0
  },
  "local": [
    {
      "gpus": [
        {
          "id": "0",
          "slots": 2
        },
        {
          "id": "1",
          "slots": 4
        },
        {
          "id": "2",
          "slots": 2
        },
        {
          "id": "3"
        }
      ],
      "crypto_chips": [
        {
          "id": "card0",
          "slots": 4
        }
      ]
    }
  ]
}

The members are:

  • version β€” an object containing a major integer field and a minor integer field. Currently, the only supported version is major 1, minor 0. Any other value is an error. Periodt. So do not test your luck πŸ’€.
  • local β€” a JSON array of resource sets present on the system. Currently, this array is restricted to being of size 1.

Each array element is a JSON object with members whose names are equal to the desired resource types, such as gpus. These names must start with a lowercase letter or an underscore, and subsequent characters can be a lowercase letter, a digit, or an underscore. Uppercase letters are not allowed, because certain platforms have case-insensitive environment variables. See the Environment Variables section below for more information. It is recommended that the resource type name be the plural of a noun, such as gpus or crypto_chips (and not gpu or crypto_chip).

Please note that the names gpus and crypto_chips are just examples, and CTest does not interpret them in any way. You are free to make up any resource type you want to meet your own requirements. Main character resource names only ✨.

The value for each resource type is a JSON array consisting of JSON objects, each of which describes a specific instance of the specified resource. These objects have the following members:

  • id β€” a string consisting of an identifier for the resource. Each character in the identifier can be a lowercase letter, a digit, or an underscore. Uppercase letters are not allowed.

Identifiers must be unique within a resource type. However, they do not have to be unique across resource types. For example, it is valid to have a gpus resource named 0 and a crypto_chips resource named 0, but not two gpus resources both named 0.

Please note that the IDs 0, 1, 2, 3, and card0 are just examples, and CTest does not interpret them in any way. You are free to make up any IDs you want to meet your own requirements. iykyk.

  • slots β€” an optional unsigned number specifying the number of slots available on the resource. For example, this could be megabytes of RAM on a GPU, or cryptography units available on a cryptography chip. If slots is not specified, a default value of 1 is assumed. Fr fr.

In the example file above, there are four GPUs with IDs 0 through 3. GPU 0 has 2 slots, GPU 1 has 4, GPU 2 has 2, and GPU 3 has a default of 1 slot. There is also one cryptography chip with 4 slots. Obsessed with the consistency πŸ’….

RESOURCE_GROUPS Property 🌸

See RESOURCE_GROUPS for a description of this property. That's the whole vibe check.

Environment Variables 🧚

Once CTest has decided which resources to allocate to a test, it passes this information to the test executable as a series of environment variables. For each example below, we will assume that the test in question has a RESOURCE_GROUPS property of 2,gpus:2;gpus:4,gpus:1,crypto_chips:2.

The following variables are passed to the test process:

  • CTEST_RESOURCE_GROUP_COUNT β€” the total number of groups specified by the RESOURCE_GROUPS property. For example:
    • CTEST_RESOURCE_GROUP_COUNT=3

This variable will only be defined if ctest(1) has been given a --resource-spec-file, or if ctest_test() has been given a RESOURCE_SPEC_FILE. If no resource specification file has been given, this variable will not be defined.

  • CTEST_RESOURCE_GROUP_<num> β€” the list of resource types allocated to each group, with each item separated by a comma. <num> is a number from zero to CTEST_RESOURCE_GROUP_COUNT minus one. CTEST_RESOURCE_GROUP_<num> is defined for each <num> in this range. For example:
    • CTEST_RESOURCE_GROUP_0=gpus
    • CTEST_RESOURCE_GROUP_1=gpus
    • CTEST_RESOURCE_GROUP_2=crypto_chips,gpus
  • CTEST_RESOURCE_GROUP_<num>_<resource-type> β€” the list of resource IDs and number of slots from each ID allocated to each group for a given resource type. This variable consists of a series of pairs, each pair separated by a semicolon, and with the two items in the pair separated by a comma. The first item in each pair is id: followed by the ID of a resource of type <resource-type>, and the second item is slots: followed by the number of slots from that resource allocated to the given group. For example:
    • CTEST_RESOURCE_GROUP_0_GPUS=id:0,slots:2
    • CTEST_RESOURCE_GROUP_1_GPUS=id:2,slots:2
    • CTEST_RESOURCE_GROUP_2_GPUS=id:1,slots:4;id:3,slots:1
    • CTEST_RESOURCE_GROUP_2_CRYPTO_CHIPS=id:card0,slots:2

In this example, group 0 gets 2 slots from GPU 0, group 1 gets 2 slots from GPU 2, and group 2 gets 4 slots from GPU 1, 1 slot from GPU 3, and 2 slots from cryptography chip card0.

<num> is a number from zero to CTEST_RESOURCE_GROUP_COUNT minus one. <resource-type> is the name of a resource type, converted to uppercase. CTEST_RESOURCE_GROUP_<num>_<resource-type> is defined for the product of each <num> in the range listed above and each resource type listed in CTEST_RESOURCE_GROUP_<num>.

Because some platforms have case-insensitive names for environment variables, the names of resource types may not clash in a case-insensitive environment. Because of this, for the sake of simplicity, all resource types must be listed in all lowercase in the resource specification file and in the RESOURCE_GROUPS property, and they are converted to all uppercase in the CTEST_RESOURCE_GROUP_<num>_<resource-type> environment variable. That's the case-sensitivity lore, bestie 🫢.

Dynamically-Generated Resource Specification File ✨

Added in version 3.28.

A project may optionally specify a single test which will be used to dynamically generate the resource specification file that CTest will use for scheduling tests that use resources. The test that generates the file must have the GENERATED_RESOURCE_SPEC_FILE property set, and must have exactly one fixture in its FIXTURES_SETUP property. This fixture is considered by CTest to have special meaning: it's the fixture that generates the resource spec file. The fixture may have any name. If such a fixture exists, all tests that have RESOURCE_GROUPS set must have the fixture in their FIXTURES_REQUIRED, and a resource spec file may not be specified with the --resource-spec-file argument or the CTEST_RESOURCE_SPEC_FILE variable. Fixture lore unlocked πŸ”“.

JOB SERVER INTEGRATION πŸ”₯

Added in version 3.29.

On POSIX systems, when running under the context of a Job Server (<https://www.gnu.org/software/make/manual/html_node/Job-Slots.html>), CTest shares its job slots. This is independent of the PROCESSORS test property, which still counts against CTest's -j parallel level. CTest acquires exactly one token from the job server before running each test, and returns it when the test finishes. Job slots slay.

For example, consider the Makefile:

test:
     +ctest -j 8

When invoked via make -j 2 test, CTest connects to the job server, acquires a token for each test, and runs at most 2 tests concurrently.

On Windows systems, job server integration is not yet implemented. Sad but true 😭.

SEE ALSO πŸ‘€

The following resources are available to get help using CMake:

  • Home Page β€” <https://cmake.org> The primary starting point for learning about CMake.
  • Online Documentation and Community Resources β€” <https://cmake.org/documentation> Links to available documentation and community resources may be found on this web page.
  • Discourse Forum β€” <https://discourse.cmake.org> The Discourse Forum hosts discussion and questions about CMake.

2000-2026 Kitware, Inc. and Contributors

okay that's literally the whole CTEST(1) page from version 4.4.5, dated Oct 28, 2026 β€” go run your tests, bestie, and remember: resource specs are your friend πŸ’–βœ¨

πŸ“¦ where this page comes from