summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorMoustafa Maher <m.maher@10gen.com>2021-03-09 01:50:26 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-12 02:27:57 +0000
commit0757d14ea960b2a30f2b84423551422e5980e41e (patch)
tree6f3eb48c1135ecd4e79806367a0c8c0af578387a /buildscripts
parentf6787932d2711fe0c1c8380516328eb8ebef36d8 (diff)
downloadmongo-0757d14ea960b2a30f2b84423551422e5980e41e.tar.gz
SERVER-54771 Adding Array Type checking in idl_check_compatibility
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/idl/idl_check_compatibility.py39
-rw-r--r--buildscripts/idl/idl_compatibility_errors.py15
-rw-r--r--buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_no_array/command_parameter_no_array.idl55
-rw-r--r--buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_with_array/command_parameter_with_array.idl55
-rw-r--r--buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_no_array/command_type_no_array.idl55
-rw-r--r--buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_with_array/command_type_with_array.idl55
-rw-r--r--buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl34
-rw-r--r--buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl34
-rw-r--r--buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl20
-rw-r--r--buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl20
-rw-r--r--buildscripts/idl/tests/test_compatibility.py50
11 files changed, 428 insertions, 4 deletions
diff --git a/buildscripts/idl/idl_check_compatibility.py b/buildscripts/idl/idl_check_compatibility.py
index b1691c4a4ae..e019517fd12 100644
--- a/buildscripts/idl/idl_check_compatibility.py
+++ b/buildscripts/idl/idl_check_compatibility.py
@@ -256,6 +256,27 @@ def check_reply_field_type(ctxt: IDLCompatibilityContext,
cmd_name, field_name, new_field_type.name, old_field_type.name, new_idl_file_path)
+def check_array_type(ctxt: IDLCompatibilityContext, symbol: str,
+ old_type: Optional[Union[syntax.Enum, syntax.Struct, syntax.Type]],
+ new_type: Optional[Union[syntax.Enum, syntax.Struct, syntax.Type]],
+ cmd_name: str, symbol_name: str, old_idl_file_path: str,
+ new_idl_file_path: str) -> bool:
+ """Check compatibility between old and new ArrayTypes."""
+ # pylint: disable=too-many-arguments,too-many-branches
+ old_is_array = isinstance(old_type, syntax.ArrayType)
+ new_is_array = isinstance(new_type, syntax.ArrayType)
+ if not old_is_array and not new_is_array:
+ return False
+
+ if not old_is_array or not new_is_array:
+ ctxt.add_type_not_array_error(symbol, cmd_name, symbol_name, new_type.name, old_type.name,
+ new_idl_file_path if old_is_array else old_idl_file_path)
+ ctxt.errors.dump_errors()
+ sys.exit(1)
+
+ return True
+
+
def check_reply_field(ctxt: IDLCompatibilityContext, old_field: syntax.Field,
new_field: syntax.Field, cmd_name: str, old_idl_file: syntax.IDLParsedSpec,
new_idl_file: syntax.IDLParsedSpec, old_idl_file_path: str,
@@ -279,6 +300,11 @@ def check_reply_field(ctxt: IDLCompatibilityContext, old_field: syntax.Field,
old_field_type = get_field_type(old_field, old_idl_file, old_idl_file_path)
new_field_type = get_field_type(new_field, new_idl_file, new_idl_file_path)
+ if check_array_type(ctxt, "reply_field", old_field_type, new_field_type, cmd_name, 'type',
+ old_idl_file_path, new_idl_file_path):
+ old_field_type = old_field_type.element_type
+ new_field_type = new_field_type.element_type
+
check_reply_field_type(ctxt, old_field_type, new_field_type, cmd_name, old_field.name,
old_idl_file, new_idl_file, old_idl_file_path, new_idl_file_path)
@@ -405,6 +431,13 @@ def check_param_or_command_type(ctxt: IDLCompatibilityContext,
is_command_parameter: bool):
"""Check compatibility between old and new command parameter type or command type."""
# pylint: disable=too-many-arguments,too-many-branches
+ if check_array_type(ctxt, "command_parameter" if is_command_parameter else "command_namespace",
+ old_type, new_type, cmd_name,
+ param_name if is_command_parameter else "type", old_idl_file_path,
+ new_idl_file_path):
+ old_type = old_type.element_type
+ new_type = new_type.element_type
+
if old_type is None:
ctxt.add_command_or_param_type_invalid_error(cmd_name, old_idl_file_path, param_name,
is_command_parameter)
@@ -581,7 +614,7 @@ def check_error_reply(old_basic_types_path: str, new_basic_types_path: str,
old_error_reply_struct = old_idl_file.spec.symbols.get_struct("ErrorReply")
if old_error_reply_struct is None:
- ctxt.add_missing_error_reply_error(old_basic_types_path)
+ ctxt.add_missing_error_reply_struct_error(old_basic_types_path)
else:
with open(new_basic_types_path) as new_file:
new_idl_file = parser.parse(new_file, new_basic_types_path,
@@ -592,7 +625,7 @@ def check_error_reply(old_basic_types_path: str, new_basic_types_path: str,
new_error_reply_struct = new_idl_file.spec.symbols.get_struct("ErrorReply")
if new_error_reply_struct is None:
- ctxt.add_missing_error_reply_error(new_basic_types_path)
+ ctxt.add_missing_error_reply_struct_error(new_basic_types_path)
else:
check_reply_fields(ctxt, old_error_reply_struct, new_error_reply_struct, "n/a",
old_idl_file, new_idl_file, old_basic_types_path,
@@ -711,7 +744,7 @@ def main():
args = arg_parser.parse_args()
error_coll = check_compatibility(args.old_idl_dir, args.new_idl_dir, [])
- if error_coll.errors.has_errors():
+ if error_coll.has_errors():
sys.exit(1)
old_basic_types_path = os.path.join(args.old_idl_dir, "mongo/idl/basic_types.idl")
diff --git a/buildscripts/idl/idl_compatibility_errors.py b/buildscripts/idl/idl_compatibility_errors.py
index f472ba54b08..d07920dc9dc 100644
--- a/buildscripts/idl/idl_compatibility_errors.py
+++ b/buildscripts/idl/idl_compatibility_errors.py
@@ -101,6 +101,7 @@ ERROR_ID_REPLY_FIELD_VALIDATORS_NOT_EQUAL = "ID0057"
ERROR_ID_CHECK_NOT_EQUAL = "ID0058"
ERROR_ID_RESOURCE_PATTERN_NOT_EQUAL = "ID0059"
ERROR_ID_NEW_ACTION_TYPES_NOT_SUBSET = "ID0060"
+ERROR_ID_TYPE_NOT_ARRAY = "ID0061"
class IDLCompatibilityCheckerError(Exception):
@@ -831,6 +832,20 @@ class IDLCompatibilityContext(object):
("'%s' has new action types that are not a subset of the old action types")
% (command_name), file)
+ def add_type_not_array_error(self, symbol: str, command_name: str, symbol_name: str,
+ new_type: str, old_type: str, file: str) -> None:
+ # pylint: disable=too-many-arguments
+ """
+ Add an error about type not being an ArrayType when it should be.
+
+ This is a general error for each case where ArrayType is missing from (command type,
+ command parameter type).
+ """
+ self._add_error(
+ ERROR_ID_TYPE_NOT_ARRAY, command_name,
+ "The command '%s' has %s: '%s' with new type '%s' while the older type was '%s'." %
+ (command_name, symbol, symbol_name, new_type, old_type), file)
+
def _assert_unique_error_messages() -> None:
"""Assert that error codes are unique."""
diff --git a/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_no_array/command_parameter_no_array.idl b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_no_array/command_parameter_no_array.idl
new file mode 100644
index 00000000000..7a8c5dfc3ae
--- /dev/null
+++ b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_no_array/command_parameter_no_array.idl
@@ -0,0 +1,55 @@
+# Copyright (C) 2021-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo"
+
+imports:
+ - "mongo/idl/basic_types.idl"
+
+structs:
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
+commands:
+ ArrayCommandParameterNoArray:
+ description: "command will abort because the command field type is not of ArrayType while
+ the other is of ArrayType."
+ command_name: arrayCommandParameterNoArray
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommandParameterNoArray
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: ArrayTypeStruct
+ reply_type: ArrayTypeStruct \ No newline at end of file
diff --git a/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_with_array/command_parameter_with_array.idl b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_with_array/command_parameter_with_array.idl
new file mode 100644
index 00000000000..abe02f63150
--- /dev/null
+++ b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_parameter_with_array/command_parameter_with_array.idl
@@ -0,0 +1,55 @@
+# Copyright (C) 2021-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo"
+
+imports:
+ - "mongo/idl/basic_types.idl"
+
+structs:
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
+commands:
+ ArrayCommandParameterNoArray:
+ description: "command will abort because the command field type of ArrayType while the other
+ is not of ArrayType."
+ command_name: arrayCommandParameterNoArray
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommandParameterNoArray
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct \ No newline at end of file
diff --git a/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_no_array/command_type_no_array.idl b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_no_array/command_type_no_array.idl
new file mode 100644
index 00000000000..6d5302f7a2a
--- /dev/null
+++ b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_no_array/command_type_no_array.idl
@@ -0,0 +1,55 @@
+# Copyright (C) 2021-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo"
+
+imports:
+ - "mongo/idl/basic_types.idl"
+
+structs:
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
+commands:
+ ArrayCommandTypeErrorNoArray:
+ description: "command will abort because the command type is not of ArrayType while
+ the other is of ArrayType."
+ command_name: arrayCommandTypeErrorNoArray
+ namespace: type
+ type: ArrayTypeStruct
+ cpp_name: arrayCommandTypeErrorNoArray
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct \ No newline at end of file
diff --git a/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_with_array/command_type_with_array.idl b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_with_array/command_type_with_array.idl
new file mode 100644
index 00000000000..3ede8ce9c94
--- /dev/null
+++ b/buildscripts/idl/tests/compatibility_test_fail/abort/missing_array/command_type_with_array/command_type_with_array.idl
@@ -0,0 +1,55 @@
+# Copyright (C) 2021-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo"
+
+imports:
+ - "mongo/idl/basic_types.idl"
+
+structs:
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
+commands:
+ ArrayCommandTypeErrorNoArray:
+ description: "command will abort because the command type is of ArrayType while
+ the other is not of ArrayType."
+ command_name: arrayCommandTypeErrorNoArray
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommandTypeErrorNoArray
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct \ No newline at end of file
diff --git a/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl b/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl
index e160fb20202..5a337aa05b0 100644
--- a/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl
+++ b/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl
@@ -339,6 +339,12 @@ structs:
stableRequiredTypeField:
type: string
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
StructCommandParameterTypeRecursive:
description: "This param struct type contains a field that is not compatible between the
old and new versions"
@@ -1459,3 +1465,31 @@ commands:
privilege:
resource_pattern: resourcePattern
action_type: [actionType, actionTypeThree]
+
+ ArrayCommandTypeError:
+ description: "new command will fail because the command type is an ArrayType of a type that
+ that isn't compatible with the old command."
+ command_name: arrayCommandTypeError
+ namespace: type
+ type: array<string>
+ cpp_name: arrayCommandTypeError
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct
+
+ ArrayCommandParameterTypeError:
+ description: "new command will fail because the command paramter type are of ArrayType of a
+ type that is incompatible with the old command paramter type."
+ command_name: arrayCommandParameterTypeError
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommandParameterTypeError
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<StructType>
+ reply_type: ArrayTypeStruct
diff --git a/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl b/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl
index da250088e4b..106fb15076b 100644
--- a/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl
+++ b/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl
@@ -392,6 +392,12 @@ structs:
type:
variant: [int, string, StructCommandParameterTypeRecursive]
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
commands:
invalidAPIVersionOld:
description: "old command fails because of invalid API version"
@@ -1447,3 +1453,31 @@ commands:
privilege:
resource_pattern: resourcePattern
action_type: [actionType, actionTypeTwo]
+
+ ArrayCommandTypeError:
+ description: "new command will fail because the command type is an ArrayType of a type that
+ that isn't compatible with the old command."
+ command_name: arrayCommandTypeError
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommandTypeError
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct
+
+ ArrayCommandParameterTypeError:
+ description: "new command will fail because the command paramter type are of ArrayType of a
+ type that is incompatible with the old command paramter type."
+ command_name: arrayCommandParameterTypeError
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommandParameterTypeError
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct
diff --git a/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl b/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl
index c92ce46b2dc..accb2e7c43e 100644
--- a/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl
+++ b/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl
@@ -358,6 +358,12 @@ structs:
type:
variant: [bsonSerializationTypeAnyAllowed, StructFieldTypeRecursiveReplyTwo]
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
commands:
testCommand:
description: "new passing test command, there was no change from the old version"
@@ -1123,3 +1129,17 @@ commands:
privilege:
resource_pattern: resourcePattern
action_type: [actionTypeThree, actionTypeOne]
+
+ ArrayCommand:
+ description: "new command will pass because the command type and the field type are of
+ ArrayType of a type that is compatible with the old command."
+ command_name: arrayCommand
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommand
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct
diff --git a/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl b/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl
index 61b4fca1c79..795141862de 100644
--- a/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl
+++ b/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl
@@ -354,6 +354,12 @@ structs:
type:
variant: [intStringBoolToIntString, bsonSerializationTypeAnyAllowed, StructFieldTypeRecursiveReplyTwo]
+ ArrayTypeStruct:
+ description: "Struct with ArrayType field."
+ fields:
+ ArrayCommandParameter:
+ type: array<string>
+
commands:
testCommand:
description: "old passing test command"
@@ -1119,3 +1125,17 @@ commands:
privilege:
resource_pattern: resourcePattern
action_type: [actionTypeOne, actionTypeTwo, actionTypeThree]
+
+ ArrayCommand:
+ description: "new command will pass because the command type and the field type are of
+ ArrayType of a type that is compatible with the old command."
+ command_name: arrayCommand
+ namespace: type
+ type: array<ArrayTypeStruct>
+ cpp_name: arrayCommand
+ strict: true
+ api_version: "1"
+ fields:
+ parameterStruct:
+ type: array<ArrayTypeStruct>
+ reply_type: ArrayTypeStruct
diff --git a/buildscripts/idl/tests/test_compatibility.py b/buildscripts/idl/tests/test_compatibility.py
index 7cf4d6bb245..43faba8b43f 100644
--- a/buildscripts/idl/tests/test_compatibility.py
+++ b/buildscripts/idl/tests/test_compatibility.py
@@ -83,6 +83,40 @@ class TestIDLCompatibilityChecker(unittest.TestCase):
path.join(dir_path, "compatibility_test_fail/abort/invalid_command_parameter_type"),
["src"])
+ with self.assertRaises(SystemExit):
+ idl_check_compatibility.check_compatibility(
+ path.join(dir_path,
+ "compatibility_test_fail/abort/missing_array/command_parameter_no_array"),
+ path.join(
+ dir_path,
+ "compatibility_test_fail/abort/missing_array/command_parameter_with_array"),
+ ["src"])
+
+ with self.assertRaises(SystemExit):
+ idl_check_compatibility.check_compatibility(
+ path.join(
+ dir_path,
+ "compatibility_test_fail/abort/missing_array/command_parameter_with_array"),
+ path.join(dir_path,
+ "compatibility_test_fail/abort/missing_array/command_parameter_no_array"),
+ ["src"])
+
+ with self.assertRaises(SystemExit):
+ idl_check_compatibility.check_compatibility(
+ path.join(dir_path,
+ "compatibility_test_fail/abort/missing_array/command_type_no_array"),
+ path.join(dir_path,
+ "compatibility_test_fail/abort/missing_array/command_type_with_array"),
+ ["src"])
+
+ with self.assertRaises(SystemExit):
+ idl_check_compatibility.check_compatibility(
+ path.join(dir_path,
+ "compatibility_test_fail/abort/missing_array/command_type_with_array"),
+ path.join(dir_path,
+ "compatibility_test_fail/abort/missing_array/command_type_no_array"),
+ ["src"])
+
# pylint: disable=too-many-locals,too-many-statements
def test_should_fail(self):
"""Tests that incompatible old and new IDL commands should fail."""
@@ -92,7 +126,7 @@ class TestIDLCompatibilityChecker(unittest.TestCase):
path.join(dir_path, "compatibility_test_fail/new"), ["src"])
self.assertTrue(error_collection.has_errors())
- self.assertTrue(error_collection.count() == 97)
+ self.assertTrue(error_collection.count() == 100)
invalid_api_version_new_error = error_collection.get_error_by_command_name(
"invalidAPIVersionNew")
@@ -574,6 +608,20 @@ class TestIDLCompatibilityChecker(unittest.TestCase):
idl_compatibility_errors.ERROR_ID_COMMAND_TYPE_VALIDATORS_NOT_EQUAL)
self.assertRegex(
str(command_type_validators_not_equal_error), "commandTypeValidatorsNotEqual")
+ array_command_type_error = error_collection.get_error_by_command_name(
+ "arrayCommandTypeError")
+ self.assertTrue(array_command_type_error.error_id ==
+ idl_compatibility_errors.ERROR_ID_NEW_COMMAND_TYPE_NOT_STRUCT)
+ self.assertRegex(str(array_command_type_error), "ArrayTypeStruct")
+ array_command_param_type_two_errors = error_collection.get_all_errors_by_command_name(
+ "arrayCommandParameterTypeError")
+ self.assertTrue(len(array_command_param_type_two_errors) == 2)
+ self.assertTrue(array_command_param_type_two_errors[0].error_id ==
+ idl_compatibility_errors.ERROR_ID_REMOVED_COMMAND_PARAMETER)
+ self.assertRegex(str(array_command_param_type_two_errors[0]), "ArrayCommandParameter")
+ self.assertTrue(array_command_param_type_two_errors[1].error_id ==
+ idl_compatibility_errors.ERROR_ID_ADDED_REQUIRED_COMMAND_PARAMETER)
+ self.assertRegex(str(array_command_param_type_two_errors[1]), "fieldOne")
new_param_variant_not_superset_error = error_collection.get_error_by_command_name(
"newParamVariantNotSuperset")