Skip to content

Commit ee07cb3

Browse files
null77Commit Bot
authored and
Commit Bot
committed
Test Harness: Allow filter with sharding params.
Some tweaks to when we call gtest initialization allows this to work. Bug: angleproject:3162 Change-Id: I75159108d3f746f666e57c1a6495a8c8616ef1cf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2024335 Commit-Queue: Jamie Madill <[email protected]> Reviewed-by: Jonah Ryan-Davis <[email protected]>
1 parent 12c0e76 commit ee07cb3

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

src/tests/test_utils/runner/TestSuite.cpp

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -357,19 +357,12 @@ std::vector<TestIdentifier> GetFilteredTests(std::map<TestIdentifier, FileLine>
357357
return FilterTests(fileLinesOut, gtestIDFilter, alsoRunDisabledTests);
358358
}
359359

360-
std::vector<TestIdentifier> GetCompiledInTests(std::map<TestIdentifier, FileLine> *fileLinesOut,
361-
bool alsoRunDisabledTests)
362-
{
363-
TestIdentifierFilter passthroughFilter = [](const TestIdentifier &id) { return true; };
364-
return FilterTests(fileLinesOut, passthroughFilter, alsoRunDisabledTests);
365-
}
366-
367360
std::vector<TestIdentifier> GetShardTests(int shardIndex,
368361
int shardCount,
369362
std::map<TestIdentifier, FileLine> *fileLinesOut,
370363
bool alsoRunDisabledTests)
371364
{
372-
std::vector<TestIdentifier> allTests = GetCompiledInTests(fileLinesOut, alsoRunDisabledTests);
365+
std::vector<TestIdentifier> allTests = GetFilteredTests(fileLinesOut, alsoRunDisabledTests);
373366
std::vector<TestIdentifier> shardTests;
374367

375368
for (int testIndex = shardIndex; testIndex < static_cast<int>(allTests.size());
@@ -713,12 +706,6 @@ TestSuite::TestSuite(int *argc, char **argv)
713706
exit(1);
714707
}
715708

716-
if (mShardCount > 0)
717-
{
718-
printf("Cannot use filter file in conjunction with sharding parameters.\n");
719-
exit(1);
720-
}
721-
722709
uint32_t fileSize = 0;
723710
if (!GetFileSize(mFilterFile.c_str(), &fileSize))
724711
{
@@ -745,25 +732,24 @@ TestSuite::TestSuite(int *argc, char **argv)
745732
AddArg(argc, argv, mFilterString.c_str());
746733
}
747734

748-
// Call into gtest internals to force parameterized test name registration.
749-
// TODO(jmadill): Clean this up so we don't need to call it.
750-
testing::internal::UnitTestImpl *impl = testing::internal::GetUnitTestImpl();
751-
impl->RegisterParameterizedTests();
752-
753735
if (mShardCount > 0)
754736
{
755-
if (hasFilter)
756-
{
757-
printf("Cannot use gtest_filter in conjunction with sharding parameters.\n");
758-
exit(1);
759-
}
737+
// Call into gtest internals to force parameterized test name registration.
738+
testing::internal::UnitTestImpl *impl = testing::internal::GetUnitTestImpl();
739+
impl->RegisterParameterizedTests();
740+
741+
// Initialize internal GoogleTest filter arguments so we can call "FilterMatchesTest".
742+
testing::internal::ParseGoogleTestFlagsOnly(argc, argv);
760743

761744
mTestQueue = GetShardTests(mShardIndex, mShardCount, &mTestFileLines, alsoRunDisabledTests);
762745
mFilterString = GetTestFilter(mTestQueue);
763746

764747
// Note that we only add a filter string if we previously deleted a shader index/count
765748
// argument. So we will have space for the new filter string in argv.
766749
AddArg(argc, argv, mFilterString.c_str());
750+
751+
// Force-re-initialize GoogleTest flags to load the shard filter.
752+
testing::internal::ParseGoogleTestFlagsOnly(argc, argv);
767753
}
768754

769755
testing::InitGoogleTest(argc, argv);

0 commit comments

Comments
 (0)