From a22a7d70e6a9055dcfc5d9e0dac6bb32c192ed5b Mon Sep 17 00:00:00 2001 From: Pierre Equoy Date: Tue, 19 Mar 2024 11:21:26 +0800 Subject: [PATCH] Add support for bootstrap_include section - Move the V class one level above, so it can be used for the different include sections of the test plan. - Fix issue found by Max (`mandatory_include` was parsed only if there was an `include` section) - Add support for `bootstrap_include` for good measure --- checkbox-ng/plainbox/impl/unit/testplan.py | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/checkbox-ng/plainbox/impl/unit/testplan.py b/checkbox-ng/plainbox/impl/unit/testplan.py index 307665c1e..efbb97315 100644 --- a/checkbox-ng/plainbox/impl/unit/testplan.py +++ b/checkbox-ng/plainbox/impl/unit/testplan.py @@ -826,25 +826,27 @@ def _get_inline_overrides( collected into a list of tuples ``(field, value)`` and this list is subsequently packed into a tuple ``(pattern, field_value_list)``. """ - override_list = [] - if testplan.include is not None: - - class V(Visitor): + class V(Visitor): - def visit_IncludeStmt_node(self, node: IncludeStmt): - if not node.overrides: - return - pattern = r"^{}$".format( - testplan.qualify_id(node.pattern.text)) - field_value_list = [ - (override_exp.field.text.replace('-', '_'), - override_exp.value.text) - for override_exp in node.overrides] - override_list.append((pattern, field_value_list)) - - V().visit(IncludeStmtList.parse(testplan.include)) - if testplan.mandatory_include: - V().visit(IncludeStmtList.parse(testplan.mandatory_include)) + def visit_IncludeStmt_node(self, node: IncludeStmt): + if not node.overrides: + return + pattern = r"^{}$".format( + testplan.qualify_id(node.pattern.text)) + field_value_list = [ + (override_exp.field.text.replace('-', '_'), + override_exp.value.text) + for override_exp in node.overrides] + override_list.append((pattern, field_value_list)) + override_list = [] + include_sections = ( + testplan.bootstrap_include, + testplan.mandatory_include, + testplan.include, + ) + for section in include_sections: + if section: + V().visit(IncludeStmtList.parse(section)) for tp_unit in testplan.get_nested_part(): override_list.extend(self._get_inline_overrides(tp_unit)) return override_list