Skip to content

Commit

Permalink
Ignore the test timeout when running under bazel run.
Browse files Browse the repository at this point in the history
`bazel run` sets but does not use the timeout.

PiperOrigin-RevId: 723094085
  • Loading branch information
xinhaoyuan authored and copybara-github committed Feb 4, 2025
1 parent 1752ee0 commit 36f9879
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/bazel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ namespace {
absl::Duration GetBazelTestTimeout() {
const char *test_timeout_env = std::getenv("TEST_TIMEOUT");
if (test_timeout_env == nullptr) return absl::InfiniteDuration();
// When using `bazel run`, `TEST_TIMEOUT` is set but not used, and we should
// ignore the timeout. We detect this by the presence of
// `BUILD_WORKSPACE_DIRECTORY`
// (https://bazel.build/docs/user-manual#running-executables).
if (getenv("BUILD_WORKSPACE_DIRECTORY") != nullptr) {
return absl::InfiniteDuration();
}
int timeout_s = 0;
CHECK(absl::SimpleAtoi(test_timeout_env, &timeout_s))
<< "Failed to parse TEST_TIMEOUT: \"" << test_timeout_env << "\"";
Expand Down

0 comments on commit 36f9879

Please sign in to comment.