Ignore the test timeout when running under `bazel run`.

`bazel run` sets but does not use the timeout.

PiperOrigin-RevId: 723176660
diff --git a/common/bazel.cc b/common/bazel.cc
index 6bdcbfa..5de96dc 100644
--- a/common/bazel.cc
+++ b/common/bazel.cc
@@ -32,6 +32,13 @@
 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 (std::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 << "\"";