diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-08-28 11:57:40 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-08-28 13:55:36 +0300 |
commit | 9a42bdd7aea0f23e892f2874be6c18acf2b0f0ae (patch) | |
tree | adbf60a0bb2f4298159c0042206b370f7c77d1c7 /render-test/main.cpp | |
parent | 6ee69e7493d8c3905d20ab7908543ed0b2d623b1 (diff) | |
download | qtlocation-mapboxgl-9a42bdd7aea0f23e892f2874be6c18acf2b0f0ae.tar.gz |
[core] Add filtering option to test-runner
This change adds filter command line option to render test runner,
so that test can be filtered by providing regular expression, for instance:
mbgl-render-test -f .*hillshade.*
Diffstat (limited to 'render-test/main.cpp')
-rw-r--r-- | render-test/main.cpp | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/render-test/main.cpp b/render-test/main.cpp index c7b0b6be55..3ab48fe5b2 100644 --- a/render-test/main.cpp +++ b/render-test/main.cpp @@ -3,13 +3,11 @@ #include <mbgl/util/run_loop.hpp> #include <mbgl/util/io.hpp> -#include "filesystem.hpp" #include "metadata.hpp" #include "parser.hpp" #include "runner.hpp" #include <random> -#include <regex> #define ANSI_COLOR_RED "\x1b[31m" #define ANSI_COLOR_GREEN "\x1b[32m" @@ -36,49 +34,18 @@ void operator delete(void* ptr, size_t) noexcept { AllocationIndex::deallocate(ptr); } -namespace { - -TestPaths makeTestPaths(mbgl::filesystem::path stylePath) { - std::vector<mbgl::filesystem::path> expectations{ stylePath }; - expectations.front().remove_filename(); - - const static std::regex regex{ TestRunner::getBasePath() }; - for (const std::string& path : TestRunner::getPlatformExpectationsPaths()) { - expectations.emplace_back(std::regex_replace(expectations.front().string(), regex, path)); - assert(!expectations.back().empty()); - } - - return { - std::move(stylePath), - std::move(expectations) - }; -} - -} // namespace - int main(int argc, char** argv) { bool recycleMap; bool shuffle; uint32_t seed; std::string testRootPath; - std::vector<std::string> ids; + std::vector<TestPaths> testPaths; - std::tie(recycleMap, shuffle, seed, testRootPath, ids) = parseArguments(argc, argv); + std::tie(recycleMap, shuffle, seed, testRootPath, testPaths) = parseArguments(argc, argv); const std::string::size_type rootLength = testRootPath.length(); const auto ignores = parseIgnores(); - // Recursively traverse through the test paths and collect test directories containing "style.json". - std::vector<TestPaths> testPaths; - testPaths.reserve(ids.size()); - for (const auto& id : ids) { - for (auto& testPath : mbgl::filesystem::recursive_directory_iterator(mbgl::filesystem::path(id))) { - if (testPath.path().filename() == "style.json") { - testPaths.emplace_back(makeTestPaths(testPath)); - } - } - } - if (shuffle) { printf(ANSI_COLOR_YELLOW "Shuffle seed: %d" ANSI_COLOR_RESET "\n", seed); |