diff options
author | Tatyana Krasnukha <tatyana@synopsys.com> | 2020-01-09 16:55:45 +0300 |
---|---|---|
committer | Tatyana Krasnukha <tatyana@synopsys.com> | 2020-01-10 16:31:02 +0300 |
commit | e4d672971030fe26dbb8237038038c3ff9ae7541 (patch) | |
tree | 53baa767c32ca03dabee9a5b4184347bda4a1557 /lldb/packages/Python | |
parent | 564481aebe18a723c9cfe9ea9ca5808771f7e9d8 (diff) | |
download | bcm5719-llvm-e4d672971030fe26dbb8237038038c3ff9ae7541.tar.gz bcm5719-llvm-e4d672971030fe26dbb8237038038c3ff9ae7541.zip |
[lldb][tests] Take into account all parent's categories when traverse folders upwards
This is needed to not re-write parent's categories by categories of a nested folder,
e.g. commands/expression/completion specify "cmdline" category, however it still belongs
to parent's "expression" category.
The sentinel ".categories" in the test-suite root directory is no longer needed.
Differential Revision: https://reviews.llvm.org/D71905
Diffstat (limited to 'lldb/packages/Python')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/.categories | 0 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/test_result.py | 25 |
2 files changed, 13 insertions, 12 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/.categories b/lldb/packages/Python/lldbsuite/test/.categories deleted file mode 100644 index e69de29bb2d..00000000000 --- a/lldb/packages/Python/lldbsuite/test/.categories +++ /dev/null diff --git a/lldb/packages/Python/lldbsuite/test/test_result.py b/lldb/packages/Python/lldbsuite/test/test_result.py index 6920eacb843..efa44b0e48d 100644 --- a/lldb/packages/Python/lldbsuite/test/test_result.py +++ b/lldb/packages/Python/lldbsuite/test/test_result.py @@ -106,9 +106,8 @@ class LLDBTestResult(unittest2.TextTestResult): 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 @@ class LLDBTestResult(unittest2.TextTestResult): 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): """ |