diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-10-21 17:22:54 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-22 17:30:26 +0000 |
commit | e67cf78cf5d90c88bc90943b68952a091a3fa2e9 (patch) | |
tree | a877ed860aacc8150dbc62f262439554ea8f9faa | |
parent | 6108ecd5a88eec78050934bbef55059faea92477 (diff) | |
download | mongo-e67cf78cf5d90c88bc90943b68952a091a3fa2e9.tar.gz |
SERVER-51375 Add "api_version" and "is_deprecated" to IDL
-rw-r--r-- | buildscripts/idl/idl/ast.py | 2 | ||||
-rw-r--r-- | buildscripts/idl/idl/parser.py | 2 | ||||
-rw-r--r-- | buildscripts/idl/idl/syntax.py | 2 | ||||
-rw-r--r-- | buildscripts/idl/tests/test_parser.py | 51 |
4 files changed, 57 insertions, 0 deletions
diff --git a/buildscripts/idl/idl/ast.py b/buildscripts/idl/idl/ast.py index 855c3def579..b1e7960140f 100644 --- a/buildscripts/idl/idl/ast.py +++ b/buildscripts/idl/idl/ast.py @@ -212,6 +212,8 @@ class Command(Struct): self.namespace = None # type: str self.command_field = None # type: Field self.reply_type = None # type: Field + self.api_version = "" # type: str + self.is_deprecated = False # type: bool super(Command, self).__init__(file_name, line, column) diff --git a/buildscripts/idl/idl/parser.py b/buildscripts/idl/idl/parser.py index 67c75811618..a8e380c944c 100644 --- a/buildscripts/idl/idl/parser.py +++ b/buildscripts/idl/idl/parser.py @@ -528,6 +528,8 @@ def _parse_command(ctxt, spec, name, node): "cpp_name": _RuleDesc('scalar'), "type": _RuleDesc('scalar'), "reply_type": _RuleDesc('scalar'), + "api_version": _RuleDesc('scalar'), + "is_deprecated": _RuleDesc('bool_scalar'), "strict": _RuleDesc("bool_scalar"), "inline_chained_structs": _RuleDesc("bool_scalar"), "immutable": _RuleDesc('bool_scalar'), diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py index 2252fad4234..01bc244da2d 100644 --- a/buildscripts/idl/idl/syntax.py +++ b/buildscripts/idl/idl/syntax.py @@ -415,6 +415,8 @@ class Command(Struct): self.namespace = None # type: str self.type = None # type: str self.reply_type = None # type: str + self.api_version = "" # type: str + self.is_deprecated = False # type: bool super(Command, self).__init__(file_name, line, column) diff --git a/buildscripts/idl/tests/test_parser.py b/buildscripts/idl/tests/test_parser.py index 7c885a76c56..e88e1fdab56 100644 --- a/buildscripts/idl/tests/test_parser.py +++ b/buildscripts/idl/tests/test_parser.py @@ -838,6 +838,8 @@ class TestParser(testcase.IDLTestcase): description: foo strict: true namespace: ignored + api_version: 1 + is_deprecated: true immutable: true inline_chained_structs: true generate_comparison_operators: true @@ -854,6 +856,8 @@ class TestParser(testcase.IDLTestcase): description: foo strict: false namespace: ignored + api_version: 1 + is_deprecated: false immutable: false inline_chained_structs: false generate_comparison_operators: false @@ -861,6 +865,18 @@ class TestParser(testcase.IDLTestcase): foo: bar """)) + # Quoted api_version + self.assert_parse( + textwrap.dedent(""" + commands: + foo: + description: foo + namespace: ignored + api_version: "1" + fields: + foo: bar + """)) + # Namespace ignored self.assert_parse( textwrap.dedent(""" @@ -938,6 +954,41 @@ class TestParser(testcase.IDLTestcase): foo: bar """), idl.errors.ERROR_ID_IS_NODE_VALID_BOOL) + # is_deprecated is a bool + self.assert_parse_fail( + textwrap.dedent(""" + commands: + foo: + description: foo + namespace: ignored + is_deprecated: bar + fields: + foo: bar + """), idl.errors.ERROR_ID_IS_NODE_VALID_BOOL) + + # api_version is a scalar + self.assert_parse_fail( + textwrap.dedent(""" + commands: + foo: + description: foo + namespace: ignored + api_version: [1] + fields: + foo: bar + """), idl.errors.ERROR_ID_IS_NODE_TYPE) + + self.assert_parse_fail( + textwrap.dedent(""" + commands: + foo: + description: foo + namespace: ignored + api_version: ["1"] + fields: + foo: bar + """), idl.errors.ERROR_ID_IS_NODE_TYPE) + # Namespace is required self.assert_parse_fail( textwrap.dedent(""" |