From 1fa03ff291cc211730bef3e165a95804599563e8 Mon Sep 17 00:00:00 2001 From: Brian Atkinson Date: Thu, 20 Feb 2020 11:04:07 -0800 Subject: [PATCH] Make use of GetDataDependencyFilepath and JoinPath to build paths which will work across operating systems. The previous implementation doesn't work correctly on Windows. PiperOrigin-RevId: 296251590 Change-Id: Iac5ad8dbf78d06969a51b9476f66e0b8affdaaa4 --- tensorflow/core/platform/cloud/BUILD | 1 + .../core/platform/cloud/oauth_client_test.cc | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tensorflow/core/platform/cloud/BUILD b/tensorflow/core/platform/cloud/BUILD index 21e826242f9..c28755a6d8c 100644 --- a/tensorflow/core/platform/cloud/BUILD +++ b/tensorflow/core/platform/cloud/BUILD @@ -428,6 +428,7 @@ tf_cc_test( "//tensorflow/core:test_main", "//tensorflow/core/platform:base64", "//tensorflow/core/platform:path", + "//tensorflow/core/platform:resource_loader", "//tensorflow/core/platform:scanner", "@boringssl//:crypto", ], diff --git a/tensorflow/core/platform/cloud/oauth_client_test.cc b/tensorflow/core/platform/cloud/oauth_client_test.cc index 8dfff63873f..babf249f5d6 100644 --- a/tensorflow/core/platform/cloud/oauth_client_test.cc +++ b/tensorflow/core/platform/cloud/oauth_client_test.cc @@ -25,13 +25,16 @@ limitations under the License. #include "tensorflow/core/platform/cloud/http_request_fake.h" #include "tensorflow/core/platform/env.h" #include "tensorflow/core/platform/path.h" +#include "tensorflow/core/platform/resource_loader.h" #include "tensorflow/core/platform/scanner.h" #include "tensorflow/core/platform/test.h" namespace tensorflow { namespace { -constexpr char kTestData[] = "core/platform/cloud/testdata/"; +string TestData() { + return io::JoinPath("tensorflow", "core", "platform", "cloud", "testdata"); +} constexpr char kTokenJson[] = R"( { @@ -92,9 +95,8 @@ TEST(OAuthClientTest, GetTokenFromRefreshTokenJson) { } TEST(OAuthClientTest, GetTokenFromServiceAccountJson) { - std::ifstream credentials( - io::JoinPath(io::JoinPath(testing::TensorFlowSrcRoot(), kTestData), - "service_account_credentials.json")); + std::ifstream credentials(GetDataDependencyFilepath( + io::JoinPath(TestData(), "service_account_credentials.json"))); ASSERT_TRUE(credentials.is_open()); Json::Value json; Json::Reader reader; @@ -135,9 +137,8 @@ TEST(OAuthClientTest, GetTokenFromServiceAccountJson) { // Check that 'signature' signs 'header_dot_claim'. // Read the serialized public key. - std::ifstream public_key_stream( - io::JoinPath(io::JoinPath(testing::TensorFlowSrcRoot(), kTestData), - "service_account_public_key.txt")); + std::ifstream public_key_stream(GetDataDependencyFilepath( + io::JoinPath(TestData(), "service_account_public_key.txt"))); string public_key_serialized( (std::istreambuf_iterator(public_key_stream)), (std::istreambuf_iterator()));