From 5a0f43037fc77d200a3759e15b258fc4e5717b43 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 8 Jan 2020 13:41:35 +0200 Subject: [PATCH] [render-test] Remove positional argument Not in use, for running a single test, use -f instead. --- render-test/manifest_parser.cpp | 46 +++++++++++---------------------- render-test/manifest_parser.hpp | 1 - render-test/render_test.cpp | 16 ++++-------- 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/render-test/manifest_parser.cpp b/render-test/manifest_parser.cpp index 45fceebeb..18b4b98cd 100644 --- a/render-test/manifest_parser.cpp +++ b/render-test/manifest_parser.cpp @@ -97,7 +97,6 @@ mbgl::filesystem::path getValidPath(const std::string& manifestPath, const std:: } // namespace mbgl::optional ManifestParser::parseManifest(const std::string& manifestPath, - const std::vector& testNames, std::string testFilter) { Manifest manifest; const auto filePath = mbgl::filesystem::path(manifestPath); @@ -263,43 +262,28 @@ mbgl::optional ManifestParser::parseManifest(const std::string& manife manifest.resultPath.pop_back(); } - std::vector paths; - for (const auto& id : testNames) { - paths.emplace_back(manifest.testRootPath + "/" + id); - } - if (paths.empty()) { - paths.emplace_back(manifest.testRootPath); - } - - // Recursively traverse through the test paths and collect test directories containing "style.json". + auto& path = manifest.testRootPath; auto& testPaths = manifest.testPaths; - testPaths.reserve(paths.size()); - for (const auto& path : paths) { - if (!mbgl::filesystem::exists(path)) { - mbgl::Log::Warning( - mbgl::Event::General, "Provided test folder '%s' does not exist.", path.string().c_str()); + + for (auto& testPath : mbgl::filesystem::recursive_directory_iterator(path)) { + // Skip paths that fail regexp search. + if (!testFilter.empty() && !std::regex_search(testPath.path().string(), std::regex(testFilter))) { continue; } - for (auto& testPath : mbgl::filesystem::recursive_directory_iterator(path)) { - // Skip paths that fail regexp search. - if (!testFilter.empty() && !std::regex_search(testPath.path().string(), std::regex(testFilter))) { - continue; - } - if (testPath.path().filename() == "style.json") { - const auto defaultExpectationPath{std::move(mbgl::filesystem::path(testPath).remove_filename())}; - const auto rootLength = manifest.testRootPath.length(); - auto testId = defaultExpectationPath.string(); - testId = testId.substr(rootLength + 1, testId.length() - rootLength - 1); + if (testPath.path().filename() == "style.json") { + const auto defaultExpectationPath{std::move(mbgl::filesystem::path(testPath).remove_filename())}; + const auto rootLength = manifest.testRootPath.length(); + auto testId = defaultExpectationPath.string(); + testId = testId.substr(rootLength + 1, testId.length() - rootLength - 1); - std::vector expectedMetricPaths{expectedMetricPath}; + std::vector expectedMetricPaths{expectedMetricPath}; #if defined(__ANDROID__) - expectedMetricPaths.emplace_back("/sdcard/baselines/"); + expectedMetricPaths.emplace_back("/sdcard/baselines/"); #endif - testPaths.emplace_back(testPath, - getTestExpectations(defaultExpectationPath, testId, expectationPaths), - getTestExpectations(defaultExpectationPath, testId, expectedMetricPaths)); - } + testPaths.emplace_back(testPath, + getTestExpectations(defaultExpectationPath, testId, expectationPaths), + getTestExpectations(defaultExpectationPath, testId, expectedMetricPaths)); } } diff --git a/render-test/manifest_parser.hpp b/render-test/manifest_parser.hpp index 28cae6f93..2d11c9633 100644 --- a/render-test/manifest_parser.hpp +++ b/render-test/manifest_parser.hpp @@ -40,6 +40,5 @@ private: class ManifestParser { public: static mbgl::optional parseManifest(const std::string& manifestPath, - const std::vector& testNames, std::string testFilter); }; diff --git a/render-test/render_test.cpp b/render-test/render_test.cpp index f140b7d5b..c6595a7b7 100644 --- a/render-test/render_test.cpp +++ b/render-test/render_test.cpp @@ -44,7 +44,7 @@ void operator delete(void* ptr, size_t) noexcept { namespace { using ArgumentsTuple = std:: - tuple, std::string>; + tuple; ArgumentsTuple parseArguments(int argc, char** argv) { const static std::unordered_map updateResultsFlags = { {"default", TestRunner::UpdateResults::DEFAULT}, @@ -74,8 +74,6 @@ ArgumentsTuple parseArguments(int argc, char** argv) { {'u', "update"}, updateResultsFlags); - args::PositionalList testNameValues(argumentParser, "URL", "Test name(s)"); - try { argumentParser.ParseCLI(argc, argv); } catch (const args::Help&) { @@ -105,7 +103,6 @@ ArgumentsTuple parseArguments(int argc, char** argv) { exit(3); } - auto testNames = testNameValues ? args::get(testNameValues) : std::vector{}; auto testFilter = testFilterValue ? args::get(testFilterValue) : std::string{}; const auto shuffle = shuffleFlag ? args::get(shuffleFlag) : false; const auto online = onlineFlag ? args::get(onlineFlag) : false; @@ -118,7 +115,6 @@ ArgumentsTuple parseArguments(int argc, char** argv) { seed, manifestPath.string(), updateResults, - std::move(testNames), std::move(testFilter)}; } } // namespace @@ -131,16 +127,15 @@ int runRenderTests(int argc, char** argv, std::function testStatus) { bool online; uint32_t seed; std::string manifestPath; - std::vector testNames; std::string testFilter; TestRunner::UpdateResults updateResults; - std::tie(recycleMap, shuffle, online, seed, manifestPath, updateResults, testNames, testFilter) = + std::tie(recycleMap, shuffle, online, seed, manifestPath, updateResults, testFilter) = parseArguments(argc, argv); ProxyFileSource::setOffline(!online); - auto manifestData = ManifestParser::parseManifest(manifestPath, testNames, testFilter); + auto manifestData = ManifestParser::parseManifest(manifestPath, testFilter); if (!manifestData) { exit(5); } @@ -246,9 +241,8 @@ int runRenderTests(int argc, char** argv, std::function testStatus) { } } - const auto manifestName = std::string("_").append(mbgl::filesystem::path(manifestPath).stem()); - const auto resultPath = manifest.getResultPath() + "/" + (testNames.empty() ? "render-tests" : testNames.front()) + - manifestName + "_index.html"; + const std::string manifestName = mbgl::filesystem::path(manifestPath).stem(); + const std::string resultPath = manifest.getResultPath() + "/" + manifestName + ".html"; std::string resultsHTML = createResultPage(stats, metadatas, shuffle, seed); mbgl::util::write_file(resultPath, resultsHTML);