Make use of GetDataDependencyFilepath and io::JoinPath to be operating system independent.
PiperOrigin-RevId: 295016334 Change-Id: I613b75f859d1822fbec4a0b3880635531463c207
This commit is contained in:
parent
3d5d9b37b7
commit
62adf994a6
tensorflow/core/api_def
@ -113,5 +113,6 @@ tf_cc_test(
|
||||
"//tensorflow/core:protos_all_cc",
|
||||
"//tensorflow/core:test",
|
||||
"//tensorflow/core:test_main",
|
||||
"//tensorflow/core/platform:resource_loader",
|
||||
],
|
||||
)
|
||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||
// Test that validates tensorflow/core/api_def/base_api/api_def*.pbtxt files.
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@ -33,17 +34,25 @@ limitations under the License.
|
||||
#include "tensorflow/core/platform/env.h"
|
||||
#include "tensorflow/core/platform/init_main.h"
|
||||
#include "tensorflow/core/platform/protobuf.h"
|
||||
#include "tensorflow/core/platform/resource_loader.h"
|
||||
#include "tensorflow/core/platform/test.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace {
|
||||
constexpr char kDefaultApiDefDir[] =
|
||||
"tensorflow/core/api_def/base_api";
|
||||
constexpr char kPythonApiDefDir[] =
|
||||
"tensorflow/core/api_def/python_api";
|
||||
|
||||
constexpr char kApiDefFilePattern[] = "api_def_*.pbtxt";
|
||||
|
||||
string DefaultApiDefDir() {
|
||||
return GetDataDependencyFilepath(
|
||||
io::JoinPath("tensorflow", "core", "api_def", "base_api"));
|
||||
}
|
||||
|
||||
string PythonApiDefDir() {
|
||||
return GetDataDependencyFilepath(
|
||||
io::JoinPath("tensorflow", "core", "api_def", "python_api"));
|
||||
}
|
||||
|
||||
// Reads golden ApiDef files and returns a map from file name to ApiDef file
|
||||
// contents.
|
||||
void GetGoldenApiDefs(Env* env, const string& api_files_dir,
|
||||
@ -191,7 +200,6 @@ void TestDeprecationVersionSetCorrectly(
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class BaseApiTest : public ::testing::Test {
|
||||
protected:
|
||||
@ -200,7 +208,7 @@ class BaseApiTest : public ::testing::Test {
|
||||
const std::vector<string> multi_line_fields = {"description"};
|
||||
|
||||
Env* env = Env::Default();
|
||||
GetGoldenApiDefs(env, kDefaultApiDefDir, &api_defs_map_);
|
||||
GetGoldenApiDefs(env, DefaultApiDefDir(), &api_defs_map_);
|
||||
}
|
||||
OpList ops_;
|
||||
std::unordered_map<string, ApiDef> api_defs_map_;
|
||||
@ -296,7 +304,7 @@ class PythonApiTest : public ::testing::Test {
|
||||
const std::vector<string> multi_line_fields = {"description"};
|
||||
|
||||
Env* env = Env::Default();
|
||||
GetGoldenApiDefs(env, kPythonApiDefDir, &api_defs_map_);
|
||||
GetGoldenApiDefs(env, PythonApiDefDir(), &api_defs_map_);
|
||||
}
|
||||
OpList ops_;
|
||||
std::unordered_map<string, ApiDef> api_defs_map_;
|
||||
@ -336,4 +344,5 @@ TEST_F(PythonApiTest, DeprecationVersionSetCorrectly) {
|
||||
TestDeprecationVersionSetCorrectly(api_defs_map_);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tensorflow
|
||||
|
Loading…
Reference in New Issue
Block a user