Commit Graph

214 Commits

Author SHA1 Message Date
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Martin Duffy
fc1d55f6a5 instrumentation: Add preBuild and postBuild hooks for ninja
Allows instrumentation indexing and callbacks to occur at the start or end of
every `ninja` invocation.
2025-02-04 11:15:11 -05:00
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Martin Duffy
097d4fd1b5 instrumentation: Collect and record project build system metrics
Add a feature for collecting build instrumentation for CMake projects.

Issue: #26099
2025-01-15 09:16:50 -05:00
Brad King
5aed3ee49d cmSystemTools: Add GetLogicalWorkingDirectory
Track the current working directory with symbolic links preserved.
2024-11-03 08:26:36 -05:00
Daniel Pfeifer
b3c01f70b5 ctest: Print documentation without creating a cmCTest instance 2024-10-23 23:22:05 +02:00
Brad King
c7d11a77e4 ctest: Remove outdated optimization of tests running ctest itself
In commit 2c2291bbe0 (ENH: add new feature to ctest so that it can
cmake, build and run a test executable, 2004-01-07, v2.4.0~3483) ctest
was taught to recognize tests that run ctest itself and run them
internally instead of spawning a new process.  This optimization was
removed by commit b9daa192af (ENH: Refactored CTest test execution code
into an object, 2009-08-19, v2.8.0~276) `cmCTestRunTest` replaced
`cmCTestTestHandler::ProcessOneTest`, which was eventually removed by
commit 5a5cc52230 (Fixed conversion warning on 64 bit machines,
2009-08-31, v2.8.0~241).  Since then the optimization was only left in
`--build-and-test` mode, likely by accident, where it makes little
difference.  Remove it to simplify the code.

Also drop the `--force-new-ctest-process` option, originally added by
commit 9255e40d81 (ENH: Add a way to force ctest to be a new process,
2004-05-10, v2.4.0~3101), since it no longer does anything.
2024-10-16 14:13:46 -04:00
Brad King
a66dfe22d7 Merge topic 'ctest-windows-std-handles'
e4d0169107 ctest: Fix spurious build failures with CTEST_USE_LAUNCHERS on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9598
2024-06-14 09:27:06 -04:00
Brad King
e4d0169107 ctest: Fix spurious build failures with CTEST_USE_LAUNCHERS on Windows
Remove the stdio handle inheritance suppression originally added by
commit f262298bb0 (... do not inherit pipes in child procs for ctest so
it can kill them, 2007-09-11, v2.6.0~1136).  It's not clear what problem
it was trying to solve, was only done in `ctest` and not `cmake`, and
since commit 9c3ffe2474 (BUG: fix problem with stdout and stderr not
showing up in ms dos shells, 2007-09-25, v2.6.0~1066) has not been done
in `ctest` launched under interactive consoles.

Furthermore, the code has been spuriously breaking stdio when `ctest` is
started with both stdout and stderr connected to the same pipe, such as
when `ctest --launch` is used under `ninja`.  This is because it used
`DuplicateHandle` with `DUPLICATE_CLOSE_SOURCE` on the stdout handle and
then the stderr handle.  If the handles are the same, then the stderr
handle becomes invalid in between these operations, leading to
likely-undefined behavior.  Since commit 96b3dd329e
(cmCTestLaunchReporter: Replace cmsysProcess with cmUVProcessChain,
2023-07-26, v3.28.0-rc1~138^2~2) this became more noticeable because
`uv_spawn` performs additional verification on stdio handles.

This could be fixed by instead suppressing inheritance via

    SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0);

However, the functionality no longer seems necessary, so remove it.
2024-06-14 07:32:29 -04:00
Brad King
5de1e21659 ctest: Allow passing -j without value to choose a contextual default
Under job server integration, added by commit 80fe56c481 (ctest: Add
support for running under a make job server on POSIX systems,
2023-11-15, v3.29.0-rc1~324^2), use a very high default so that
parallelism is effectively limited only by available job server tokens.

Otherwise, choose a default limit based on the number of processors.

Also allow passing `0` to specify unbounded parallelism.

Fixes: #25739
2024-03-10 11:41:39 -04:00
Alex Neundorf
dbacc1d5a8 ctest: add command line option to exclude tests listed in a given file
Add `--exclude-from-file <filename>` to exclude the tests listed in the
given file.

Issue: #25455
2024-01-25 12:37:56 -05:00
Alex Neundorf
022f20f663 ctest: add command line option to run the tests listed in a given file
Add `--tests-from-file <filename>` to run only the tests listed in the
given file.  The test names must match exactly, no regexps or something.
The listed tests can still be filtered with a regexp using -R.

