From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id E769010E97C for ; Fri, 10 Mar 2023 08:24:04 +0000 (UTC) From: =?UTF-8?q?Zbigniew=20Kempczy=C5=84ski?= To: igt-dev@lists.freedesktop.org Date: Fri, 10 Mar 2023 09:23:19 +0100 Message-Id: <20230310082326.12088-12-zbigniew.kempczynski@intel.com> In-Reply-To: <20230310082326.12088-1-zbigniew.kempczynski@intel.com> References: <20230310082326.12088-1-zbigniew.kempczynski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t 11/18] scripts/igt_doc.py: use a different logic to get IGT prefix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: From: Mauro Carvalho Chehab The past logic was dependent on how the initial Xe IGT support was conceived. Change it to be more generic and use os.path.commonprefix. Signed-off-by: Mauro Carvalho Chehab --- scripts/igt_doc.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py index 5b08ac1442..f1b6d64615 100755 --- a/scripts/igt_doc.py +++ b/scripts/igt_doc.py @@ -235,7 +235,6 @@ class TestList: def __init__(self, config_fname, include_plan, file_list): self.doc = {} self.test_number = 0 - self.min_test_prefix = '' self.config = None self.filenames = file_list self.plan_filenames = [] @@ -494,7 +493,7 @@ class TestList: for test in self.doc: # pylint: disable=C0206 fname = self.doc[test]["File"] - name = re.sub(r'.*tests/', '', fname) + name = re.sub(r'.*/', '', fname) name = re.sub(r'\.[\w+]$', '', name) name = "igt@" + name @@ -548,7 +547,7 @@ class TestList: for test in sorted(self.doc.keys()): fname = self.doc[test]["File"] - name = re.sub(r'.*tests/', '', fname) + name = re.sub(r'.*/', '', fname) name = re.sub(r'\.[ch]', '', name) name = "igt@" + name @@ -720,7 +719,7 @@ class TestList: for test in sorted(self.doc.keys()): fname = self.doc[test]["File"] - test_name = re.sub(r'.*tests/', '', fname) + test_name = re.sub(r'.*/', '', fname) test_name = re.sub(r'\.[ch]', '', test_name) test_name = "igt@" + test_name @@ -759,10 +758,12 @@ class TestList: for i in range(0, len(doc_subtests)): # pylint: disable=C0200 doc_subtests[i] = re.sub(r'\<[^\>]+\>', r'\\d+', doc_subtests[i]) + test_prefix = os.path.commonprefix(doc_subtests) + # Get a list of tests from try: result = subprocess.run([ f"{IGT_BUILD_PATH}/{IGT_RUNNER}", - "-L", "-t", self.min_test_prefix, + "-L", "-t", test_prefix, f"{IGT_BUILD_PATH}/tests"], check = True, stdout=subprocess.PIPE, universal_newlines=True) except subprocess.CalledProcessError as sub_err: @@ -824,14 +825,6 @@ class TestList: cur_arg = -1 cur_arg_element = 0 - prefix = re.sub(r'.*tests/', '', fname) - prefix = r'igt\@' + re.sub(r'(.*/).*', r'\1', prefix) - - if self.min_test_prefix == '': - self.min_test_prefix = prefix - elif len(prefix) < len(self.min_test_prefix): - self.min_test_prefix = prefix - with open(fname, 'r', encoding='utf8') as handle: arg_ref = None current_test = '' -- 2.34.1