summaryrefslogtreecommitdiff
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-10-29 14:45:21 -0400
committerBrad King <brad.king@kitware.com>2019-10-29 15:10:12 -0400
commit80c2c9d14cf1c1a8f162e119bd00d5f483a94af2 (patch)
tree273a15083c42453ee3265a3ce8263bf7a74a3e3e /Source/cmCTest.cxx
parent0187e522448c8fe92c15d4a983afac36950d1d59 (diff)
downloadcmake-80c2c9d14cf1c1a8f162e119bd00d5f483a94af2.tar.gz
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>
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx35
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 10b7646664..7276d98fba 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -84,7 +84,7 @@ struct cmCTest::Private
};
int RepeatTests = 1; // default to run each test once
- bool RepeatUntilFail = false;
+ cmCTest::Rerun RerunMode = cmCTest::Rerun::Never;
std::string ConfigType;
std::string ScheduleType;
std::chrono::system_clock::time_point StopTime;
@@ -1839,11 +1839,16 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
this->SetParallelLevel(plevel);
this->Impl->ParallelLevelSetInCli = true;
}
+
if (this->CheckArgument(arg, "--repeat-until-fail")) {
if (i >= args.size() - 1) {
errormsg = "'--repeat-until-fail' 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)) {
@@ -1853,7 +1858,29 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
}
this->Impl->RepeatTests = static_cast<int>(repeat);
if (repeat > 1) {
- this->Impl->RepeatUntilFail = true;
+ this->Impl->RerunMode = cmCTest::Rerun::UntilFail;
+ }
+ }
+
+ if (this->CheckArgument(arg, "--repeat-until-pass")) {
+ if (i >= args.size() - 1) {
+ errormsg = "'--repeat-until-pass' 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-until-pass' given non-integer value '" + args[i] + "'";
+ return false;
+ }
+ this->Impl->RepeatTests = static_cast<int>(repeat);
+ if (repeat > 1) {
+ this->Impl->RerunMode = cmCTest::Rerun::UntilPass;
}
}
@@ -2852,9 +2879,9 @@ int cmCTest::GetTestRepeat() const
return this->Impl->RepeatTests;
}
-bool cmCTest::GetRepeatUntilFail() const
+cmCTest::Rerun cmCTest::GetRerunMode() const
{
- return this->Impl->RepeatUntilFail;
+ return this->Impl->RerunMode;
}
void cmCTest::SetBuildID(const std::string& id)