From a0199a1fefd26c11cd26ef76c6d8023f4caf4e63 Mon Sep 17 00:00:00 2001 From: Brian Atkinson Date: Thu, 13 Feb 2020 18:20:08 -0800 Subject: [PATCH] Use io::JoinPath rather than StrCat to build paths. This breaks when trying to run on Windows. PiperOrigin-RevId: 295046481 Change-Id: I46a0c5be12894b7223f545cc842894fb8b2a55e1 --- tensorflow/core/platform/default/BUILD | 1 + tensorflow/core/platform/default/test.cc | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tensorflow/core/platform/default/BUILD b/tensorflow/core/platform/default/BUILD index d11c92e3deb..30287fdb5eb 100644 --- a/tensorflow/core/platform/default/BUILD +++ b/tensorflow/core/platform/default/BUILD @@ -418,6 +418,7 @@ cc_library( "//tensorflow/core/platform:logging", "//tensorflow/core/platform:macros", "//tensorflow/core/platform:net", + "//tensorflow/core/platform:path", "//tensorflow/core/platform:strcat", "//tensorflow/core/platform:types", "@com_google_googletest//:gtest", diff --git a/tensorflow/core/platform/default/test.cc b/tensorflow/core/platform/default/test.cc index 1118dce44d5..8bc3abab930 100644 --- a/tensorflow/core/platform/default/test.cc +++ b/tensorflow/core/platform/default/test.cc @@ -19,6 +19,7 @@ limitations under the License. #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/net.h" +#include "tensorflow/core/platform/path.h" #include "tensorflow/core/platform/strcat.h" #include "tensorflow/core/platform/types.h" @@ -61,15 +62,13 @@ string TensorFlowSrcRoot() { const char* workspace = getenv("TEST_WORKSPACE"); if (env && env[0] != '\0') { if (workspace && workspace[0] != '\0') { - return strings::StrCat(env, "/", workspace, "/tensorflow"); - } else { - return strings::StrCat(env, "/tensorflow"); + return io::JoinPath(env, workspace, "tensorflow"); } - } else { - LOG(WARNING) << "TEST_SRCDIR environment variable not set: " - << "using $PWD/tensorflow as TensorFlowSrcRoot() for tests."; - return "tensorflow"; + return io::JoinPath(env, "tensorflow"); } + LOG(WARNING) << "TEST_SRCDIR environment variable not set: " + << "using $PWD/tensorflow as TensorFlowSrcRoot() for tests."; + return "tensorflow"; } } // namespace testing