aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/api_def/api_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/core/api_def/api_test.cc')
-rw-r--r--tensorflow/core/api_def/api_test.cc39
1 files changed, 38 insertions, 1 deletions
diff --git a/tensorflow/core/api_def/api_test.cc b/tensorflow/core/api_def/api_test.cc
index 477a0b670e..ae03a61ae6 100644
--- a/tensorflow/core/api_def/api_test.cc
+++ b/tensorflow/core/api_def/api_test.cc
@@ -149,6 +149,33 @@ void TestAllApiDefAttributeNamesAreValid(
}
}
}
+
+void TestDeprecatedAttributesSetCorrectly(
+ const std::unordered_map<string, ApiDef>& api_defs_map) {
+ for (const auto& name_and_api_def : api_defs_map) {
+ int num_deprecated_endpoints = 0;
+ const auto& api_def = name_and_api_def.second;
+ for (const auto& endpoint : api_def.endpoint()) {
+ if (endpoint.deprecated()) {
+ ++num_deprecated_endpoints;
+ }
+ }
+
+ const auto& name = name_and_api_def.first;
+ ASSERT_TRUE(api_def.deprecation_message().empty() ||
+ num_deprecated_endpoints == 0)
+ << "Endpoints are set to 'deprecated' for deprecated op " << name
+ << ". If an op is deprecated (i.e. deprecation_message is set), "
+ << "all the endpoints are deprecated implicitly and 'deprecated' "
+ << "field should not be set.";
+ if (num_deprecated_endpoints > 0) {
+ ASSERT_NE(num_deprecated_endpoints, api_def.endpoint_size())
+ << "All " << name << " endpoints are deprecated. Please, set "
+ << "deprecation_message in api_def_" << name << ".pbtxt instead. "
+ << "to indicate that the op is deprecated.";
+ }
+ }
+}
} // namespace
class BaseApiTest : public ::testing::Test {
@@ -171,7 +198,7 @@ TEST_F(BaseApiTest, AllOpsAreInApiDef) {
if (excluded_ops->find(op.name()) != excluded_ops->end()) {
continue;
}
- ASSERT_TRUE(api_defs_map_.find(op.name()) != api_defs_map_.end())
+ EXPECT_TRUE(api_defs_map_.find(op.name()) != api_defs_map_.end())
<< op.name() << " op does not have api_def_*.pbtxt file. "
<< "Please add api_def_" << op.name() << ".pbtxt file "
<< "under tensorflow/core/api_def/base_api/ directory.";
@@ -236,6 +263,11 @@ TEST_F(BaseApiTest, AllApiDefAttributeNamesAreValid) {
TestAllApiDefAttributeNamesAreValid(ops_, api_defs_map_);
}
+// Checks that deprecation is set correctly.
+TEST_F(BaseApiTest, DeprecationSetCorrectly) {
+ TestDeprecatedAttributesSetCorrectly(api_defs_map_);
+}
+
class PythonApiTest : public ::testing::Test {
protected:
PythonApiTest() {
@@ -272,4 +304,9 @@ TEST_F(PythonApiTest, AllApiDefAttributeNamesAreValid) {
TestAllApiDefAttributeNamesAreValid(ops_, api_defs_map_);
}
+// Checks that deprecation is set correctly.
+TEST_F(PythonApiTest, DeprecationSetCorrectly) {
+ TestDeprecatedAttributesSetCorrectly(api_defs_map_);
+}
+
} // namespace tensorflow