[igt-dev] [PATCH i-g-t 3/3] scripts/test_list.py: use a compiled regex for check

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Wed Apr 12 12:35:45 UTC 2023


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

Speed up even further the logic for --check-testlist by
pre-compiling the regex that will be used to validate the
results.

Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
 scripts/test_list.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/test_list.py b/scripts/test_list.py
index 287351e717b3..acdd1cac4c20 100755
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -820,10 +820,18 @@ class TestList:
         run_missing = []
         doc_uneeded = []
 
+        test_regex = r""
+        for doc_test in doc_subtests:
+            if test_regex != r"":
+                test_regex += r"|"
+            test_regex += r'^' + doc_test + r'$'
+
+        test_regex = re.compile(test_regex)
+
         for doc_test in doc_subtests:
             found = False
             for run_test in run_subtests:
-                if re.match(r'^' + doc_test + r'$', run_test):
+                if re.match(test_regex, run_test):
                     found = True
                     break
             if not found:
@@ -832,7 +840,7 @@ class TestList:
         for run_test in run_subtests:
             found = False
             for doc_test in doc_subtests:
-                if re.match(r'^' + doc_test + r'$', run_test):
+                if re.match(test_regex, run_test):
                     found = True
                     break
             if not found:
-- 
2.39.2



More information about the igt-dev mailing list