summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-10-09 13:26:28 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-10-09 14:35:08 +0300
commitb4e0224a5786f1d362b2b6b7e7f536be8bb98981 (patch)
tree9571c0aac878b7fff55ccff11726bcc73093fa81
parentd0281e3ca4686ca52b1b4d886dad4e8de27bdcfa (diff)
downloadqtlocation-mapboxgl-b4e0224a5786f1d362b2b6b7e7f536be8bb98981.tar.gz
[test runner] Fix finding of expected images paths
Before this change, the found paths to the expected images erroneously included the path to the `metrics.json` file (if this file was present) leading to raising of an unhandled exception.
-rw-r--r--render-test/parser.cpp15
-rw-r--r--render-test/parser.hpp3
-rw-r--r--render-test/runner.cpp4
3 files changed, 16 insertions, 6 deletions
diff --git a/render-test/parser.cpp b/render-test/parser.cpp
index 802c3c7f55..024adf91d1 100644
--- a/render-test/parser.cpp
+++ b/render-test/parser.cpp
@@ -291,9 +291,8 @@ std::string serializeMetrics(const TestMetrics& metrics) {
return s.GetString();
}
-std::vector<std::string> readExpectedEntries(const mbgl::filesystem::path& base) {
- static const std::regex regex(".*expected.*.png|.*expected.*.json");
-
+namespace {
+std::vector<std::string> readExpectedEntries(const std::regex& regex, const mbgl::filesystem::path& base) {
std::vector<std::string> expectedImages;
for (const auto& entry : mbgl::filesystem::directory_iterator(base)) {
if (entry.is_regular_file()) {
@@ -305,7 +304,17 @@ std::vector<std::string> readExpectedEntries(const mbgl::filesystem::path& base)
}
return expectedImages;
}
+} // namespace
+
+std::vector<std::string> readExpectedImageEntries(const mbgl::filesystem::path& base) {
+ static const std::regex regex(".*expected.*.png");
+ return readExpectedEntries(regex, base);
+}
+std::vector<std::string> readExpectedJSONEntries(const mbgl::filesystem::path& base) {
+ static const std::regex regex(".*expected.*.json");
+ return readExpectedEntries(regex, base);
+}
ArgumentsTuple parseArguments(int argc, char** argv) {
args::ArgumentParser argumentParser("Mapbox GL Test Runner");
diff --git a/render-test/parser.hpp b/render-test/parser.hpp
index afa281ad30..3c857b7e1e 100644
--- a/render-test/parser.hpp
+++ b/render-test/parser.hpp
@@ -18,7 +18,8 @@ JSONReply readJson(const mbgl::filesystem::path&);
std::string serializeJsonValue(const mbgl::JSValue&);
std::string serializeMetrics(const TestMetrics&);
-std::vector<std::string> readExpectedEntries(const mbgl::filesystem::path& base);
+std::vector<std::string> readExpectedImageEntries(const mbgl::filesystem::path& base);
+std::vector<std::string> readExpectedJSONEntries(const mbgl::filesystem::path& base);
TestMetrics readExpectedMetrics(const mbgl::filesystem::path& path);
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index 4d4b586a17..5df167431f 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -122,7 +122,7 @@ bool TestRunner::checkQueryTestResults(mbgl::PremultipliedImage&& actualImage,
mbgl::filesystem::path expectedMetricsPath;
for (auto rit = expectations.rbegin(); rit != expectations.rend(); ++rit) {
if (mbgl::filesystem::exists(*rit)) {
- expectedJsonPaths = readExpectedEntries(*rit);
+ expectedJsonPaths = readExpectedJSONEntries(*rit);
if (!expectedJsonPaths.empty()) break;
}
}
@@ -206,7 +206,7 @@ bool TestRunner::checkRenderTestResults(mbgl::PremultipliedImage&& actualImage,
maybeExpectedMetricsPath.replace_filename("metrics.json");
metadata.expectedMetrics = readExpectedMetrics(maybeExpectedMetricsPath);
}
- expectedImagesPaths = readExpectedEntries(*rit);
+ expectedImagesPaths = readExpectedImageEntries(*rit);
if (!expectedImagesPaths.empty()) break;
}
}