2142 Commits
Author SHA1 Message Date
Brad King 6498b76d61 Merge topic 'reduce-realloc-clang-tidy-part3'
0aa1eaf506 Source: Reduce string allocations, part 4
1d2f0120be Source: Reduce string allocations, part 3
cb20c5bd89 Source: Reduce string allocations, part 2

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12538
2026-09-23 13:30:55 -04:00
AJIOB cb20c5bd89 Source: Reduce string allocations, part 2 2026-09-22 11:37:41 +03:00
Taylor Braun-JonesandTyler Yankee 5cced02b9d CTest: Repeat test fixtures with the tests that require them
When ctest repeats tests with its --repeat option, it repeats each test
on its own.  A fixture's setup and cleanup tests therefore run all of
their repetitions back to back, and the tests they bracket repeat inside
a single setup/cleanup pair:

  setup -> setup -> test -> test -> cleanup -> cleanup

Add a FIXTURE_REPEAT_MODE test property to select how a fixture behaves
when its tests are repeated:

* AROUND_ALL_REPEATS: the fixture runs once, around all repetitions of
  the tests requiring it.
* AROUND_EACH_REPEAT: the fixture and the tests requiring it repeat
  together, so every repetition gets a fresh setup and its own cleanup.
* EACH_TEST_SEPARATELY: every test repeats on its own, as before.

The property describes the fixture rather than the test carrying it, so
setting it on any one of a fixture's setup or cleanup tests is enough.

In AROUND_EACH_REPEAT mode the tests of a fixture form a repeat group that
ctest re-queues as a whole once every test in it has finished.  The --repeat
condition then applies to the group the way it applies to an individual
test: until-fail repeats while the whole group passes, until-pass repeats
while any of it does not, and after-timeout repeats while any of it times
out.  Fixtures that share a test repeat together, so a test requiring two of
them still runs once per repetition.

A group is recorded the way a repeating test is: only once it stops
repeating, and with the results of its last repetition.  A group that
until-pass makes pass therefore reports a pass rather than the failure that
made it repeat, a test that DEPENDS on one of the group's tests waits for
the last repetition rather than the first, and `ctest -F` resumes an
interrupted group by running it again from the beginning.

Fixtures that repeat together have to agree on the mode: a test cannot
repeat with one fixture but not with another it takes part in, and a fixture
whose setup and cleanup tests disagree has no coherent behavior.  Report an
error and run nothing in those cases rather than pick an order in which a
test repeats after a fixture it requires has been cleaned up.

Add policy CMP0224 to select AROUND_EACH_REPEAT as the default for fixtures
whose setup and cleanup tests choose no mode themselves.  Record the mode
the policy chose in the generated test file under its own
_CMAKE_DEFAULT_FIXTURE_REPEAT_MODE keyword, so that ctest reads a mode
rather than the policy settings behind it, and so that a mode requested on
one of a fixture's tests wins over the default recorded for its siblings.
Only NEW needs recording: with nothing recorded, ctest already uses the
behavior of CMake 4.4 and below.  Fixtures are common, and the choice of
mode matters only to those who run ctest --repeat, so warn about the unset
policy only when the CMAKE_POLICY_WARNING_CMP0224 variable asks for it.

discover_tests() and gtest_discover_tests() create their tests while ctest
runs or at build time, too late for the policy to reach them, so carry the
setting in effect at their call sites through to the tests they create.

Report the repetition a grouped test belongs to in the "(run N/M)" suffix
of its "Start" line, as ctest already does for a test repeating on its own.

Co-authored-by: Tyler Yankee <tyler.yankee@kitware.com>
Fixes: #21438
2026-09-18 08:29:28 -04:00
Taylor Braun-Jones 4fcf3dd296 CTest: Ignore a checkpoint entry for a test that is not pending
CheckResume() reads the checkpoint `ctest -F` resumes from and removes each
test it names.  RemoveTest() erased the iterator std::find returned without
checking it, so a checkpoint naming a test the current run does not have
pending -- one written before the test list changed, say -- erased the end
iterator of a std::list, which is undefined behavior.  Skip such an entry
instead.
2026-09-18 08:28:42 -04:00
Taylor Braun-Jones 32b25b94d6 CTest: Track one run number for a repeating test
cmCTestRunTest counted the repetitions of a test with two members whose
meaning overlapped: how many runs were left, and how many there were in
total.  The "(run N/M)" suffix then had to recover N by subtracting one
from the other, and the rule deciding which run prints the "completed/total"
prefix read as a pair of conditions on the remaining count.

