Commit Graph

54 Commits

Author SHA1 Message Date
Brad King
54c5654f7d ctest: Optionally terminate tests with a custom signal on timeout
CTest normally terminates test processes on timeout using `SIGKILL`.
Offer tests a chance to exit gracefully, on platforms supporting POSIX
signals, by setting `TIMEOUT_SIGNAL_{NAME,GRACE_PERIOD}` properties.

Fixes: #17288
2023-06-02 06:51:13 -04:00
Brad King
1edf138506 Tests/RunCMake: Update cmake_minimum_required versions
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.5 where possible.

Also, remove `cmake_minimum_required()` and `project()` calls from
individual cases where they are handled by `CMakeLists.txt`.
2023-02-11 06:24:22 -05:00
friendlyanon
0661de58d8 ctest(1): Add CTEST_NO_TESTS_ACTION env var
This environment variable provides a default value for the
--no-tests=<action> command line argument.
2023-01-13 13:33:39 +01:00
Brad King
3b6c1c1a3b Tests: Factor out RunCMake ctest environment isolation
Some RunCMake tests unset some environment variables that affect ctest's
behavior before running it.  Any test using the RunCTest helper needs to
do this, so do it in the helper itself.

Issue: #24153
2022-11-14 11:05:56 -05:00
Brad King
bd30d20bc3 Tests: Add cases covering bad ctest output truncation types
Issue: #23869
2022-09-07 12:23:08 -04:00
Frank Winklmeier
cb55d5e730 RunCMakeTest: fix Truncation test definition
The `ctest_test` and `CTestCommandLine` truncation tests had multiple problems:
- escape expected result string to avoid regex matching
- specify the truncation size
- pass the truncation mode correctly into the test definition
- use unique test names

Issue: #23868
2022-09-05 13:42:40 +02:00
Kyle Edwards
313ea361b0 CMake: Use FindPython instead of FindPythonInterp to build CMake itself
Fixes: #23444
2022-04-21 14:23:36 -04:00
Brad King
5059db7c17 Tests: Fix CMake syntax warning in RunCMake.CTestCommandLine
Fix a regex added in the test by commit 140704d443 (ctest: add option
for output truncation, 2022-03-07).
2022-03-10 08:05:56 -05: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
Brad King
7c5a120c38 Tests: Add case covering both ctest subdirectory commands
CTest re-implements the `subdirs` and `add_subdirectory` commands.
Verify that they both work.
2021-12-08 11:36:50 -05:00
Joseph Snyder
5d5610b04f CTest: Exit coverage handling early if no binary dir
Check for the existence of the Binary directory string before checking
for coverage files.  If the directory is not specified, write an error
message and do not do any checking.

Fixes: #22102
2021-06-02 08:41:09 -04: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
Brad King
82e40607a4 ctest: Display test "WAITING" messages only in extra-verbose mode
These messages are incidental scheduling output.  Avoid cluttering
the normal verbose output showing tests starting and finishing.
2021-04-06 14:48:14 -04:00
Asit Dhal
dbcf86d24d Ctest: Support build tree on command line
Fixes: #21268
2020-12-17 05:01:03 +01:00
Asit Dhal
5a6c199069 ctest: Provide hints about inspecting test failures
Fixes: #20955
2020-12-01 01:53:03 +01:00
Kevin Puetz
6a6f1d1edd CTest: exit nonzero after message(SEND_ERROR|FATAL_ERROR)
Fixes: #21004
2020-08-26 11:27:05 -04:00
Brad King
f9fbc78cd6 Merge topic 'ctest_stop_on_failure_16628'
e89aeba5c4 ctest: add option --stop-on-failure

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4630
2020-04-22 08:38:33 -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
Brad King
e03d3c08f0 CTest: Fix '-T MemCheck' command-line support for sanitizers
In commit 49948f7221 (ctest_memcheck: Add support for ThreadSanitizer,
2014-07-07, v3.1.0-rc1~322^2~1) and commit 1e005eadbc (CTest: Fix
MemoryCheckType from 'ctest -T MemCheck', 2014-07-15, v3.1.0-rc1~298^2),
the `CMakeCommand` internal setting was left set only when using `ctest
-S` scripts.  Instead simply use CTest's corresponding CMake directly
without passing it through an internal setting.

