diff options
author | Brad King <brad.king@kitware.com> | 2019-10-29 18:21:38 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-10-29 19:14:36 (GMT) |
commit | 39ac8b4eb5c5ea99cf1053bd37e76d811f5122fc (patch) | |
tree | 284a7da62ff3285b1809618e822dd1c693ec03dd /Source | |
parent | 80c2c9d14cf1c1a8f162e119bd00d5f483a94af2 (diff) | |
download | CMake-39ac8b4eb5c5ea99cf1053bd37e76d811f5122fc.zip CMake-39ac8b4eb5c5ea99cf1053bd37e76d811f5122fc.tar.gz CMake-39ac8b4eb5c5ea99cf1053bd37e76d811f5122fc.tar.bz2 |
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.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmCTestRunTest.cxx | 13 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 22 | ||||
-rw-r--r-- | Source/cmCTest.h | 1 | ||||
-rw-r--r-- | Source/ctest.cxx | 2 |
4 files changed, 33 insertions, 5 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index ce9e13b..ba14653 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -345,7 +345,9 @@ bool cmCTestRunTest::NeedsToRerun() if ((this->RerunMode == cmCTest::Rerun::UntilFail && this->TestResult.Status == cmCTestTestHandler::COMPLETED) || (this->RerunMode == cmCTest::Rerun::UntilPass && - this->TestResult.Status != cmCTestTestHandler::COMPLETED)) { + this->TestResult.Status != cmCTestTestHandler::COMPLETED) || + (this->RerunMode == cmCTest::Rerun::AfterTimeout && + this->TestResult.Status == cmCTestTestHandler::TIMEOUT)) { this->RunAgain = true; return true; } @@ -745,10 +747,11 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) // then it will never print out the completed / total, same would // got for run until pass. Trick is when this is called we don't // yet know if we are passing or failing. - if ((this->RerunMode != cmCTest::Rerun::UntilPass && - this->NumberOfRunsLeft == 1) || - (this->RerunMode == cmCTest::Rerun::UntilPass && - this->NumberOfRunsLeft == this->NumberOfRunsTotal) || + bool const progressOnLast = + (this->RerunMode != cmCTest::Rerun::UntilPass && + this->RerunMode != cmCTest::Rerun::AfterTimeout); + if ((progressOnLast && this->NumberOfRunsLeft == 1) || + (!progressOnLast && this->NumberOfRunsLeft == this->NumberOfRunsTotal) || this->CTest->GetTestProgressOutput()) { outputStream << std::setw(getNumWidth(total)) << completed << "/"; outputStream << std::setw(getNumWidth(total)) << total << " "; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 7276d98..20445b0 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1884,6 +1884,28 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, } } + if (this->CheckArgument(arg, "--repeat-after-timeout")) { + if (i >= args.size() - 1) { + errormsg = "'--repeat-after-timeout' requires an argument"; + return false; + } + if (this->Impl->RerunMode != cmCTest::Rerun::Never) { + errormsg = "At most one '--repeat-*' option may be used."; + return false; + } + i++; + long repeat = 1; + if (!cmStrToLong(args[i], &repeat)) { + errormsg = + "'--repeat-after-timeout' given non-integer value '" + args[i] + "'"; + return false; + } + this->Impl->RepeatTests = static_cast<int>(repeat); + if (repeat > 1) { + this->Impl->RerunMode = cmCTest::Rerun::AfterTimeout; + } + } + if (this->CheckArgument(arg, "--test-load") && i < args.size() - 1) { i++; unsigned long load; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index c6b8928..bef0f8d 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -438,6 +438,7 @@ public: Never, UntilFail, UntilPass, + AfterTimeout, }; Rerun GetRerunMode() const; diff --git a/Source/ctest.cxx b/Source/ctest.cxx index f716d7a..2659e30 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -102,6 +102,8 @@ static const char* cmDocumentationOptions[][2] = { "Require each test to run <n> times without failing in order to pass" }, { "--repeat-until-pass <n>", "Allow each test to run up to <n> times in order to pass" }, + { "--repeat-after-timeout <n>", + "Allow each test to run up to <n> times if it times out" }, { "--max-width <width>", "Set the max width for a test name to output" }, { "--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1." }, { "--hardware-spec-file <file>", "Set the hardware spec file to use." }, |