Count up instead.  Keep the number of the run being made and the number of
runs the test may be given, and let the rule say which run the prefix
belongs to.
2026-09-18 08:28:41 -04:00
Brad King f9ae489598 Merge topic 'cdash-instrumentation-proc-metrics'
01fa1984e5 instrumentation: Send processMetrics data to CDash
68e2a3e793 instrumentation: Rename userTime and systemTime fields to exclude units

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Tyler Yankee <tyler.yankee@kitware.com>
Merge-request: !12514
2026-09-18 08:11:50 -04:00
Brad King ab46a992e5 Merge topic 'ctest-dashboard-preset-env'
27f28db197 Help: Clarify CTEST_NO_TESTS_ACTION support and interaction
a235560e53 Help: Clarify interaction between CTest parallelism toggles
f745dd11ab ctest: Respect test envvars set by CTEST_PRESET
277236a99a cmCTestTestCommand: Factor out preset resolution
81b46d87ba cmCTest: Factor out environment variable handling
4e81913645 Tests: Fix unset(ENV{...}) typos

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12495
2026-09-18 07:59:56 -04:00
Martin Duffy 68e2a3e793 instrumentation: Rename userTime and systemTime fields to exclude units
Drop the "USec" suffix from these fields for consistency with other
instrumentation fields which do not include units.
2026-09-17 10:10:31 -04:00
Brad King a30ad325f4 Merge topic 'instrumentation-cdash-file-check'
77443e7258 instrumentation: Don't expect staged CDash files when cdashSubmit is disabled

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Tested-by: Aiden Woodruff <aiden.woodruff@kitware.com>
Merge-request: !12508
2026-09-16 14:39:28 -04:00
Tyler Yankee f745dd11ab ctest: Respect test envvars set by CTEST_PRESET
Note the special attention given to support CTest environment variables
from inside a test preset's `environment` field.

Fixes: #28079
2026-09-16 09:34:43 -04:00
Tyler Yankee 277236a99a cmCTestTestCommand: Factor out preset resolution
Prepare for a future commit which will reuse this functionality. Add a
structure to hold the resolved fields so that we can more easily
distinguish between errors during preset resolution and cases when
presets simply aren't used.
2026-09-16 09:05:32 -04:00
Martin Duffy 77443e7258 instrumentation: Don't expect staged CDash files when cdashSubmit is disabled 2026-09-14 15:38:40 -04:00
AJIOB c8b93b9db6 Source: Reduce string allocations 2026-09-11 23:11:52 +03:00
Nerixyz 865d6bf223 CTest: Support --max-width shorter than longest test name
Fixes: #24101
2026-09-07 18:21:35 +02:00
Brad King c23b537168 Merge topic 'instrumentation-proc-metrics'
5f222e8f3a Instrumentation: Add Process Resource Usage Metrics
7204679f48 Merge branch 'upstream-KWSys' into instrumentation-proc-metrics
431a794a66 KWSys 2026-08-27 (8f4afc3e)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12381
2026-08-28 09:17:39 -04:00
Martin Duffy 5f222e8f3a Instrumentation: Add Process Resource Usage Metrics
Issue: #26675, #27742
2026-08-27 10:24:25 -04:00
Maxime HaselbauerandTyler Yankee 135c7aa1f1 ctest: Add test rerun index "(run XX/YY)" to output
This makes the output more user friendly when using CTest's repeat
options (`until-fail`, `until-pass` `after-timeout`).

Closes: #28039
Co-authored-by: Tyler Yankee <tyler.yankee@kitware.com>
2026-08-21 09:11:52 -04:00
Brad King fc5ff503cf Merge topic 'ctest-json-test-prop-raw'
572e4b5d2a ctest: Add --show-only=json-v1-raw option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12288
2026-08-04 10:53:33 -04:00
Arha Gatram 572e4b5d2a ctest: Add --show-only=json-v1-raw option
This option changes the JSON value field for test properties to use the
unparsed string value.

Fixes: #27958
2026-08-03 09:36:11 -07:00
Tyler Yankee c0e1d332af cmCTestSubmitHandler: Use cmJSONState to read responses
This approach will be more portable.
2026-08-01 11:38:10 -04:00
Brad King 90cfce949a Merge topic 'discover-tests-crash'
1b2f3287f7 GoogleTest: Restore toleration of odd test PROPERTIES count
6147180017 discover_tests: Require properties to be key-value pairs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12350
2026-07-31 08:52:06 -04:00
Daniel Pfeifer 6147180017 discover_tests: Require properties to be key-value pairs
Issue: #28004
2026-07-30 12:21:23 -04:00
Brad King 4b88240b64 Merge topic 'ctest_test-label-and'
257865e1d4 CTest: Make ctest_test() label filters multi-value (AND)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12321
2026-07-28 09:50:30 -04:00
AJIOB dba12b5e82 instrumentation: support long output list of files
Fixes: #27942
2026-07-26 23:04:22 +03:00
Daksh Mamodiya 257865e1d4 CTest: Make ctest_test() label filters multi-value (AND)
The ctest(1) command line allows repeating -L/-LE to form an AND
filter over test labels, but the ctest_test() and ctest_memcheck()
scripting commands accepted only a single INCLUDE_LABEL/EXCLUDE_LABEL
value, so a dashboard script could not express that filter.

