From f1485714fffed5c62729ca3d7855729889fdc652 Mon Sep 17 00:00:00 2001 From: "Ian (Hee) Cha" Date: Wed, 24 May 2023 06:33:16 -0700 Subject: [PATCH] Set `GTEST_SHARD_STATUS_FILE` in test setup (#18482) googletest only reads `GTEST_SHARD_STATUS_FILE`, not `TEST_SHARD_STATUS_FILE`, so this variable has to be set to keep sharded `cc_test`s relying on the test framework working with `--incompatible_check_sharding_support`. Closes #18469. PiperOrigin-RevId: 534375567 Change-Id: I0ca909cc7eb0b0f28f756e90e333e6bf39a0954d Co-authored-by: Fabian Meumertzheim --- tools/test/test-setup.sh | 1 + tools/test/windows/tw.cc | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh index 952754c82dd62d..b5c48def4a0b9c 100755 --- a/tools/test/test-setup.sh +++ b/tools/test/test-setup.sh @@ -102,6 +102,7 @@ export -n TEST_UNDECLARED_OUTPUTS_ANNOTATIONS if [[ -n "${TEST_TOTAL_SHARDS+x}" ]] && ((TEST_TOTAL_SHARDS != 0)); then export GTEST_SHARD_INDEX="${TEST_SHARD_INDEX}" export GTEST_TOTAL_SHARDS="${TEST_TOTAL_SHARDS}" + export GTEST_SHARD_STATUS_FILE="${TEST_SHARD_STATUS_FILE}" fi export GTEST_TMP_DIR="${TEST_TMPDIR}" diff --git a/tools/test/windows/tw.cc b/tools/test/windows/tw.cc index 8d5f61c4a3d915..011eebc6a42e6a 100644 --- a/tools/test/windows/tw.cc +++ b/tools/test/windows/tw.cc @@ -615,7 +615,10 @@ bool ExportGtestVariables(const Path& test_tmpdir) { } if (total_shards_value > 0) { std::wstring shard_index; - if (!GetEnv(L"TEST_SHARD_INDEX", &shard_index) || + std::wstring shard_status_file; + if (!GetEnv(L"TEST_SHARD_STATUS_FILE", &shard_status_file) || + !GetEnv(L"TEST_SHARD_INDEX", &shard_index) || + !SetEnv(L"GTEST_SHARD_STATUS_FILE", shard_status_file) || !SetEnv(L"GTEST_SHARD_INDEX", shard_index) || !SetEnv(L"GTEST_TOTAL_SHARDS", total_shards_str)) { return false;