[Lldb-commits] [PATCH] D71905: [lldb][tests] Take into account all parent's categories when traverse folders upwards
Tatyana Krasnukha via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 10 05:36:50 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe4d672971030: [lldb][tests] Take into account all parent's categories when traverse folders… (authored by tatyana-krasnukha).
Changed prior to commit:
https://reviews.llvm.org/D71905?vs=237079&id=237294#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71905/new/
https://reviews.llvm.org/D71905
Files:
lldb/packages/Python/lldbsuite/test/.categories
lldb/packages/Python/lldbsuite/test/test_result.py
Index: lldb/packages/Python/lldbsuite/test/test_result.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -106,9 +106,8 @@
def _getFileBasedCategories(test):
"""
Returns the list of categories to which this test case belongs by
- looking for a ".categories" file. We start at the folder the test is in
- an traverse the hierarchy upwards - we guarantee a .categories to exist
- at the top level directory so we do not end up looping endlessly.
+ collecting values of ".categories" files. We start at the folder the test is in
+ and traverse the hierarchy upwards until the test-suite root directory.
"""
import inspect
import os.path
@@ -120,20 +119,22 @@
start_path = inspect.getfile(test.__class__)
folder = os.path.dirname(start_path)
- while folder != '/':
+
+ from lldbsuite import lldb_test_root as test_root
+ if test_root != os.path.commonprefix([folder, test_root]):
+ raise Exception("The test file %s is outside the test root directory" % start_path)
+
+ categories = set()
+ while not os.path.samefile(folder, test_root):
categories_file_name = os.path.join(folder, ".categories")
if os.path.exists(categories_file_name):
categories_file = open(categories_file_name, 'r')
- categories = categories_file.readline()
+ categories_str = categories_file.readline().strip()
categories_file.close()
- categories = str.replace(categories, '\n', '')
- categories = str.replace(categories, '\r', '')
- return categories.split(',')
- else:
- folder = os.path.dirname(folder)
- continue
- raise Exception("Did not find a .categories file, starting at: %s" % start_path)
+ categories.update(categories_str.split(','))
+ folder = os.path.dirname(folder)
+ return list(categories)
def getCategoriesForTest(self, test):
"""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71905.237294.patch
Type: text/x-patch
Size: 2242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200110/3d5f01f2/attachment.bin>
More information about the lldb-commits
mailing list