The label-matching engine already stores the include/exclude
expressions as vectors and applies them with AND semantics; only the
command binding was single-value.  Change both keywords to multi-value
(NonEmpty<vector<string>>) and hand the collected list straight to the
engine.  ctest_memcheck() gains the same behavior for free, since it
inherits the option set.

Fixes : #27497
2026-07-24 21:27:58 +02:00
Arha Gatram 4c2d06e69b CTest: Add support for relative paths in GENERATED_RESOURCE_SPEC_FILE 2026-07-22 09:49:28 -07:00
Brad King 5868009096 Merge topic 'ctest-windows-jobserver-client'
79331d5865 CTest: Add Windows job server client

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12297
2026-07-22 11:23:38 -04:00
Brad King 40089c5db6 Merge topic 'ctest-configure-avoid-unused-cli-warning'
72eac83626 ctest: Avoid unused-cli warning when propagating SITE/BUILDNAME

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12299
2026-07-21 15:15:30 -04:00
Zack Galbreath 72eac83626 ctest: Avoid unused-cli warning when propagating SITE/BUILDNAME
Commit 433721b7a7 (ctest: Pass CTEST_SITE/CTEST_BUILD_NAME to configure
step, 2026-06-15) updated ctest_configure() to pass `-DSITE=...` and
`-DBUILDNAME=...` to the configure command whenever CTEST_SITE or
CTEST_BUILD_NAME are set. Projects that don't include the CTest module never
reference these cache variables, causing CMake to report an unused-cli warning.

Use `-C <initial-cache>` instead of `-D` to seed SITE/BUILDNAME. Cache entries
set using `-C` are not tracked by CMake's unused-cli diagnostic, so projects
using the CTest module still get DartConfiguration.tcl populated correctly,
while projects that never reference SITE/BUILDNAME no longer see the warning.

Fixes: #27953
2026-07-20 13:21:00 -04:00
Daksh Mamodiya 79331d5865 CTest: Add Windows job server client
Use a named semaphore polled from the libuv event loop to share GNU Make
job slots on Windows. Cover token ordering, bounded draining, and
teardown, and document the new support.

Fixes: #27968
2026-07-20 16:40:11 +02:00
Daksh Mamodiya d5d2741414 Instrumentation: Write ctest snippet on interrupted test run
Extend the interrupt-flush mechanism already used for cmakeBuild and
cmakeInstall to ctest, so that a user interrupt (e.g. Ctrl+C) still writes
the overall ctest instrumentation snippet, marked with interruptSignal,
before exiting.

On interrupt CTest stops scheduling further tests at every launch site,
skips the postCTest hook, forces a non-zero exit status, and preserves the
checkpoint file so that a later 'ctest -F' can resume the interrupted test
set.

Issue: #27859
2026-07-14 20:40:09 +02:00
Brad King ccfef28ee4 Merge topic 'ctest-launch-signal-passthrough'
899e7231ab CTest: Report failure when a launched command is killed by a signal

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12248
2026-07-08 10:41:17 -04:00
Daksh Mamodiya 899e7231ab CTest: Report failure when a launched command is killed by a signal
cmCTestLaunch, which backs ctest --launch and ctest --instrument,
derived its exit code from the child's SpawnResult and ExitStatus but
ignored TermSignal.  On POSIX a command killed by a signal reports
ExitStatus 0 and TermSignal N, so the launcher reported success for a
crashed or killed command, masking failed compile/link/custom rules on
the dashboard and in instrumentation snippets.

Classify the child with the ordered triple SpawnResult, TermSignal,
ExitStatus, mapping a signal-killed child to a non-zero exit code.
Native Windows is unaffected: abnormal termination already arrives as a
non-zero exit code there.

Fixes: #27921
2026-07-06 15:46:37 +02:00
Tyler Yankee fd395b25b5 ctest: Improve colorization in output
Refactor CTest's logging to replace custom color code handling with the
infrastructure introduced in commit 329d755dbd (StdIo: Add a Terminal
abstraction to print color text, 2025-05-06).

Avoid ANSI escape sequences in files passed to `--output-log-file`.