Issue: #25455
2024-01-25 12:37:16 -05:00
Matthew Woehlke
20adf8cfce ctest: allow HTTP headers via command line
Add ability to specify HTTP headers via `ctest -T Submit`.
2024-01-08 14:11:40 -05:00
Alex Turbov
69918b07e1 cmDocumentationEntry: Drop all user provided ctors for C++ >= 14
There is no need for them cuz:

- the last field has a default value
- all static instances use 2 arguments convertible to `std::string`
- "dynamic" instances used for _Generator_ doc entries access
  fields diectly using default constructed instance

Moreover, compiler may generate move ctor/assign when needed.
2022-11-17 16:37:12 +04:00
Alex Turbov
74b735dea8 cmDocumentation: char*[][2]cmDocumentationEntry[N]
Use fixed size arrays of `cmDocumentationEntry` items instead of
open arrays of two `char` pointers when describe program options
help screens.

Also, drop `const char*[][2]` overloads of methods of
`cmDocumentation` and `cmDocumentationSection` classes in the sake
of generic (template) appenders introduced earlier.
2022-11-17 16:37:11 +04:00
Alex Turbov
8e2a03c078 ctest.cxx: Eliminate redundand trenary operator 2022-11-17 16:37:11 +04:00
Alex Turbov
9ae6569bfe ctest.cxx: Optimize std::ostream::operator<< calls 2022-11-17 16:37:10 +04:00
Alex Turbov
fddc48dd26 ctest.cxx: Use anonymous namespace instead of static arrays 2022-11-17 16:37:10 +04:00
Frank Winklmeier
140704d443 ctest: add option for output truncation
Add `--test-output-truncation` to `ctest`. This option can be used to
customize which part of the test output is being truncated. Currently
supported values are `tail`, `middle` and `head`.

Also add equivalent `CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION` variable.

Fixes: #23206
2022-03-08 08:18:02 -05:00
Zack Galbreath
25bf514447 ctest: Add support for writing test results in JUnit XML format
Addresses #18654
2021-04-26 08:55:22 -04:00
Adriaan de Groot
44ad3f0b7f ctest: Support multiple -L and -LE options to mean "AND"
Fixes: #21087
2021-03-28 12:04:05 +11:00
Brad King
6fa3647023 ctest: Add support for '--prefix=<prefix>' form of the argument
The main `cmake --preset` argument for configure presets supports both
forms, so support it for `ctest --preset` too.

Fixes: #21855
2021-02-23 09:22:00 -05:00
Sam Freed
676ecf0d37 cmake-presets: Add build and test presets
Fixes: #21391
2021-02-01 11:59:40 -05:00
Asit Dhal
dbcf86d24d Ctest: Support build tree on command line
Fixes: #21268
2020-12-17 05:01:03 +01:00
Brad King
90b39a5209 cmConsoleBuf: Factor out cout/cerr console buffer management 2020-10-14 12:08:06 -04:00
Brad King
f1fdd15863 clang-format: Fix include block order in ctest.cxx and cpack.cxx 2020-10-14 12:06:50 -04:00
Johnny Jazeix
e89aeba5c4 ctest: add option --stop-on-failure
To stop the tests once one has failed

Fixes: #16628
2020-04-20 23:05:15 +02:00
Stefan Dinkelacker
a39d4139d0 Add --no-tests=<[error|ignore]> option to CTest
If no tests were found, the default behavior of CTest is to always log an
error message but to return an error code in script mode only. This option
unifies the behavior of CTest by either returning an error code if no tests
were found or by ignoring it.

Signed-off-by: Stefan Dinkelacker <s.dinkelacker@dkfz-heidelberg.de>
2020-01-31 18:17:13 +01:00
Craig Scott
9e9787f19a Merge topic 'ctest-repeat'
32c165d263 CTest: Consolidate '--repeat-* n' options as `--repeat *:n`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4053
2019-11-19 15:48:38 -05:00
Brad King
32c165d263 CTest: Consolidate '--repeat-* n' options as --repeat *:n
Combine `--repeat-until-fail`, `--repeat-until-pass`, and
`--repeat-after-timeout` to create a single `--repeat <mode>:<n>`
option.  Retain `--repeat-until-fail` too because that has been
available in previous releases.
2019-11-15 10:08:33 -05:00
Brad King
a4c19cb895 Windows: Restore suppression of error report popups in CI builds
On Windows, libuv uses `_CrtSetReportHook` to install a handler it uses
to suppress assertions on invalid file descriptors in `_get_osfhandle`.
This removes the handler we install in CI environments to suppress
interactive popups.  Move installation of our handler to after libuv is
initialized so that our handler is actually used.

