Use Env::LocalTempFilename for a temp filename.
This function works both in and outside of tests. Additionally, LocalTempFilename works well on Windows where as TmpDir is a little problematic because of bazel oddities. PiperOrigin-RevId: 296093672 Change-Id: I998ac9dab0077d7cfc09631db4bf295f4eef155a
This commit is contained in:
parent
37d4d0484c
commit
10568a537f
tensorflow/compiler/xla
@ -722,6 +722,7 @@ tf_cc_test(
|
||||
":text_literal_writer",
|
||||
":types",
|
||||
"//tensorflow/core:lib",
|
||||
"//tensorflow/core:test",
|
||||
"//tensorflow/core:test_main",
|
||||
],
|
||||
)
|
||||
|
@ -23,6 +23,7 @@ limitations under the License.
|
||||
#include "tensorflow/compiler/xla/test.h"
|
||||
#include "tensorflow/compiler/xla/test_helpers.h"
|
||||
#include "tensorflow/compiler/xla/types.h"
|
||||
#include "tensorflow/core/lib/core/status_test_util.h"
|
||||
#include "tensorflow/core/lib/io/path.h"
|
||||
#include "tensorflow/core/platform/env.h"
|
||||
#include "tensorflow/core/platform/logging.h"
|
||||
@ -35,12 +36,12 @@ TEST(TextLiteralWriterTest, WritesFloatLiteral) {
|
||||
{3.14, 2.17},
|
||||
{1.23, 4.56},
|
||||
});
|
||||
string path =
|
||||
tensorflow::io::JoinPath(tensorflow::testing::TmpDir(), "/whatever");
|
||||
string path;
|
||||
ASSERT_TRUE(tensorflow::Env::Default()->LocalTempFilename(&path));
|
||||
ASSERT_IS_OK(TextLiteralWriter::WriteToPath(literal, path));
|
||||
string contents;
|
||||
TF_CHECK_OK(tensorflow::ReadFileToString(tensorflow::Env::Default(), path,
|
||||
&contents));
|
||||
TF_ASSERT_OK(tensorflow::ReadFileToString(tensorflow::Env::Default(), path,
|
||||
&contents));
|
||||
const string expected = R"(f32[2,2]
|
||||
(0, 0): 3.14
|
||||
(0, 1): 2.17
|
||||
|
Loading…
Reference in New Issue
Block a user