Fixes: #20584
2020-04-17 08:36:01 -04: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
Julien Jomier
e6f758be6d ctest: Populate CTEST_CONFIGURATION_TYPE from the -C command line when set 2019-12-09 13:10:59 -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
016601e5e6 Merge branch 'backport-ctest-resource-groups' 2019-11-05 12:59:16 -05:00
Brad King
af9ed543b0 CTest: Rename PROCESSES test property to RESOURCE_GROUPS
The `PROCESSES` test property name added for CMake 3.16 is too close to
the existing `PROCESSORS` test property.  Furthermore, the property in
principle specifies groups of resources organized in a way that is
meaningful to a particular test.  The groups may often correspond to
processes but they could have other meanings.  Since the property name
`PROCESSES` has not been in a final 3.16 release yet, simply rename it
to `RESOURCE_GROUPS`.

Fixes: #19914
2019-11-05 12:08:01 -05:00
Brad King
30e79bb4a3 Tests: Extend RunCMake.CTestCommandLine internal timeout for valgrind
A case added by commit 39ac8b4eb5 (ctest: Add --repeat-after-timeout
option, 2019-10-29) includes a success-case timeout of 2 seconds.  That
is too short when running under valgrind, so extend it to 5 seconds.
2019-11-04 11:22:58 -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
d1f100a415 CTest: Add Json output for PROCESSES property 2019-10-02 09:33:54 -04:00
Brad King
a6b01b7d45 Merge topic 'ctest-json-REQUIRED_FILES'
5778880d20 CTest: Fix --show-only=json-v1 output with REQUIRED_FILES property

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3719
2019-08-23 10:07:32 -04:00
Brad King
5778880d20 CTest: Fix --show-only=json-v1 output with REQUIRED_FILES property
Fixes: #19629
2019-08-22 15:07:43 -04:00
Gabor Bencze
d7955d4e5d Tests: Create test for SKIP_REGULAR_EXPRESSION test property 2019-07-18 11:52:10 -04: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
Brad King
cae9d2a61a CTest: Teach --show-only= to reject unknown values 2019-01-17 12:01:07 -05:00
Brad King
7370b02c36 CTest: Teach --show-only=json-v1 to filter out not-available tests
Avoid exposing the internal special value that we use to track tests not
available in the tested configuration.  This also prevents clients from
having to do the filtering themselves.
2019-01-17 12:01:07 -05:00
Brad King
62fec84ad7 Tests: Fix RunCMake.CTestCommandLine case when no python is found
Do not try to run the python checks if the python executable is
not available.
2019-01-17 12:01:07 -05:00
Brad King
75a7a23746 Tests: Rename RunCMake.CTestCommandLine show-only test cases
The current name was chosen from an earlier design iteration of the
command-line option name.  Rename the case to match the final name.
2019-01-17 10:57:51 -05:00
Brad King
fecbc87608 Tests: Fix RunCMake.CTestCommandLine to actually check json-v1
Add a file missing from commit 67209a9291 (Tests: Add cases for ctest
--show-only=json-v1, 2018-11-01) to actually hook up the content check.
2019-01-16 14:10:15 -05:00
Brad King
67209a9291 Tests: Add cases for ctest --show-only=json-v1 2019-01-10 07:37:35 -05:00
Brad King
86e8315482 CTest: Restore inheritance of stdin by test processes
Since commit v3.11.0-rc1~117^2 (CTest: Re-implement test process
handling using libuv, 2017-12-10) we do not give the child test
processes any stdin.  Prior to that change we let the child test
processes inherit stdin from ctest itself.  Tests that run serially
might be able to use the real stdin meaningfully, so restore that
behavior and add a test case.

