diff --git a/Tools/px4events/srcparser.py b/Tools/px4events/srcparser.py index c175a38c0f..400e04a1bd 100644 --- a/Tools/px4events/srcparser.py +++ b/Tools/px4events/srcparser.py @@ -92,7 +92,7 @@ class SourceParser(object): re_comment_start = re.compile(r'^\/\*\s*EVENT$') re_events_send = re.compile(r'^events::send[<\(]') re_comment_content = re.compile(r'^\*\s*(.*)') - re_comment_tag = re.compile(r'^@([a-zA-Z][a-zA-Z0-9_]*):?\s*(.*)') + re_comment_tag = re.compile(r'^@([a-zA-Z][a-zA-Z0-9_-]*):?\s*(.*)') re_comment_end = re.compile(r'(.*?)\s*\*\/$') re_code_end = re.compile(r'(.*?)\s*;$') re_template_args = re.compile(r'([a-zA-Z0-9_:\.]+)\s*<([a-zA-Z0-9_,\s:]+)\s*>\s*\((.*)\);$') @@ -107,7 +107,7 @@ class SourceParser(object): """ dict of 'group': [Event] list """ return self._events - def Parse(self, contents): + def Parse(self, contents, path): """ Incrementally parse program contents and append all found events to the list. @@ -117,7 +117,7 @@ class SourceParser(object): # names. state = None def finalize_current_tag(event, tag, value): - if tag is None: return + if tag is None: return True if tag == "description": descr = value.strip() # merge continued lines (but not e.g. enumerations) @@ -133,6 +133,9 @@ class SourceParser(object): "If this is not a typo, add the new group to the script".format(event.group, known_groups)) elif tag == "type": event.type = value.strip() + elif tag == "skip-file": + print("Skipping file: {:}".format(path)) + return False elif tag.startswith("arg"): arg_index = int(tag[3:])-1 arg_name = value.strip() @@ -140,6 +143,7 @@ class SourceParser(object): event.add_argument(None, arg_name) else: raise Exception("Invalid tag: {}\nvalue: {}".format(tag, value)) + return True for line in self.re_split_lines.split(contents): line = line.strip() @@ -267,7 +271,8 @@ class SourceParser(object): comment_content = m.group(1) m = self.re_comment_tag.match(comment_content) if m: - finalize_current_tag(event, current_tag, current_value) + if not finalize_current_tag(event, current_tag, current_value): + return True # skip file current_tag, current_value = m.group(1, 2) elif current_tag is not None: current_value += "\n"+comment_content @@ -277,7 +282,8 @@ class SourceParser(object): # "*" or "*/". raise Exception("Excpected a comment, got '{}'".format(line)) if last_comment_line: - finalize_current_tag(event, current_tag, current_value) + if not finalize_current_tag(event, current_tag, current_value): + return True # skip file state = "parse-command" return True diff --git a/Tools/px4events/srcscanner.py b/Tools/px4events/srcscanner.py index 3f14fb949d..7f378a2c6b 100644 --- a/Tools/px4events/srcscanner.py +++ b/Tools/px4events/srcscanner.py @@ -46,7 +46,7 @@ class SourceScanner(object): print('Failed reading file: %s, skipping content.' % path) pass try: - return parser.Parse(contents) + return parser.Parse(contents, path) except Exception as e: print("Exception while parsing file {}".format(path)) raise diff --git a/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecksTest.cpp b/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecksTest.cpp index d54bce6c2e..33f754cc86 100644 --- a/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecksTest.cpp +++ b/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecksTest.cpp @@ -43,6 +43,9 @@ using namespace time_literals; // to run: make tests TESTFILTER=HealthAndArmingChecks +/* EVENT + * @skip-file + */ class ReporterTest : public ::testing::Test