X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=source%2Ftesting%2FTestManager.cpp;fp=source%2Ftesting%2FTestManager.cpp;h=b83f8d4ce566b6a2ff08ac0e8325f9145cef521c;hp=e90d20d35d69af67911503680e5660658042b669;hb=f34b8069233e9e09208339bb79d8576c1ff962e1;hpb=cef452116c2966d7eaa65ff31ee7613bf3ae1b93 diff --git a/source/testing/TestManager.cpp b/source/testing/TestManager.cpp index e90d20d..b83f8d4 100644 --- a/source/testing/TestManager.cpp +++ b/source/testing/TestManager.cpp @@ -299,6 +299,36 @@ TestCase *TestManager::getTestCase(unsigned int id, const std::string &descripti return result; } +bool TestManager::clearTestCase(std::string &result, unsigned int id) { + result = ""; + + if (!tests()) { + result = "There are not programmed test cases to be removed"; + return false; + } + + test_pool_it it = ((id != -1) ? a_testPool.find(id) : a_currentTestIt); + if (it == a_testPool.end()) { + result = "Test case id provided not found"; + return false; + } + + if (!it->second->safeToClear()) { + result = "Test case id provided has running-thread steps. Check for stuck external procedures or try later."; + return false; + } + + a_testPool.erase(it); + + auto key1_it = a_key1TestCaseMap.find(it->second->getKey()); + if (key1_it != a_key1TestCaseMap.end()) a_key1TestCaseMap.erase(key1_it); + auto key2_it = a_key2TestCaseMap.find(it->second->getKey()); + if (key2_it != a_key2TestCaseMap.end()) a_key2TestCaseMap.erase(key2_it); + + result = "Provided test case has been dropped"; + return true; +} + bool TestManager::clearPool(std::string &result) { result = "";