From 4d815d83060bbf96e88022d685227b3363c557e0 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Sat, 21 Dec 2019 01:28:55 +0200 Subject: [PATCH] [render-test] Add flag to run tests online And also make it not go to the network by setting the status explicitly when when the -o flag is not passed. --- render-test/render_test.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/render-test/render_test.cpp b/render-test/render_test.cpp index e9fbbe365..32d7e5133 100644 --- a/render-test/render_test.cpp +++ b/render-test/render_test.cpp @@ -1,6 +1,7 @@ #include "allocation_index.hpp" #include +#include #include #include #include @@ -41,8 +42,8 @@ void operator delete(void* ptr, size_t) noexcept { namespace { -using ArgumentsTuple = - std::tuple, std::string>; +using ArgumentsTuple = std:: + tuple, std::string>; ArgumentsTuple parseArguments(int argc, char** argv) { const static std::unordered_map updateResultsFlags = { {"default", TestRunner::UpdateResults::DEFAULT}, @@ -56,6 +57,8 @@ ArgumentsTuple parseArguments(int argc, char** argv) { args::Flag recycleMapFlag(argumentParser, "recycle map", "Toggle reusing the map object", {'r', "recycle-map"}); args::Flag shuffleFlag(argumentParser, "shuffle", "Toggle shuffling the tests order", {'s', "shuffle"}); + args::Flag onlineFlag( + argumentParser, "online", "Toggle online mode (by default tests will run offline)", {'o', "online"}); args::ValueFlag seedValue(argumentParser, "seed", "Shuffle seed (default: random)", {"seed"}); args::ValueFlag testPathValue( argumentParser, "manifestPath", "Test manifest file path", {'p', "manifestPath"}); @@ -104,11 +107,13 @@ ArgumentsTuple parseArguments(int argc, char** argv) { 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; const auto seed = seedValue ? args::get(seedValue) : 1u; TestRunner::UpdateResults updateResults = testUpdateResultsValue ? args::get(testUpdateResultsValue) : TestRunner::UpdateResults::NO; return ArgumentsTuple{recycleMapFlag ? args::get(recycleMapFlag) : false, shuffle, + online, seed, manifestPath.string(), updateResults, @@ -122,13 +127,14 @@ int runRenderTests(int argc, char** argv, std::function testStatus) { int returnCode = 0; bool recycleMap; bool shuffle; + bool online; uint32_t seed; std::string manifestPath; std::vector testNames; std::string testFilter; TestRunner::UpdateResults updateResults; - std::tie(recycleMap, shuffle, seed, manifestPath, updateResults, testNames, testFilter) = + std::tie(recycleMap, shuffle, online, seed, manifestPath, updateResults, testNames, testFilter) = parseArguments(argc, argv); auto manifestData = ManifestParser::parseManifest(manifestPath, testNames, testFilter); if (!manifestData) { @@ -141,6 +147,8 @@ int runRenderTests(int argc, char** argv, std::function testStatus) { runner.doShuffle(seed); } + NetworkStatus::Set(online ? NetworkStatus::Status::Online : NetworkStatus::Status::Offline); + const auto& manifest = runner.getManifest(); const auto& ignores = manifest.getIgnores(); const auto& testPaths = manifest.getTestPaths();