diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-04-02 20:16:15 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-04-02 20:29:50 (GMT) |
commit | 060d2ce26914e7a5ff6632869556f3c67d88940c (patch) | |
tree | 82c437bfc9767eda7fb1eb302043ac3a03f757c8 /Source/CTest | |
parent | e95d274f3031180103ee8c88f51432c8d93a5a02 (diff) | |
download | CMake-060d2ce26914e7a5ff6632869556f3c67d88940c.zip CMake-060d2ce26914e7a5ff6632869556f3c67d88940c.tar.gz CMake-060d2ce26914e7a5ff6632869556f3c67d88940c.tar.bz2 |
CTest: Add CTEST_RESOURCE_SPEC_FILE variable
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestTestCommand.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 37 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 2 |
3 files changed, 30 insertions, 16 deletions
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 0f9b695..c5f683d 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -52,6 +52,13 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() } } this->CTest->SetTimeOut(timeout); + + const char* resourceSpecFile = + this->Makefile->GetDefinition("CTEST_RESOURCE_SPEC_FILE"); + if (this->ResourceSpecFile.empty() && resourceSpecFile) { + this->ResourceSpecFile = resourceSpecFile; + } + cmCTestGenericHandler* handler = this->InitializeActualHandler(); if (!this->Start.empty() || !this->End.empty() || !this->Stride.empty()) { handler->SetOption( diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 1feac3a..f9850ef 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -408,7 +408,9 @@ int cmCTestTestHandler::ProcessHandler() // start the real time clock auto clock_start = std::chrono::steady_clock::now(); - this->ProcessDirectory(passed, failed); + if (!this->ProcessDirectory(passed, failed)) { + return -1; + } auto clock_finish = std::chrono::steady_clock::now(); @@ -545,22 +547,11 @@ bool cmCTestTestHandler::ProcessOptions() if (val) { this->ExcludeFixtureCleanupRegExp = val; } - this->SetRerunFailed(cmIsOn(this->GetOption("RerunFailed"))); - val = this->GetOption("ResourceSpecFile"); if (val) { - this->UseResourceSpec = true; this->ResourceSpecFile = val; - auto result = this->ResourceSpec.ReadFromJSONFile(val); - if (result != cmCTestResourceSpec::ReadFileResult::READ_OK) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Could not read/parse resource spec file " - << val << ": " - << cmCTestResourceSpec::ResultToString(result) - << std::endl); - return false; - } } + this->SetRerunFailed(cmIsOn(this->GetOption("RerunFailed"))); return true; } @@ -1261,7 +1252,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, std::string& value, return ret; } -void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, +bool cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, std::vector<std::string>& failed) { this->ComputeTestList(); @@ -1285,7 +1276,17 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, } else { parallel->SetTestLoad(this->CTest->GetTestLoad()); } - if (this->UseResourceSpec) { + if (!this->ResourceSpecFile.empty()) { + this->UseResourceSpec = true; + auto result = this->ResourceSpec.ReadFromJSONFile(this->ResourceSpecFile); + if (result != cmCTestResourceSpec::ReadFileResult::READ_OK) { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Could not read/parse resource spec file " + << this->ResourceSpecFile << ": " + << cmCTestResourceSpec::ResultToString(result) + << std::endl); + return false; + } parallel->InitResourceAllocator(this->ResourceSpec); } @@ -1345,6 +1346,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, this->ElapsedTestingTime = std::chrono::steady_clock::now() - elapsed_time_start; *this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl; + + return true; } void cmCTestTestHandler::GenerateTestCommand( @@ -1743,6 +1746,10 @@ void cmCTestTestHandler::GetListOfTests() if (cmSystemTools::GetErrorOccuredFlag()) { return; } + const char* specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE"); + if (this->ResourceSpecFile.empty() && specFile) { + this->ResourceSpecFile = specFile; + } cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Done constructing a list of tests" << std::endl, this->Quiet); diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 8a49ec2..55cecb6 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -278,7 +278,7 @@ private: /** * Run the tests for a directory and any subdirectories */ - void ProcessDirectory(std::vector<std::string>& passed, + bool ProcessDirectory(std::vector<std::string>& passed, std::vector<std::string>& failed); /** |