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
@ -113,5 +113,6 @@ tf_cc_test(
|
|||||||
"//tensorflow/core:protos_all_cc",
|
"//tensorflow/core:protos_all_cc",
|
||||||
"//tensorflow/core:test",
|
"//tensorflow/core:test",
|
||||||
"//tensorflow/core:test_main",
|
"//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.
|
// Test that validates tensorflow/core/api_def/base_api/api_def*.pbtxt files.
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -33,17 +34,25 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/platform/env.h"
|
#include "tensorflow/core/platform/env.h"
|
||||||
#include "tensorflow/core/platform/init_main.h"
|
#include "tensorflow/core/platform/init_main.h"
|
||||||
#include "tensorflow/core/platform/protobuf.h"
|
#include "tensorflow/core/platform/protobuf.h"
|
||||||
|
#include "tensorflow/core/platform/resource_loader.h"
|
||||||
#include "tensorflow/core/platform/test.h"
|
#include "tensorflow/core/platform/test.h"
|
||||||
#include "tensorflow/core/platform/types.h"
|
#include "tensorflow/core/platform/types.h"
|
||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
namespace {
|
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";
|
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
|
// Reads golden ApiDef files and returns a map from file name to ApiDef file
|
||||||
// contents.
|
// contents.
|
||||||
void GetGoldenApiDefs(Env* env, const string& api_files_dir,
|
void GetGoldenApiDefs(Env* env, const string& api_files_dir,
|
||||||
@ -191,7 +200,6 @@ void TestDeprecationVersionSetCorrectly(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class BaseApiTest : public ::testing::Test {
|
class BaseApiTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
@ -200,7 +208,7 @@ class BaseApiTest : public ::testing::Test {
|
|||||||
const std::vector<string> multi_line_fields = {"description"};
|
const std::vector<string> multi_line_fields = {"description"};
|
||||||
|
|
||||||
Env* env = Env::Default();
|
Env* env = Env::Default();
|
||||||
GetGoldenApiDefs(env, kDefaultApiDefDir, &api_defs_map_);
|
GetGoldenApiDefs(env, DefaultApiDefDir(), &api_defs_map_);
|
||||||
}
|
}
|
||||||
OpList ops_;
|
OpList ops_;
|
||||||
std::unordered_map<string, ApiDef> api_defs_map_;
|
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"};
|
const std::vector<string> multi_line_fields = {"description"};
|
||||||
|
|
||||||
Env* env = Env::Default();
|
Env* env = Env::Default();
|
||||||
GetGoldenApiDefs(env, kPythonApiDefDir, &api_defs_map_);
|
GetGoldenApiDefs(env, PythonApiDefDir(), &api_defs_map_);
|
||||||
}
|
}
|
||||||
OpList ops_;
|
OpList ops_;
|
||||||
std::unordered_map<string, ApiDef> api_defs_map_;
|
std::unordered_map<string, ApiDef> api_defs_map_;
|
||||||
@ -336,4 +344,5 @@ TEST_F(PythonApiTest, DeprecationVersionSetCorrectly) {
|
|||||||
TestDeprecationVersionSetCorrectly(api_defs_map_);
|
TestDeprecationVersionSetCorrectly(api_defs_map_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
Loading…
Reference in New Issue
Block a user