Skip to content

Commit

Permalink
Add support for bootstrap_include section
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
pieqq committed Mar 19, 2024
1 parent bf2716c commit a22a7d7
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions checkbox-ng/plainbox/impl/unit/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a22a7d7

Please sign in to comment.