[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/13] qapi: Tweak error messages for unknown / conflicting 'if' k
From: |
Markus Armbruster |
Subject: |
[PULL 13/13] qapi: Tweak error messages for unknown / conflicting 'if' keys |
Date: |
Fri, 3 Sep 2021 21:32:09 +0200 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-13-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
scripts/qapi/expr.py | 7 +++----
tests/qapi-schema/bad-if-key.err | 2 +-
tests/qapi-schema/bad-if-keys.err | 2 +-
tests/qapi-schema/enum-if-invalid.err | 2 +-
4 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index ae4437ba08..b62f0a3640 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -286,13 +286,12 @@ def _check_if(cond: Union[str, object]) -> None:
raise QAPISemError(
info,
"'if' condition of %s must be a string or an object" % source)
+ check_keys(cond, info, "'if' condition of %s" % source, [],
+ ["all", "any", "not"])
if len(cond) != 1:
raise QAPISemError(
info,
- "'if' condition dict of %s must have one key: "
- "'all', 'any' or 'not'" % source)
- check_keys(cond, info, "'if' condition", [],
- ["all", "any", "not"])
+ "'if' condition of %s has conflicting keys" % source)
oper, operands = next(iter(cond.items()))
if not operands:
diff --git a/tests/qapi-schema/bad-if-key.err b/tests/qapi-schema/bad-if-key.err
index a69dc9ee86..38cf44b687 100644
--- a/tests/qapi-schema/bad-if-key.err
+++ b/tests/qapi-schema/bad-if-key.err
@@ -1,3 +1,3 @@
bad-if-key.json: In struct 'TestIfStruct':
-bad-if-key.json:2: 'if' condition has unknown key 'value'
+bad-if-key.json:2: 'if' condition of struct has unknown key 'value'
Valid keys are 'all', 'any', 'not'.
diff --git a/tests/qapi-schema/bad-if-keys.err
b/tests/qapi-schema/bad-if-keys.err
index aceb31dc6d..fe87bd30ac 100644
--- a/tests/qapi-schema/bad-if-keys.err
+++ b/tests/qapi-schema/bad-if-keys.err
@@ -1,2 +1,2 @@
bad-if-keys.json: In struct 'TestIfStruct':
-bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all',
'any' or 'not'
+bad-if-keys.json:2: 'if' condition of struct has conflicting keys
diff --git a/tests/qapi-schema/enum-if-invalid.err
b/tests/qapi-schema/enum-if-invalid.err
index 3bb84075a9..2b2bbffb65 100644
--- a/tests/qapi-schema/enum-if-invalid.err
+++ b/tests/qapi-schema/enum-if-invalid.err
@@ -1,3 +1,3 @@
enum-if-invalid.json: In enum 'TestIfEnum':
-enum-if-invalid.json:2: 'if' condition has unknown key 'val'
+enum-if-invalid.json:2: 'if' condition of 'data' member 'bar' has unknown key
'val'
Valid keys are 'all', 'any', 'not'.
--
2.31.1
- [PULL 01/13] qapi: Set boolean value correctly in examples, (continued)
- [PULL 01/13] qapi: Set boolean value correctly in examples, Markus Armbruster, 2021/09/03
- [PULL 06/13] qapi: Fix C code generation for 'if', Markus Armbruster, 2021/09/03
- [PULL 10/13] qapi: Use re.fullmatch() where appropriate, Markus Armbruster, 2021/09/03
- [PULL 04/13] tests/qapi-schema: Correct two 'if' conditionals, Markus Armbruster, 2021/09/03
- [PULL 03/13] qapi: Simplify how QAPISchemaIfCond represents "no condition", Markus Armbruster, 2021/09/03
- [PULL 05/13] tests/qapi-schema: Demonstrate broken C code for 'if', Markus Armbruster, 2021/09/03
- [PULL 08/13] qapi: Avoid redundant parens in code generated for conditionals, Markus Armbruster, 2021/09/03
- [PULL 12/13] qapi: Tweak error messages for missing / conflicting meta-type, Markus Armbruster, 2021/09/03
- [PULL 11/13] tests/qapi-schema: Hide OrderedDict in test output, Markus Armbruster, 2021/09/03
- [PULL 02/13] qapi: Simplify QAPISchemaIfCond's interface for generating C, Markus Armbruster, 2021/09/03
- [PULL 13/13] qapi: Tweak error messages for unknown / conflicting 'if' keys,
Markus Armbruster <=
- [PULL 07/13] qapi: Factor common recursion out of cgen_ifcond(), docgen_ifcond(), Markus Armbruster, 2021/09/03
- [PULL 09/13] qapi: Use "not COND" instead of "!COND" for generated documentation, Markus Armbruster, 2021/09/03
- Re: [PULL 00/13] QAPI patches patches for 2021-09-03, Peter Maydell, 2021/09/05