Prechádzať zdrojové kódy

test: fix suite filter

Sam Jaffe 1 rok pred
rodič
commit
cf1582b217
1 zmenil súbory, kde vykonal 19 pridanie a 8 odobranie
  1. 19 8
      tests/selfvalidate_test.cxx

+ 19 - 8
tests/selfvalidate_test.cxx

@@ -94,6 +94,21 @@ protected:
   bool skip_case(std::string const & desc) const { return not s_case_filter.accepts(desc); }
 
   static void SetUpTestCase() {
+    auto tokenize = [](auto & into, std::string const & in) {
+      std::vector<std::string> tokens;
+      testing::internal::SplitString(in, ':', &tokens);
+      for (size_t i = 1; i < tokens.size();) {
+        if (tokens[i].front() != ' ') {
+          ++i;
+          continue;
+        }
+        tokens[i - 1] += ":";
+        tokens[i - 1] += tokens[i];
+        tokens.erase(tokens.begin() + i);
+      }
+      into.insert(tokens.begin(), tokens.end());
+    };
+
     for (std::string_view str : testing::internal::GetArgvs()) {
       RecursiveTestFilter * ptr;
       if (str.starts_with("--json_suite_filter=")) {
@@ -107,18 +122,14 @@ protected:
       }
 
       size_t const pos_end = str[0] == '-' ? 0 : str.find(":-");
-      size_t const neg_end =
+      size_t const neg_start =
           pos_end == 0 ? 1 : (pos_end == std::string::npos ? pos_end : pos_end + 2);
 
       if (pos_end > 0) {
-        std::vector<std::string> tokens;
-        testing::internal::SplitString(std::string(str.substr(0, pos_end)), ':', &tokens);
-        ptr->whitelist.insert(tokens.begin(), tokens.end());
+        tokenize(ptr->whitelist, std::string(str.substr(0, pos_end)));
       }
-      if (neg_end != std::string::npos) {
-        std::vector<std::string> tokens;
-        testing::internal::SplitString(std::string(str.substr(neg_end)), ':', &tokens);
-        ptr->blacklist.insert(tokens.begin(), tokens.end());
+      if (neg_start != std::string::npos) {
+        tokenize(ptr->blacklist, std::string(str.substr(neg_start)));
       }
     }
   }