Use GetTestUndeclaredOutputsDir to access TEST_UNDECLARED_OUTPUTS_DIR.
On Windows, Bazel populates environment variables with `/`s only. Changing path
manipulation logic to use `\` properly on Windows will conflict with this
behavior, requiring a layer of indirection to deal with Bazel.
PiperOrigin-RevId: 296104352
Change-Id: Ibaa19d0c4d231a15811232c63bcefc9d4931f88b
diff --git a/tensorflow/compiler/xla/tests/literal_test_util.cc b/tensorflow/compiler/xla/tests/literal_test_util.cc
index 4dd59cd..bb82193 100644
--- a/tensorflow/compiler/xla/tests/literal_test_util.cc
+++ b/tensorflow/compiler/xla/tests/literal_test_util.cc
@@ -18,6 +18,7 @@
#include "absl/strings/str_format.h"
#include "tensorflow/compiler/xla/literal_comparison.h"
#include "tensorflow/core/lib/io/path.h"
+#include "tensorflow/core/platform/path.h"
#include "tensorflow/core/platform/test.h"
namespace xla {
@@ -30,10 +31,7 @@
// TEST_UNDECLARED_OUTPUTS_DIR. This plays well with tools that inspect test
// results, especially when they're run on remote machines.
string outdir;
- const char* undeclared_outputs_dir = getenv("TEST_UNDECLARED_OUTPUTS_DIR");
- if (undeclared_outputs_dir != nullptr) {
- outdir = undeclared_outputs_dir;
- } else {
+ if (!tensorflow::io::GetTestUndeclaredOutputsDir(&outdir)) {
outdir = tensorflow::testing::TmpDir();
}
diff --git a/tensorflow/compiler/xla/tests/literal_test_util_test.cc b/tensorflow/compiler/xla/tests/literal_test_util_test.cc
index 66373af..e2ad5a7 100644
--- a/tensorflow/compiler/xla/tests/literal_test_util_test.cc
+++ b/tensorflow/compiler/xla/tests/literal_test_util_test.cc
@@ -25,6 +25,7 @@
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
+#include "tensorflow/core/platform/path.h"
#include "tensorflow/core/platform/test.h"
namespace xla {
@@ -129,10 +130,7 @@
tensorflow::Env* env = tensorflow::Env::Default();
string outdir;
- const char* undeclared_outputs_dir = getenv("TEST_UNDECLARED_OUTPUTS_DIR");
- if (undeclared_outputs_dir != nullptr) {
- outdir = undeclared_outputs_dir;
- } else {
+ if (!tensorflow::io::GetTestUndeclaredOutputsDir(&outdir)) {
outdir = tensorflow::testing::TmpDir();
}
string pattern = tensorflow::io::JoinPath(outdir, "tempfile-*.pb");