diff options
Diffstat (limited to 'Source/CTest/cmCTestTestHandler.cxx')
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 88 |
1 files changed, 37 insertions, 51 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 0d0237f..4e63654 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2,20 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" -#include "cmCTest.h" -#include "cmCTestBatchTestHandler.h" -#include "cmCTestMultiProcessHandler.h" -#include "cmCommand.h" -#include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" -#include "cmMakefile.h" -#include "cmState.h" -#include "cmSystemTools.h" -#include "cmXMLWriter.h" -#include "cm_auto_ptr.hxx" -#include "cm_utf8.h" -#include "cmake.h" - #include <algorithm> #include <cmsys/Base64.h> #include <cmsys/Directory.hxx> @@ -31,6 +17,21 @@ #include <string.h> #include <time.h> +#include "cmCTest.h" +#include "cmCTestBatchTestHandler.h" +#include "cmCTestMultiProcessHandler.h" +#include "cmCommand.h" +#include "cmGeneratedFileStream.h" +#include "cmGlobalGenerator.h" +#include "cmMakefile.h" +#include "cmState.h" +#include "cmStateSnapshot.h" +#include "cmSystemTools.h" +#include "cmXMLWriter.h" +#include "cm_auto_ptr.hxx" +#include "cm_utf8.h" +#include "cmake.h" + class cmExecutionStatus; class cmCTestSubdirCommand : public cmCommand @@ -58,8 +59,6 @@ public: */ std::string GetName() const CM_OVERRIDE { return "subdirs"; } - cmTypeMacro(cmCTestSubdirCommand, cmCommand); - cmCTestTestHandler* TestHandler; }; @@ -139,8 +138,6 @@ public: */ std::string GetName() const CM_OVERRIDE { return "add_subdirectory"; } - cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand); - cmCTestTestHandler* TestHandler; }; @@ -213,8 +210,6 @@ public: */ std::string GetName() const CM_OVERRIDE { return "add_test"; } - cmTypeMacro(cmCTestAddTestCommand, cmCommand); - cmCTestTestHandler* TestHandler; }; @@ -253,8 +248,6 @@ public: */ std::string GetName() const CM_OVERRIDE { return "set_tests_properties"; } - cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand); - cmCTestTestHandler* TestHandler; }; @@ -725,7 +718,7 @@ void cmCTestTestHandler::ComputeTestList() // Now create a final list of tests to run int cnt = 0; inREcnt = 0; - std::string last_directory = ""; + std::string last_directory; ListOfTests finalList; for (it = this->TestList.begin(); it != this->TestList.end(); it++) { cnt++; @@ -804,8 +797,9 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const // Prepare some maps to help us find setup and cleanup tests for // any given fixture - typedef std::set<ListOfTests::const_iterator> TestIteratorSet; - typedef std::map<std::string, TestIteratorSet> FixtureDependencies; + typedef ListOfTests::const_iterator TestIterator; + typedef std::multimap<std::string, TestIterator> FixtureDependencies; + typedef FixtureDependencies::const_iterator FixtureDepsIterator; FixtureDependencies fixtureSetups; FixtureDependencies fixtureDeps; @@ -816,14 +810,14 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const const std::set<std::string>& setups = p.FixturesSetup; for (std::set<std::string>::const_iterator depsIt = setups.begin(); depsIt != setups.end(); ++depsIt) { - fixtureSetups[*depsIt].insert(it); - fixtureDeps[*depsIt].insert(it); + fixtureSetups.insert(std::make_pair(*depsIt, it)); + fixtureDeps.insert(std::make_pair(*depsIt, it)); } const std::set<std::string>& cleanups = p.FixturesCleanup; for (std::set<std::string>::const_iterator depsIt = cleanups.begin(); depsIt != cleanups.end(); ++depsIt) { - fixtureDeps[*depsIt].insert(it); + fixtureDeps.insert(std::make_pair(*depsIt, it)); } } @@ -866,17 +860,15 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const // associated with the required fixture. If any of those setup // tests fail, this test should not run. We make the fixture's // cleanup tests depend on this test case later. - FixtureDependencies::const_iterator setupIt = - fixtureSetups.find(requiredFixtureName); - if (setupIt != fixtureSetups.end()) { - for (TestIteratorSet::const_iterator sIt = setupIt->second.begin(); - sIt != setupIt->second.end(); ++sIt) { - const std::string& setupTestName = (**sIt).Name; - tests[i].RequireSuccessDepends.insert(setupTestName); - if (std::find(tests[i].Depends.begin(), tests[i].Depends.end(), - setupTestName) == tests[i].Depends.end()) { - tests[i].Depends.push_back(setupTestName); - } + std::pair<FixtureDepsIterator, FixtureDepsIterator> setupRange = + fixtureSetups.equal_range(requiredFixtureName); + for (FixtureDepsIterator sIt = setupRange.first; + sIt != setupRange.second; ++sIt) { + const std::string& setupTestName = sIt->second->Name; + tests[i].RequireSuccessDepends.insert(setupTestName); + if (std::find(tests[i].Depends.begin(), tests[i].Depends.end(), + setupTestName) == tests[i].Depends.end()) { + tests[i].Depends.push_back(setupTestName); } } @@ -889,17 +881,11 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const // Already added this fixture continue; } - FixtureDependencies::const_iterator fixtureIt = - fixtureDeps.find(requiredFixtureName); - if (fixtureIt == fixtureDeps.end()) { - // No setup or cleanup tests for this fixture - continue; - } - - const TestIteratorSet& testIters = fixtureIt->second; - for (TestIteratorSet::const_iterator depsIt = testIters.begin(); - depsIt != testIters.end(); ++depsIt) { - ListOfTests::const_iterator lotIt = *depsIt; + std::pair<FixtureDepsIterator, FixtureDepsIterator> fixtureRange = + fixtureDeps.equal_range(requiredFixtureName); + for (FixtureDepsIterator it = fixtureRange.first; + it != fixtureRange.second; ++it) { + ListOfTests::const_iterator lotIt = it->second; const cmCTestTestProperties& p = *lotIt; if (!addedTests.insert(p.Name).second) { @@ -1663,7 +1649,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() int numFiles = static_cast<int>(cmsys::Directory::GetNumberOfFilesInDirectory(dirName)); std::string pattern = "LastTestsFailed"; - std::string logName = ""; + std::string logName; for (int i = 0; i < numFiles; ++i) { std::string fileName = directory.GetFile(i); |