Skip to content

Commit

Permalink
autotest: take a list of globs that can match features
Browse files Browse the repository at this point in the history
useful if you need to test multiple features at the same time
  • Loading branch information
peterbarker committed Mar 19, 2024
1 parent f6ec471 commit 52d3efe
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions Tools/autotest/test_build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, feature, vehicle, bytes_delta):

class TestBuildOptions(object):
def __init__(self,
match_glob=None,
match_glob=[],
do_step_disable_all=True,
do_step_disable_none=False,
do_step_disable_defaults=True,
Expand Down Expand Up @@ -317,9 +317,13 @@ def run_disable_in_turn(self):
options = self.get_build_options_from_ardupilot_tree()
count = 1
for feature in sorted(options, key=lambda x : x.define):
if self.match_glob is not None:
if not fnmatch.fnmatch(feature.define, self.match_glob):
continue
match = False
for match_glob in self.match_glob:
if fnmatch.fnmatch(feature.define, match_glob):
match = True
break
if not match:
continue
with open("/tmp/run-disable-in-turn-progress", "w") as f:
f.write(f"{count}/{len(options)} {feature.define}\n")
# if feature.define < "WINCH_ENABLED":
Expand Down Expand Up @@ -355,9 +359,13 @@ def run_enable_in_turn(self):
options = self.get_build_options_from_ardupilot_tree()
count = 1
for feature in options:
if self.match_glob is not None:
if not fnmatch.fnmatch(feature.define, self.match_glob):
continue
match = False
for match_glob in self.match_glob:
if fnmatch.fnmatch(feature.define, match_glob):
match = True
break
if not match:
continue
self.progress("Enabling feature %s(%s) (%u/%u)" %
(feature.label, feature.define, count, len(options)))
with open("/tmp/run-enable-in-turn-progress", "w") as f:
Expand All @@ -377,9 +385,13 @@ def get_disable_all_defines(self):
options = self.get_build_options_from_ardupilot_tree()
defines = {}
for feature in options:
if self.match_glob is not None:
if not fnmatch.fnmatch(feature.define, self.match_glob):
continue
match = False
for match_glob in self.match_glob:
if fnmatch.fnmatch(feature.define, match_glob):
match = True
break
if not match:
continue
defines[feature.define] = 0
for define in self.must_have_defines_for_board(self._board):
defines[define] = 1
Expand Down Expand Up @@ -453,9 +465,9 @@ def run(self):

parser = optparse.OptionParser()
parser.add_option("--define-match-glob",
type='string',
default=None,
help='feature define must match this glob to be tested')
default=[],
action='append',
help='feature define must match any of these globs to be tested')
parser.add_option("--no-run-with-defaults",
action='store_true',
help='Do not run the run-with-defaults step')
Expand Down

0 comments on commit 52d3efe

Please sign in to comment.