Skip to content
Snippets Groups Projects
Commit 39dc06fe authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

scripts/xls_to_doc.py: detect field removal


Eventually, a field may have been removed. Add support for
detecting it at the write logic.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: default avatarKamil Konieczny <kamil.konieczny@linux.intel.com>
parent bb39b3c2
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,8 @@ class FillTests(TestList): ...@@ -37,6 +37,8 @@ class FillTests(TestList):
# Read current documentation # Read current documentation
TestList.__init__(self, config_path) TestList.__init__(self, config_path)
self.orig_doc = self.doc.copy()
self.testname_regex = re.compile(r'^\s*(igt@[^\n\@]+)\@?(\S*)\s*') self.testname_regex = re.compile(r'^\s*(igt@[^\n\@]+)\@?(\S*)\s*')
self.key_has_wildcard = re.compile(r'\%?arg\[(\d+)\]') self.key_has_wildcard = re.compile(r'\%?arg\[(\d+)\]')
self.field_re = re.compile(r"(" + '|'.join(self.field_list.keys()) + r'):\s*(.*)', re.I) self.field_re = re.compile(r"(" + '|'.join(self.field_list.keys()) + r'):\s*(.*)', re.I)
...@@ -202,7 +204,8 @@ class FillTests(TestList): ...@@ -202,7 +204,8 @@ class FillTests(TestList):
content[i] = "" content[i] = ""
content.insert(i, f' * {field}: {value}\n') if value != "":
content.insert(i, f' * {field}: {value}\n')
def parse_spreadsheet(self, fname, sheets=None): def parse_spreadsheet(self, fname, sheets=None):
""" """
...@@ -265,6 +268,8 @@ class FillTests(TestList): ...@@ -265,6 +268,8 @@ class FillTests(TestList):
test_nr = self.tests[testname]["Test"] test_nr = self.tests[testname]["Test"]
doc_content = self.orig_doc[test_nr]
for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()): for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
if "line" not in subtest_content: if "line" not in subtest_content:
print(f"Warning: didn't find where {subtest} is documented.") print(f"Warning: didn't find where {subtest} is documented.")
...@@ -280,26 +285,29 @@ class FillTests(TestList): ...@@ -280,26 +285,29 @@ class FillTests(TestList):
print(f"Warning: test {testname}, subtest {subtest} is not documented.") print(f"Warning: test {testname}, subtest {subtest} is not documented.")
continue continue
doc_content = self.doc[test_nr]["subtest"][subtest_nr] doc_content = self.orig_doc[test_nr]["subtest"][subtest_nr]
# Handling wildcards is not easy. Let's just skip those fields = set(subtest_content.keys()) | set(doc_content.keys())
for field, value in sorted(subtest_content.items()):
if field in ['line', 'subtest_nr']: for field in sorted(fields):
if field not in self.props:
continue continue
if args.ignore_lists: if args.ignore_lists:
if field in self.ignore_fields: if field in self.ignore_fields:
continue continue
doc_value = doc_content.get(field) value = subtest_content.get(field, "")
if doc_value: doc_value = doc_content.get(field, "")
if self.key_has_wildcard.search(doc_value):
print(f"Warning: {subtest} field {field} has wildcards. Skipping it.") # Handling wildcards is not easy. Let's just skip those
continue if self.key_has_wildcard.search(doc_value):
if doc_value == value: print(f"Warning: {subtest} field {field} has wildcards. Skipping it.")
if self.verbose > 1: continue
print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it") if doc_value == value:
continue if self.verbose > 1:
print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
continue
if self.verbose > 0: if self.verbose > 0:
print(f"Update {testname}@{subtest} field {field} on line {line}:") print(f"Update {testname}@{subtest} field {field} on line {line}:")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment