[igt-dev] [PATCH i-g-t v5 09/11] scripts/test_list.py: add support for expanding fields on spreadsheet
Mauro Carvalho Chehab
mauro.chehab at linux.intel.com
Fri Sep 8 10:31:51 UTC 2023
From: Mauro Carvalho Chehab <mchehab at kernel.org>
Sometimes, it is desired to expand a field into multiple columns
when generating a spreadsheet. Add support for it.
Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
scripts/test_list.py | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/scripts/test_list.py b/scripts/test_list.py
index 01f6528ac84c..74abdc5ebe65 100644
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -759,7 +759,7 @@ class TestList:
else:
return out
- def get_spreadsheet(self):
+ def get_spreadsheet(self, expand_fields = {}):
"""
Return a bidimentional array with the test contents.
@@ -768,6 +768,7 @@ class TestList:
separate python file that would create a workbook's sheet.
"""
+ expand_field_name = {}
sheet = []
row = 0
sheet.append([])
@@ -779,6 +780,9 @@ class TestList:
fields_order = []
fields = sorted(self.props.items(), key = _sort_per_level)
for item in fields:
+ if item[0] in expand_fields.keys():
+ expand_field_name[item[0]] = set()
+ continue
fields_order.append(item[0])
sheet[row].append(item[0])
@@ -799,6 +803,35 @@ class TestList:
sheet[row].append(fields[field])
else:
sheet[row].append('')
+
+ for field in expand_fields.keys():
+ names = fields.get(field)
+ if not names:
+ continue
+
+ names = set(re.split(r",\s*", names))
+ expand_field_name[field].update(names)
+
+ # Add expanded fields, if any
+ for item in sorted(expand_fields.keys(), key=str.lower):
+ prefix = expand_fields[item]
+
+ for field in sorted(list(expand_field_name[item]), key=str.lower):
+ row = 0
+ sheet[row].append(prefix + field)
+
+ for subtest, fields in subtests:
+ row += 1
+ value = ""
+ names = fields.get(item)
+ if names:
+ names = set(re.split(r",\s*", names))
+
+ if field in names:
+ value = "Yes"
+
+ sheet[row].append(value)
+
return sheet
def print_nested_rest(self, filename = None, return_string = False):
--
2.41.0
More information about the igt-dev
mailing list