|
|
@@ -3,6 +3,7 @@
|
|
|
#include <filesystem>
|
|
|
#include <fstream>
|
|
|
#include <iostream>
|
|
|
+#include <regex>
|
|
|
#include <unordered_set>
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
@@ -27,12 +28,31 @@ using jvalidate::schema::Version;
|
|
|
|
|
|
using testing::TestWithParam;
|
|
|
|
|
|
+class Glob {
|
|
|
+private:
|
|
|
+ std::regex re_;
|
|
|
+
|
|
|
+public:
|
|
|
+ explicit Glob(std::string glob) {
|
|
|
+ for (size_t i = glob.find('.'); i != std::string::npos; i = glob.find('.', i + 2)) {
|
|
|
+ glob.insert(glob.begin() + i, '\\');
|
|
|
+ }
|
|
|
+ for (size_t i = glob.find('*'); i != std::string::npos; i = glob.find('*', i + 2)) {
|
|
|
+ glob.insert(glob.begin() + i, '.');
|
|
|
+ }
|
|
|
+ re_ = std::regex(glob);
|
|
|
+ }
|
|
|
+
|
|
|
+ bool operator==(std::string const & str) const { return std::regex_search(str, re_); }
|
|
|
+};
|
|
|
+
|
|
|
struct RecursiveTestFilter {
|
|
|
- std::unordered_set<std::string> whitelist;
|
|
|
- std::unordered_set<std::string> blacklist;
|
|
|
+ std::vector<Glob> whitelist;
|
|
|
+ std::vector<Glob> blacklist;
|
|
|
|
|
|
bool accepts(std::string const & str) const {
|
|
|
- return not blacklist.contains(str) and (whitelist.empty() or whitelist.contains(str));
|
|
|
+ return std::count(blacklist.begin(), blacklist.end(), str) == 0 and
|
|
|
+ (whitelist.empty() or std::count(whitelist.begin(), whitelist.end(), str) > 0);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -104,7 +124,9 @@ protected:
|
|
|
tokens[i - 1] += tokens[i];
|
|
|
tokens.erase(tokens.begin() + i);
|
|
|
}
|
|
|
- into.insert(tokens.begin(), tokens.end());
|
|
|
+ for (auto &tok : tokens) {
|
|
|
+ into.emplace_back(tok);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
for (std::string_view str : testing::internal::GetArgvs()) {
|