153 Commits

Author SHA1 Message Date
Marc Chevrier
c688b401d3 cmstd: Modernize CMake system headers
Provide a standardized way to handle the C++ "standard" headers
customized to be used with current CMake C++ standard constraints.
Offer under directory `cm` headers which can be used as direct
replacements of the standard ones.  For example:

    #include <cm/string_view>

can be used safely for CMake development in place of the `<string_view>`
standard header.

Fixes: #19491
2019-09-20 10:01:37 -04:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Regina Pfeifer
d25a5a7ec9 clang-tidy: modernize-use-auto
Set the MinTypeNameLength option to an impossibly high value in order
to limit the diagnostics to iterators.  Leave new expressions and cast
expressions for later.
2019-09-10 22:21:41 +02:00
Brad King
89479bde94 Merge topic 'pvs-cleanup'
7fe3e874d5 cmCPackLog: Fix support for multiple log message tags
74f2c0ea56 cmCTestTestHandler: Remove extra layer of parentheses
7c2767ef3b cmCTestMultiProcessHandler: Explain testRun ownership in comments
303e813438 CTest: Simplify some boolean conditions
51565abe79 cmMessageCommand: Remove extra layer of parentheses
b1cfaf7b91 cmVSSetupHelper: Remove unused SmartBSTR copy operations
3f4c4e7afe cmVSSetupHelper: Fix SmartBSTR copy operations
a8ca5aea94 cmMakefileTargetGenerator: Check for null before using a pointer
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Acked-by: Artalus <artalus-mail@yandex.ru>
Merge-request: !3715
2019-08-26 10:51:11 -04:00
Brad King
303e813438 CTest: Simplify some boolean conditions
Directly compare two boolean values instead of spelling out accepted
combinations.

Issue: #19610
2019-08-26 09:43:46 -04:00
Sebastian Holtermann
9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00
Kitware Robot
54e9d38c28 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP 2019-08-09 10:41:44 -04:00
Gabor Bencze
4f1dec86a5 CTest: Add SKIP_REGULAR_EXPRESSION test property 2019-07-18 11:52:05 -04:00
Marc Chevrier
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx 2019-07-14 15:37:30 +02:00
Stephen Manz
adcbdb143c CTest: Clean up stdout and logfile output for Pass/Fail regex
For pass regex, display only the element that was found, rather
than all elements
Rename loop variable for fail regex, from pass to fail
For consistency, add space in output for pass
Add tests that find and don't find PASS_REGULAR_EXPRESSION, and a test
that finds FAIL_REGULAR_EXPRESSION, whose LastTest.log files are checked
using *-check.cmake.
2019-07-09 09:01:04 -07:00
Regina Pfeifer
670d27da64 cmCTest: Remove friend declarations 2019-03-18 22:25:50 +01:00
Gregor Jasny
1166aa5ce7 ctest: refactor some code 2019-03-05 19:20:29 +01:00
Brad King
c0ba467d2d Merge topic 'cmCTestRunTest-compress'
948c55857e cmCTestRunTest: Remove duplicated compression logic

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2946
2019-02-12 08:28:24 -05:00
Regina Pfeifer
948c55857e cmCTestRunTest: Remove duplicated compression logic 2019-02-10 15:47:15 +01:00
Zsolt Parragi
440b08e4f0 CTest: Represent process exit codes as 64-bit signed integer
Exit code constants on Windows, such as `STATUS_NO_MEMORY` do not fit in
a 32-bit signed integer type.  They do fit in an unsigned 32-bit type,
but for compatibility with UNIX semantics we treat exit codes as signed.
Use a 64-bit signed integer to handle both.
2019-02-08 14:49:20 -05:00
Michael Wegner
b3d5b8b3fb ctest: Add option for live progress summary in terminal 2018-09-26 11:47:49 -04:00
Michael Wegner
62fbe5002a cmCTestRunTest: Thread number of completed tests through start APIs 2018-09-25 08:20:57 -04:00
Michael Wegner
6a285bb737 cmCTestRunTest: Buffer test result output before printing 2018-09-25 08:20:57 -04:00
Brad King
ed71ec7579 CTest: Improve stop-time implementation
The CTestTestStopTime test has been failing sporadically because the
stop time causes the first internal test to have a timeout short enough
that we might hit it and start the second test just before the stop time
is reached.  Instead we should track when a timeout is shortened in
order to stay within the stop time.  If a test times out for this reason
then we should consider the stop time reached and not start any more
tests.
2018-09-12 10:59:55 -04:00
Vitaly Stakhovsky
69ca85cc7f Remove unnecessary c_str() in RegularExpression::find calls 2018-08-07 15:28:24 -04:00
luz.paz
be28106880 Fix misc. typos
Found via `codespell` and `grep`
2018-06-04 10:32: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
e11410bb0c Merge topic 'cmWorkingDirectory_success_checking'
5901699672 cmDepends: Remove attempt to change directory that always fails
e60e4dfc88 cmWorkingDirectory: Check success of current dir changes
e654622aee Tests: Add --build-and-test test case
a865f0beb2 Tests: Confirm test working dir set successfully

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1817
2018-03-09 07:43:54 -05:00
Craig Scott
e60e4dfc88 cmWorkingDirectory: Check success of current dir changes 2018-03-08 20:07:14 +11:00
Brad King
6be53c6695 CTest: Add options to control test process affinity to CPUs
In commit v2.8.0~170 (ENH: Added ctest test options PROCESSORS and
RUN_SERIAL, 2009-09-07) CTest learned to track the number of processors
allocated to running tests in order to balance it against the desired
level of parallelism.  Extend this idea by introducing a new
`PROCESSOR_AFFINITY` test property to ask that CTest run a test
with the CPU affinity mask set.  This will allow a set of tests
that are running concurrently to use disjoint CPU resources.
2018-03-05 09:21:32 -05:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00
Wouter Klouwen
ff62b00522 CTest: add safe conversion from cmDuration to integer types
A problem area by recent refactoring of time to std::chrono has been the
unsafe conversion from duration<double> to std::chrono::seconds, which
is of an unspecified integer type.