Fixes: #27915
2026-07-03 10:02:43 -04:00
Martin Duffy e11b5827c3 ctest: Add --out-of-date option for running out of date tests
Add an --out-of-date option to ctest which runs only those tests with
recorded build dependencies whose timestamps are newer than the timestamp
at which the test last finished.

Fixes: #27614
2026-06-30 11:31:35 -04:00
Zack Galbreath 433721b7a7 ctest: Pass CTEST_SITE/CTEST_BUILD_NAME to configure step
When performing the configure step in dashboard client mode, propagate
`CTEST_SITE` and `CTEST_BUILD_NAME` as the `SITE` and `BUILDNAME`
respective cache variables.

This causes the values recorded in `DartConfiguration.tcl` to match those
specified by the user, allowing subsequent ctest calls to reuse them
automatically.
2026-06-15 10:56:11 -04:00
Martin Duffy 1a85245496 instrumentation: Optionally Record Command Output
Add `stdout`  and `stderr` reporting to instrumentation for `compile`, `link`,
`custom`, `install` and `test` snippets when the `captureOutput` option is
enabled.

Fixes: #26704
2026-06-04 10:42:04 -04:00
Brad King 850ca80ce8 Merge topic 'ctest_submit_parts'
a798a84b22 ctest: add new variable CTEST_SUBMIT_PARTS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12135
2026-06-04 10:08:20 -04:00
Zack Galbreath a798a84b22 ctest: add new variable CTEST_SUBMIT_PARTS
This new variable allows dashboard client users to specify what parts
to submit.
2026-06-03 10:45:42 -04:00
Daniel Pfeifer 1da072eacb discover_tests: Add TEST_LIST to CTest command 2026-06-02 21:05:04 +02:00
Zack Galbreath 7dc39e7221 ctest: prioritize presets over existing DartConfiguration.tcl commands
CMake writes ConfigureCommand and MakeCommand entries into
DartConfiguration.tcl when configuring a project that uses the CTest module.

These values prevented users from being able to use configure/build presets
in dashboard client mode from a pre-configured build directory.

This commit updates ctest_configure() and ctest_build() to ignore
CTEST_CONFIGURE_COMMAND / CTEST_BUILD_COMMAND when a preset is specified.
This allows the requested preset to be honored.
2026-05-29 11:40:47 -04:00
Zack Galbreath 63b6e7d785 ctest: allow dashboard clients to specify presets via variables
Add variables to support specifying PRESET and PRESETS_FILE to
dashboard clients from the command-line.
2026-05-27 09:33:06 -04:00
Brad King e0b79bddd0 Merge topic 'ctest-llvm-cov'
e0ac166e7b ctest: Parse Clang Source code coverage files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12049
2026-05-15 10:16:00 -04:00
Brad King 08bf1b6985 Merge topic 'ctest_commands_presets_file'
08dc82ceb3 ctest: add PRESETS_FILE option to CTest commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12042
2026-05-14 08:53:25 -04:00
Joseph Snyder e0ac166e7b ctest: Parse Clang Source code coverage files
Introduce the capability to use the Clang Source code coverage capability
to generate coverage information for a submission to CDash.

This handler will:
  * Recursively glob the binary directory for coverage files (`*.profdata`)
  * Use the `llvm-profdata` tool to merge all found files into a single
    `default.profdata` file
  * Recursively glob the binary directory for .o files
  * Use the `llvm-cov export` capability to parse the coverage information
    found for each object file

Since the coverage information contains branch coverage, add new attributes
to the CoverageLog Line object to capture the number of branches that are
covered and uncovered

See documentation page here
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
2026-05-14 08:35:49 -04:00
Brad King af2c38b289 Merge topic 'instrumentation-disabled-test-fix'
94a83b412c Merge branch 'backport-instrumentation-disabled-test-fix'
180746bc7c instrumentation: Don't instrument disabled tests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12033
2026-05-13 13:31:45 -04:00
Brad King d7257109e7 Merge topic 'ctest-update-version-options'
585e0d5878 ctest_update: Add options VERSION_ONLY and VERSION_OVERRIDE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12038
2026-05-13 13:28:21 -04:00
Zack Galbreath 08dc82ceb3 ctest: add PRESETS_FILE option to CTest commands
Allow CTest script authors to use presets from arbitrary files.
2026-05-12 15:49:39 -04:00
Brad King 94a83b412c Merge branch 'backport-instrumentation-disabled-test-fix' 2026-05-12 11:10:40 -04:00
Martin Duffy 180746bc7c instrumentation: Don't instrument disabled tests
Fixes: #27791
2026-05-12 11:09:58 -04:00