From 26cfddaf47bfeacc2ef739c32c9de2eae94af787 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Sat, 21 Dec 2019 01:48:04 +0200 Subject: [render-test] Add access token to the test manifest Needed if we want to run tests online. Will default to the MAPBOX_ACCESS_TOKEN environment value. --- render-test/manifest_parser.cpp | 25 ++++++++++++++++++++++++- render-test/manifest_parser.hpp | 3 +++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'render-test') diff --git a/render-test/manifest_parser.cpp b/render-test/manifest_parser.cpp index 6aec4b3593..e0e4946215 100644 --- a/render-test/manifest_parser.cpp +++ b/render-test/manifest_parser.cpp @@ -22,7 +22,13 @@ std::string prependFileScheme(const std::string& url) { } } // namespace -Manifest::Manifest() = default; +Manifest::Manifest() { + const char* envToken = getenv("MAPBOX_ACCESS_TOKEN"); + if (envToken != nullptr) { + accessToken = envToken; + } +} + Manifest::~Manifest() = default; const std::vector& Manifest::getTestPaths() const { @@ -48,6 +54,10 @@ const std::string& Manifest::getCachePath() const { return cachePath; } +const std::string& Manifest::getAccessToken() const { + return accessToken; +} + const std::set& Manifest::getProbes() const { return probes; } @@ -321,6 +331,19 @@ mbgl::optional ManifestParser::parseManifest(const std::string& manife return mbgl::nullopt; } } + if (document.HasMember("access_token")) { + const auto& accessTokenValue = document["access_token"]; + if (!accessTokenValue.IsString()) { + mbgl::Log::Warning(mbgl::Event::General, + "Invalid access_token is provided inside the manifest file: %s", + filePath.c_str()); + return mbgl::nullopt; + } + manifest.accessToken = accessTokenValue.GetString(); + if (manifest.accessToken.empty()) { + return mbgl::nullopt; + } + } mbgl::filesystem::path baseTestPath; if (document.HasMember("base_test_path")) { const auto& testPathValue = document["base_test_path"]; diff --git a/render-test/manifest_parser.hpp b/render-test/manifest_parser.hpp index 55249896cb..120fb9a2bd 100644 --- a/render-test/manifest_parser.hpp +++ b/render-test/manifest_parser.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -21,6 +22,7 @@ public: const std::string& getManifestPath() const; const std::string& getResultPath() const; const std::string& getCachePath() const; + const std::string& getAccessToken() const; const std::set& getProbes() const; void doShuffle(uint32_t seed); @@ -49,6 +51,7 @@ private: std::string assetPath; std::string resultPath; std::string cachePath; + std::string accessToken; std::vector> ignores; std::vector testPaths; std::set probes; -- cgit v1.2.1