| 208 | } |
| 209 | |
| 210 | bool Options::is_test_name_matching(const std::string& test_name) { |
| 211 | if (!testpat.empty()) { |
| 212 | bool positive_patterns = false; |
| 213 | bool match_found = false; |
| 214 | for (const auto& type_pattern: testpat) { |
| 215 | const auto& type = type_pattern.first; |
| 216 | const auto& pattern = type_pattern.second; |
| 217 | if (type == MT_NOT) { // Negative pattern |
| 218 | if (test_name.find(pattern) != std::string::npos) { |
| 219 | // Test matches a negative pattern, should not run |
| 220 | return false; |
| 221 | } |
| 222 | } else { |
| 223 | // Positive pattern |
| 224 | positive_patterns = true; |
| 225 | if (!match_found) { |
| 226 | // No match found yet, test with current pattern |
| 227 | if (((type == MT_ANY) && (test_name.find(pattern) != std::string::npos)) || |
| 228 | ((type == MT_FIRST) && (test_name.find(pattern) == 0))) |
| 229 | match_found = true; |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if (positive_patterns && match_found) { |
| 235 | // Some positive pattern matched the test name |
| 236 | return true; |
| 237 | } else if (positive_patterns && !match_found) { |
| 238 | // No positive pattern matched the test name |
| 239 | return false; |
| 240 | } else { |
| 241 | // No positive patterns, but no negative pattern ruled the test name out |
| 242 | return true; |
| 243 | } |
| 244 | } else { |
| 245 | // With no test-patterns, all tests should run. |
| 246 | return true; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /// Run a single test, returning true iff the test succeeded |
| 251 | bool run_test(Base* test, unsigned int test_seed, const Options& options, std::ostream& ostream) { |