gtest: Reword fail_if_no_test_selected_message for sharding and filtering.

Users have shown some confusion about the interaction between this flag,
sharding, and --gtest_filter, so let's provide some more information.

PiperOrigin-RevId: 776734799
Change-Id: Icdcf6aa056988095f15588758994604d326c0567
This commit is contained in:
David Pizzuto 2025-06-27 15:17:44 -07:00 committed by Copybara-Service
parent a45468c0fc
commit c67de11737

View File

@ -6092,7 +6092,11 @@ bool UnitTestImpl::RunAllTests() {
constexpr char kNoTestsSelectedMessage[] =
"No tests were selected to run. Please make sure at least one test "
"exists and is not disabled! If the test is sharded, you may have "
"defined more shards than test cases, which is wasteful.";
"defined more shards than test cases, which is wasteful. If you also "
"defined --gtest_filter, that filter is taken into account, so "
"shards with no matching test cases will hit this error. Either "
"disable sharding, set --gtest_fail_if_no_test_selected=false, or "
"remove the filter to resolve this error.";
ColoredPrintf(GTestColor::kRed, "%s\n", kNoTestsSelectedMessage);
return false;
}