Move sharding logic to the correct context

Bug: b:338087169
Change-Id: I380f03c34ffcee315ef5084263f9f740b6bc4176
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/349642
Commit-Queue: Christoffer Dewerin <jansson@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42258}
This commit is contained in:
Christoffer Dewerin 2024-05-08 11:19:39 +02:00 committed by WebRTC LUCI CQ
parent 1545cdc76b
commit 35af7ccfb0

View file

@ -143,19 +143,6 @@ class TestMainImpl : public TestMain {
rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs) ||
absl::GetFlag(FLAGS_verbose));
// The sharding arguments take precedence over the sharding environment
// variables.
if (!absl::GetFlag(FLAGS_test_launcher_shard_index).empty() &&
!absl::GetFlag(FLAGS_test_launcher_total_shards).empty()) {
std::string shard_index =
"GTEST_SHARD_INDEX=" + absl::GetFlag(FLAGS_test_launcher_shard_index);
std::string total_shards =
"GTEST_TOTAL_SHARDS=" +
absl::GetFlag(FLAGS_test_launcher_total_shards);
putenv(shard_index.data());
putenv(total_shards.data());
}
// InitFieldTrialsFromString stores the char*, so the char array must
// outlive the application.
field_trials_ = absl::GetFlag(FLAGS_force_fieldtrials);
@ -191,6 +178,18 @@ class TestMainImpl : public TestMain {
metrics_to_plot->clear();
}
}
// The sharding arguments take precedence over the sharding environment
// variables.
if (!absl::GetFlag(FLAGS_test_launcher_shard_index).empty() &&
!absl::GetFlag(FLAGS_test_launcher_total_shards).empty()) {
std::string shard_index =
"GTEST_SHARD_INDEX=" + absl::GetFlag(FLAGS_test_launcher_shard_index);
std::string total_shards =
"GTEST_TOTAL_SHARDS=" +
absl::GetFlag(FLAGS_test_launcher_total_shards);
putenv(total_shards.data());
putenv(shard_index.data());
}
#if defined(WEBRTC_IOS)
rtc::test::InitTestSuite(