This commit adds a template function that for a given type provides a
safe conversion, effectively clamping a duration<double> into what fits
safely in that type. A specialisation for int and unsigned int are
provided.

It changes the protential problem areas to use this safe function.
2018-01-23 10:05:12 -05:00
Wouter Klouwen
695951bc46 CTest: introduce cmDuration
This commit introduces cmDuration as a typedef for
std::chrono::duration<double, std::ratio<1>>. It is less verbose and
provides for a point to put future common functionality for durations.

No functional change intended.
2018-01-23 10:04:38 -05:00
Bryon Bean
b5e21d7d2e CTest: Re-implement test process handling using libuv
Co-Author: Brad King <brad.king@kitware.com>
2018-01-10 10:19:14 -05:00
Bryon Bean
fcebff75f9 cmProcess: Use explicit enum for process exit exception
Translate the values from KWSys Process.
2018-01-10 10:19:14 -05:00
Bryon Bean
3dd2edf4ab cmProcess: Use explicit enum for process state
Translate the values from KWSys Process.
2018-01-10 10:19:14 -05:00
Bryon Bean
c13b68e61f cmCTestRunTest: Modernize constructor and destructor decls 2018-01-10 10:19:13 -05:00
Brad King
61ab5a8ef4 cmCTestMultiProcessHandler: Check stop time more directly
Avoid creating a cmCTestRunTest instance if the stop time has been
reached.  If the stop time occurs in the small time between creating an
instance and computing the child process timeout, we will simply compute
a zero timeout.  This is already done for the case that we StartAgain
after the stop time.
2018-01-08 12:55:01 -05:00
Brad King
4c199a4c28 cmCTestRunTest: Subsume ResolveTimeout into only call site 2018-01-08 12:55:01 -05:00
Brad King
2567e5df69 cmCTest: Refactor stop time calculations
Calculate the stop time up front instead of re-parsing its string for
every test.
2018-01-08 12:55:00 -05:00
Brad King
1138feb38f cmCTest: Remove unused member LastStopTimeout
This member was added by commit v2.8.2~285 (Better detection of
stop_time being passed, 2010-03-19), but its logic has no effect.
The member is only used for comparison against a value to which
it was just assigned.
2018-01-08 12:55:00 -05:00
Brad King
1f5b2a8de9 Merge topic 'fix-ctest-chrono'
ba6caafa CTest: Use integer-representable value for "infinite" timeout
548e8f6f CTest: Simplify std::chrono::duration<double> conversion to double
de0035fd cmCTestBuildAndTestHandler: Convert timeout to std::chrono::duration
687a26b7 CTest: Fix regression in build-and-test timeout forwarding
e770b1b8 CTest: Fix regression in build-and-test timeout compuatation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: dublet <github@dublet.org>
Merge-request: !1574
2017-12-12 08:02:33 -05:00
Brad King
ba6caafa42 CTest: Use integer-representable value for "infinite" timeout
Refactoring in commit 66419bc046 (CTest: convert timeouts to
std::chrono::duration, 2017-11-20) changed out "infinite" timeout to a
value not representable by a 64-bit integer.  This causes undefined
behavior when e.g. KWSys Process converts the duration to a `long` to
interact with system APIs.  Use the old `1.0e7` maximum value.
2017-12-11 10:41:48 -05:00
Brad King
548e8f6ffe CTest: Simplify std::chrono::duration<double> conversion to double
The ratio of ticks to seconds for this type is 1, so we can just use its
`count()` directly.  This also avoids converting through the integer
representation of `std::chrono::milliseconds`, which has a much smaller
allowed range.

