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
This commit is contained in:
Brian Atkinson 2020-02-19 18:20:38 -08:00 committed by TensorFlower Gardener
parent 1612c983e5
commit 9aac700d02
2 changed files with 4 additions and 8 deletions

View File

@ -18,6 +18,7 @@ limitations under the License.
#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 @@ void WriteLiteralToTempFile(const LiteralSlice& literal, const string& name) {
// 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();
}

View File

@ -25,6 +25,7 @@ limitations under the License.
#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 @@ TEST(LiteralTestUtilTest, ExpectNearFailurePlacesResultsInTemporaryDirectory) {
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");