Unfortunately this also removes libuv's handler and so may cause Debug
builds under CI to abort on invalid file descriptors instead of simply
converting them to `INVALID_HANDLE_VALUE`.  If this becomes a problem
we may need to modify libuv to make its hook more configurable.
2019-11-15 09:23:47 -05:00
Brad King
016601e5e6 Merge branch 'backport-ctest-resource-groups' 2019-11-05 12:59:16 -05:00
Craig Scott
a7c1e15cc4 CTest: Rename hardware -> resources for CMake variables, command options
Only changes the user-visible effects of renaming hardware
allocation to resource allocation. Code changes are the minimum
needed to achieve that.
2019-11-05 12:08:35 -05:00
Brad King
39ac8b4eb5 ctest: Add --repeat-after-timeout option
Add an option to re-run tests if they timeout.  This will help tolerate
sporadic timeouts on busy machines.
2019-10-29 15:14:36 -04:00
Brad King
80c2c9d14c ctest: Add --repeat-until-pass option
Add an option to re-run tests if they fail.  This will help tolerate
sporadic failures.

Issue: #17010
Co-Author: Ben Boeckel <ben.boeckel@kitware.com>
Co-Author: Chuck Atkins <chuck.atkins@kitware.com>
2019-10-29 15:10:12 -04:00
Kyle Edwards
e34de0691b CTest: Allocate hardware to tests 2019-10-02 09:33:54 -04:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Zack Galbreath
2a71a0390c ctest: rename TRACK to GROUP
Update command-line options, script variables, and documentation to use
the term "group" instead of "track". The old terms are still available
for now, but they are now undocumented.

This makes our terminology more consistent with CDash. The goal of this
change is to make it more clear to our users how CTest and CDash interact
with each other.
2019-08-22 13:10:18 -04:00
Kitware Robot
54e9d38c28 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP 2019-08-09 10:41:44 -04:00
Brad King
c85524a94a Ensure stdin, stdout, and stderr pipes are always open
On non-Windows platforms libuv assumes that file descriptors 0-2 are
always used for standard pipes and never for anything else.  Otherwise,
libuv may re-use one of these descriptors and then fail an assertion
when closing it.  Similarly, On Windows platforms our ConsoleBuf
implementation assumes that the standard handles are always open.

If CMake is run with any standard pipes closed, open them with
`/dev/null` or `NUL` to satisfy these assumptions.

Fixes: #19219
2019-05-02 14:34:58 -04:00
Regina Pfeifer
b172a81d55 cmCTest: Use concrete accessor functions for TestingHandlers 2019-03-20 11:39:14 -04:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
Justin Goshi
fc41a95f08 CTest: Add --show-only[=format] option to print test info
format can be 'human' to print the current text format or 'json-v1' to
print the test object model in json format and is useful for IDEs who
want to gather information about the tests. Defaults to 'human' format.
2019-01-10 07:37:32 -05:00
Regina Pfeifer
3e0eb3307f Help: clarify documentation of ctest --timeout 2018-12-09 22:10:31 +01:00
Michael Wegner
b3d5b8b3fb ctest: Add option for live progress summary in terminal 2018-09-26 11:47:49 -04:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Brad King
98628de812 Extend libuv file translate mode workaround to all executables
Since libuv commit v1.14.1~7 (win: add uv__once_init() calls,
2017-08-30) the libuv initialization of the file translate mode may take
place even if we do not use a uv loop.  This change was included in our
libuv update commit f4a26c748b (libuv 2018-01-19).  Therefore use of
libuv even through `cmSystemTools::GetRealPath` in any executable may
trigger its file translate mode setting.

Factor out the logic added to `cmake.exe` by commit v3.9.0-rc4~10^2
(cmake: Fix default file translate mode when using libuv, 2017-06-13)
and re-use to initialize all executables.

Issue: #16962
2018-01-23 09:29:07 -05:00
Betsy McPhail
e80dc2ad7f cmCTest: Remove dead code
The option 'ctest-config' is ignored.
2017-11-07 14:15:20 -05:00
Matthias Maennich
79b8c3802a Improve several occurrences of vector::push_back in loops
Fix issues diagnosed by clang-tidy by pre-allocating the vector capacity
before the loop [performance-inefficient-vector-operation].

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-28 07:23:41 -04:00