Drop our `cmsysProcess_SetTimeout` wrapper as it is now very thin.
2017-12-08 11:09:49 -05:00
Brad King
51045535e8 Merge topic 'fix-ctest-chrono'
be470278 CTest: Fix regression in test timeout compuatation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: dublet <github@dublet.org>
Merge-request: !1568
2017-12-07 10:45:47 -05:00
Brad King
be4702781d CTest: Fix regression in test timeout compuatation
Refactoring in commit 66419bc046 (CTest: convert timeouts to
std::chrono::duration, 2017-11-20) accidentally changed the logic used
to compute the timeout for a test when it starts.  It incorrectly limits
the maximum possible timeout to 2 minutes rather than 2 minutes less
than the total allowed test time remaining.  Update the new logic to
restore the original behavior.

Avoid subtracting 2 minutes from our "infinite" timeout value to avoid
creating very large timeouts that are not "infinite" and may exceed
integer type ranges.
2017-12-07 08:33:19 -05:00
Brad King
b8e7af979d Merge topic 'ctest-chrono'
66419bc0 CTest: convert timeouts to std::chrono::duration
923b8fad IWYU: Add mappings for std::enable_if on chrono durations

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1513
2017-12-05 08:12:52 -05:00
Wouter Klouwen
66419bc046 CTest: convert timeouts to std::chrono::duration
This commit continues the refactoring of CTest to adopt std::chrono.
After the last sets of changes that introduced std::chrono::steady_clock
and std::chrono::system_clock respectively, it makes sense to have all
the timeouts be stored as std::chrono::duration.

No functional change intended.
2017-12-04 10:43:14 -05:00
Craig Scott
fbe91dba6a CTest: Check failed fixture dependencies before test command and args 2017-11-29 07:27:20 +11:00
Wouter Klouwen
e8a4036e96 CTest: use std::chrono::steady_clock for time keeping
It was reported in issue #17345 that CTest does not use monotonic time
to report test duration. Monotonic clocks are not affected by large NTP
adjustments or things like daylight savings time.

As CMake 3.10 requires C++11, which introduced std::chrono, this commit
moves the time keeping in CTest from cmSystemTools::GetTime() to
std::chrono::steady_clock.

Fixes: #17345
2017-11-14 13:30:14 +00:00
Pavel Solodovnikov
37d9387be3 Replace empty-string comparisons with checking against empty(). 2017-09-21 11:23:19 +03:00
Pavel Solodovnikov
5db3aac111 Meta: replace empty-string assignments with clear(). 2017-09-16 02:26:49 +03:00
Pavel Solodovnikov
63f6fd144e Meta: modernize old-fashioned loops to range-based for (CTest).
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
2017-09-14 16:11:58 +03:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Daniel Pfeifer
ca2233e31f IWYU: Mark cmConfigure.h with pragma: keep
Also remove `#include "cmConfigure.h"` from most source files.
2017-08-26 07:41:04 +02:00