Commit ad80b184 by Jamie Madill Committed by Commit Bot

Test Runner: List tests explicitly without GTest.

This dramatically speeds up Android shards that use batches of hudreds of tests. Because ANGLE already has the test list, it no longer needs to call GTest with an enourmous gtest_filter. Bug: angleproject:5164 Change-Id: I28fee2f36c50006f2a35a4dcd90f44f8ebe4f78c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2468464 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 426fa735
...@@ -40,6 +40,7 @@ constexpr char kTestTimeoutArg[] = "--test-timeout="; ...@@ -40,6 +40,7 @@ constexpr char kTestTimeoutArg[] = "--test-timeout=";
constexpr char kFilterFileArg[] = "--filter-file="; constexpr char kFilterFileArg[] = "--filter-file=";
constexpr char kResultFileArg[] = "--results-file="; constexpr char kResultFileArg[] = "--results-file=";
constexpr char kHistogramJsonFileArg[] = "--histogram-json-file="; constexpr char kHistogramJsonFileArg[] = "--histogram-json-file=";
constexpr char kListTests[] = "--gtest_list_tests";
#if defined(NDEBUG) #if defined(NDEBUG)
constexpr int kDefaultTestTimeout = 20; constexpr int kDefaultTestTimeout = 20;
#else #else
...@@ -704,6 +705,38 @@ TestQueue BatchTests(const std::vector<TestIdentifier> &tests, int batchSize) ...@@ -704,6 +705,38 @@ TestQueue BatchTests(const std::vector<TestIdentifier> &tests, int batchSize)
return testQueue; return testQueue;
} }
// Prints the names of the tests matching the user-specified filter flag.
// This matches the output from googletest/src/gtest.cc but is much much faster for large filters.
// See http://anglebug.com/5164
void ListTests(const std::map<TestIdentifier, TestResult> &resultsMap)
{
std::map<std::string, std::vector<std::string>> suites;
for (const auto &resultIt : resultsMap)
{
const TestIdentifier &id = resultIt.first;
suites[id.testSuiteName].push_back(id.testName);
}
for (const auto &testSuiteIt : suites)
{
bool printedTestSuiteName = false;
const std::string &suiteName = testSuiteIt.first;
const std::vector<std::string> &testNames = testSuiteIt.second;
for (const std::string &testName : testNames)
{
if (!printedTestSuiteName)
{
printedTestSuiteName = true;
printf("%s.\n", suiteName.c_str());
}
printf(" %s\n", testName.c_str());
}
}
}
} // namespace } // namespace
TestIdentifier::TestIdentifier() = default; TestIdentifier::TestIdentifier() = default;
...@@ -765,6 +798,7 @@ TestSuite::TestSuite(int *argc, char **argv) ...@@ -765,6 +798,7 @@ TestSuite::TestSuite(int *argc, char **argv)
mShardIndex(-1), mShardIndex(-1),
mBotMode(false), mBotMode(false),
mDebugTestGroups(false), mDebugTestGroups(false),
mListTests(false),
mBatchSize(kDefaultBatchSize), mBatchSize(kDefaultBatchSize),
mCurrentResultCount(0), mCurrentResultCount(0),
mTotalResultCount(0), mTotalResultCount(0),
...@@ -987,7 +1021,8 @@ bool TestSuite::parseSingleArg(const char *argument) ...@@ -987,7 +1021,8 @@ bool TestSuite::parseSingleArg(const char *argument)
ParseStringArg(kHistogramJsonFileArg, argument, &mHistogramJsonFile) || ParseStringArg(kHistogramJsonFileArg, argument, &mHistogramJsonFile) ||
ParseStringArg("--isolated-script-test-perf-output=", argument, &mHistogramJsonFile) || ParseStringArg("--isolated-script-test-perf-output=", argument, &mHistogramJsonFile) ||
ParseFlag("--bot-mode", argument, &mBotMode) || ParseFlag("--bot-mode", argument, &mBotMode) ||
ParseFlag("--debug-test-groups", argument, &mDebugTestGroups)); ParseFlag("--debug-test-groups", argument, &mDebugTestGroups) ||
ParseFlag(kListTests, argument, &mListTests));
} }
void TestSuite::onCrashOrTimeout(TestResultType crashOrTimeout) void TestSuite::onCrashOrTimeout(TestResultType crashOrTimeout)
...@@ -1189,6 +1224,12 @@ bool TestSuite::finishProcess(ProcessInfo *processInfo) ...@@ -1189,6 +1224,12 @@ bool TestSuite::finishProcess(ProcessInfo *processInfo)
int TestSuite::run() int TestSuite::run()
{ {
if (mListTests)
{
ListTests(mTestResults.results);
return EXIT_SUCCESS;
}
// Run tests serially. // Run tests serially.
if (!mBotMode) if (!mBotMode)
{ {
......
...@@ -142,6 +142,7 @@ class TestSuite ...@@ -142,6 +142,7 @@ class TestSuite
TestResults mTestResults; TestResults mTestResults;
bool mBotMode; bool mBotMode;
bool mDebugTestGroups; bool mDebugTestGroups;
bool mListTests;
int mBatchSize; int mBatchSize;
int mCurrentResultCount; int mCurrentResultCount;
int mTotalResultCount; int mTotalResultCount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment