Skip to content

Commit

Permalink
Set GTEST_SHARD_STATUS_FILE in test setup
Browse files Browse the repository at this point in the history
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 bazelbuild#18469.

PiperOrigin-RevId: 534375567
Change-Id: I0ca909cc7eb0b0f28f756e90e333e6bf39a0954d
  • Loading branch information
fmeum authored and iancha1992 committed May 23, 2023
1 parent c422565 commit ddbff68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
5 changes: 4 additions & 1 deletion tools/test/windows/tw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ddbff68

Please sign in to comment.