@@ -357,19 +357,12 @@ std::vector<TestIdentifier> GetFilteredTests(std::map<TestIdentifier, FileLine>
357
357
return FilterTests (fileLinesOut, gtestIDFilter, alsoRunDisabledTests);
358
358
}
359
359
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
-
367
360
std::vector<TestIdentifier> GetShardTests (int shardIndex,
368
361
int shardCount,
369
362
std::map<TestIdentifier, FileLine> *fileLinesOut,
370
363
bool alsoRunDisabledTests)
371
364
{
372
- std::vector<TestIdentifier> allTests = GetCompiledInTests (fileLinesOut, alsoRunDisabledTests);
365
+ std::vector<TestIdentifier> allTests = GetFilteredTests (fileLinesOut, alsoRunDisabledTests);
373
366
std::vector<TestIdentifier> shardTests;
374
367
375
368
for (int testIndex = shardIndex; testIndex < static_cast <int >(allTests.size ());
@@ -713,12 +706,6 @@ TestSuite::TestSuite(int *argc, char **argv)
713
706
exit (1 );
714
707
}
715
708
716
- if (mShardCount > 0 )
717
- {
718
- printf (" Cannot use filter file in conjunction with sharding parameters.\n " );
719
- exit (1 );
720
- }
721
-
722
709
uint32_t fileSize = 0 ;
723
710
if (!GetFileSize (mFilterFile .c_str (), &fileSize))
724
711
{
@@ -745,25 +732,24 @@ TestSuite::TestSuite(int *argc, char **argv)
745
732
AddArg (argc, argv, mFilterString .c_str ());
746
733
}
747
734
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
-
753
735
if (mShardCount > 0 )
754
736
{
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);
760
743
761
744
mTestQueue = GetShardTests (mShardIndex , mShardCount , &mTestFileLines , alsoRunDisabledTests);
762
745
mFilterString = GetTestFilter (mTestQueue );
763
746
764
747
// Note that we only add a filter string if we previously deleted a shader index/count
765
748
// argument. So we will have space for the new filter string in argv.
766
749
AddArg (argc, argv, mFilterString .c_str ());
750
+
751
+ // Force-re-initialize GoogleTest flags to load the shard filter.
752
+ testing::internal::ParseGoogleTestFlagsOnly (argc, argv);
767
753
}
768
754
769
755
testing::InitGoogleTest (argc, argv);
0 commit comments