Fixes: #18591
2018-11-15 08:08:56 -05:00
Brad King
292ec157b6 CTest: Fix --test-load regression
The `ctest --test-load` option is implemented in `StartNextTests` by not
starting any tests when the load is too high and instead sleeping and
then returning.  Prior to commit v3.11.0-rc1~117^2 (CTest: Re-implement
test process handling using libuv, 2017-12-10) our outer loop in
`RunTests` would immediately call `StartNextTests` again.  However, now
the `uv_run` loop may simply terminate if there are no tests running
because no events are left pending.

Fix this by converting the sleep in `StartNextTests` into a libuv timer
that it starts instead.  This avoids leaving `uv_run` with no pending
events.  In the case that there are other running tests this also allows
CTest to detect when they finish even if it during the wait period where
we previously slept.

This regression was not caught by the test suite because it only
verified that we do not start new tests when the load was too high and
not that we proceed to start tests when the load drops.  Revise the test
suite to cover both.

Fixes: #18338
2018-09-10 07:32:16 -04: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
Betsy McPhail
7904b659ea Tests: Remove incorrect use of 'test-timeout' option 2017-11-10 07:52:05 -05:00
Bill Hoffman
5b829c89b8 CTest: Weight reported test times by PROCESSORS in summaries
This commit changes the times reported by labels and subprojects to be
weighted by the PROCESSORS property. It is reported with `sec*proc`
instead of just `sec`.
2017-09-08 10:03:01 -04:00
Sylvain Joubert
a105863772 CTest: Properly reset output to avoid duplication with --repeat-until-fail 2017-01-12 11:32:58 +01:00
Zack Galbreath
f725b20be3 Update tests that expect uncompressed output
Pass --no-compressed-output to ctest for tests that expect uncompressed output.
2016-11-08 15:58:29 -05:00
Brad King
e61973e1ab CTest: Fix regression in handling of a RUN_SERIAL test that fails
Refactoring in commit v3.4.0-rc1~390^2~1 (cmCTestMultiProcessHandler:
Refactor RUN_SERIAL implementation, 2015-06-01) forgot to update a code
path for cleaning up after a failed RUN_SERIAL test.  This causes an
infinite loop after a RUN_SERIAL test fails.  Fix it and add a test.
2015-10-23 09:55:25 -04:00
Roman Wüger
fd47df4503 CTest: Add options to limit output of passed and failed tests
Add ctest command-line options:

  --test-output-size-passed <n>
  --test-output-size-failed <n>

to set the amount of test output to store in Test.xml as a command-line
dashboard client.
2015-09-18 11:32:06 -04:00
Betsy McPhail
42747fcc73 CTest: Show the number of tests for each label in the summary 2015-07-06 10:06:35 -04:00
Betsy McPhail
f62d301b92 ctest: Optionally avoid starting tests that may exceed a given CPU load
Add a TestLoad setting to CTest that can be set via a new --test-load
command-line option, CTEST_TEST_LOAD variable, or TEST_LOAD option to
the ctest_test command.  Teach cmCTestMultiProcessHandler to measure
the CPU load and avoid starting tests that may take more than the
spare load currently available.  The expression

 <current_load> + <test_processors> <= <max-load>

must be true to start a new test.

Co-Author: Zack Galbreath <zack.galbreath@kitware.com>
2015-06-30 10:21:37 -04:00
Brad King
721b7e3e56 CTest: Capture test stdout/stderr through one pipe (#15600)
Use the KWSys Process "MergeOutput" option to give each test child
process the same pipe for both stdout and stderr.  This allows natural
merging of stdout and stderr together instead of merging on arbitrary
buffered read boundaries as before.
2015-06-03 08:47:49 -04:00