diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-14 17:07:00 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-16 16:25:59 +0300 |
commit | a1904e802c61e5b5a0cef8cc9de9bf7c2c617552 (patch) | |
tree | e5c71ef187ca93be40a8228b59295358261873bf /render-test/main.cpp | |
parent | 1165f62df6dd344d83f88a6396cfba153e9271f3 (diff) | |
download | qtlocation-mapboxgl-a1904e802c61e5b5a0cef8cc9de9bf7c2c617552.tar.gz |
[test-runner] Introduce mapbox-gl-native test expectations
The `mapbox-gl-native`-specific render tests expected results will
be stored at the `render-test/expected/` subfolder.
Test runner will automatically put new expected results there if
invoked with `UPDATE=true`.
Diffstat (limited to 'render-test/main.cpp')
-rw-r--r-- | render-test/main.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/render-test/main.cpp b/render-test/main.cpp index 35f0cdea30..db141649f2 100644 --- a/render-test/main.cpp +++ b/render-test/main.cpp @@ -7,6 +7,7 @@ #include "runner.hpp" #include <random> +#include <regex> #define ANSI_COLOR_RED "\x1b[31m" #define ANSI_COLOR_GREEN "\x1b[32m" @@ -18,6 +19,25 @@ #define ANSI_COLOR_LIGHT_GRAY "\x1b[90m" #define ANSI_COLOR_RESET "\x1b[0m" +namespace { + +TestPaths makeTestPaths(mbgl::filesystem::path stylePath) { + auto defaultExpectations = stylePath; + defaultExpectations.remove_filename(); + const static std::regex regex{ TestRunner::getBasePath() }; + auto platformExpectations = std::regex_replace(defaultExpectations.string(), regex, TestRunner::getPlatformExpectationsPath()); + assert(!defaultExpectations.empty()); + assert(!platformExpectations.empty()); + + return { + std::move(stylePath), + std::move(defaultExpectations), + std::move(platformExpectations) + }; +} + +} // namespace + int main(int argc, char** argv) { bool recycleMap; bool shuffle; @@ -31,11 +51,12 @@ int main(int argc, char** argv) { const auto ignores = parseIgnores(); // Recursively traverse through the test paths and collect test directories containing "style.json". - std::vector<mbgl::filesystem::path> testPaths; + 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.push_back(testPath); + testPaths.emplace_back(makeTestPaths(testPath)); } } } @@ -67,7 +88,7 @@ int main(int argc, char** argv) { std::string& status = metadata.status; std::string& color = metadata.color; - id = testPath.remove_filename().string(); + id = testPath.defaultExpectations.string(); id = id.substr(rootLength + 1, id.length() - rootLength - 2); bool shouldIgnore = false; |