[igt-dev] [PATCH i-g-t v3 07/14] scripts/test_list.py: don't rely on file name to parse config

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Thu Jul 13 07:50:47 UTC 2023


From: Mauro Carvalho Chehab <mchehab at kernel.org>

Currently, config_fname should not be empty, as the class init
will fail. Make the logic more generic to prepare to optionally pass
the configuration dict directly.

Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
 scripts/test_list.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/scripts/test_list.py b/scripts/test_list.py
index ac77d6523672..465c73c3bdef 100644
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -255,7 +255,6 @@ class TestList:
         self.filenames = file_list
         self.plan_filenames = []
         self.props = {}
-        self.config_fname = config_fname
         self.built_testlist = built_testlist
         self.level_count = 0
         self.field_list = {}
@@ -274,6 +273,9 @@ class TestList:
         with open(config_fname, 'r', encoding='utf8') as handle:
             self.config = json.load(handle)
 
+        config_origin = config_fname
+        cfg_path = os.path.realpath(os.path.dirname(config_fname)) + "/"
+
         self.__add_field(None, 0, 0, self.config["fields"])
 
         sublevel_count = [ 0 ] * self.level_count
@@ -314,12 +316,12 @@ class TestList:
             files = self.config["files"]
             exclude_file_glob = self.config.get("exclude_files", [])
             for cfg_file in exclude_file_glob:
-                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                cfg_file = cfg_path + cfg_file
                 for fname in glob.glob(cfg_file):
                     exclude_files.append(fname)
 
             for cfg_file in files:
-                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                cfg_file = cfg_path + cfg_file
                 for fname in glob.glob(cfg_file):
                     if fname in exclude_files:
                         continue
@@ -335,7 +337,7 @@ class TestList:
             implemented_class = "Implemented"
             files = self.config["planning_files"]
             for cfg_file in files:
-                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                cfg_file = cfg_path + cfg_file
                 for fname in glob.glob(cfg_file):
                     self.plan_filenames.append(fname)
                     has_planned = True
@@ -363,12 +365,12 @@ class TestList:
                 continue
 
             self.__add_file_documentation(fname, implemented_class, field_re,
-                                          test_tag, subtest_tag)
+                                          test_tag, subtest_tag, config_origin)
 
         if include_plan:
             for fname in self.plan_filenames:
                 self.__add_file_documentation(fname, planned_class, field_re,
-                                              test_tag, subtest_tag)
+                                              test_tag, subtest_tag, config_origin)
 
     #
     # ancillary methods
@@ -1003,7 +1005,7 @@ class TestList:
     #
 
     def __add_file_documentation(self, fname, implemented_class, field_re,
-                                 test_tag, subtest_tag):
+                                 test_tag, subtest_tag, config_origin):
 
         """Adds the contents of test/subtest documentation form a file"""
 
@@ -1215,7 +1217,7 @@ class TestList:
 
                 file_line.rstrip(r"\n")
                 sys.exit(f"{fname}:{file_ln + 1}: Error: unrecognized line. Need to add field at %s?\n\t==> %s" %
-                         (self.config_fname, file_line))
+                         (config_origin, file_line))
 
     def show_subtests(self, sort_field):
 
-- 
2.40.1



More information about the igt-dev mailing list