tatyana-krasnukha created this revision. tatyana-krasnukha added reviewers: labath, teemperor. Herald added subscribers: lldb-commits, JDevlieghere. Herald added a project: LLDB.
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. Repository: rLLDB LLDB https://reviews.llvm.org/D71905 Files: packages/Python/lldbsuite/test/test_result.py Index: packages/Python/lldbsuite/test/test_result.py =================================================================== --- packages/Python/lldbsuite/test/test_result.py +++ packages/Python/lldbsuite/test/test_result.py @@ -107,26 +107,26 @@ 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 + collecting values of ".categories" files. We start at the folder the test is in + and traverse the hierarchy upwards - we guarantee a .categories to exist at the top level directory so we do not end up looping endlessly. """ import inspect import os.path folder = inspect.getfile(test.__class__) folder = os.path.dirname(folder) + categories = set() while folder != '/': 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 + categories.update(categories_str.split(',')) + + folder = os.path.dirname(folder) + + return list(categories) def getCategoriesForTest(self, test):
Index: packages/Python/lldbsuite/test/test_result.py =================================================================== --- packages/Python/lldbsuite/test/test_result.py +++ packages/Python/lldbsuite/test/test_result.py @@ -107,26 +107,26 @@ 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 + collecting values of ".categories" files. We start at the folder the test is in + and traverse the hierarchy upwards - we guarantee a .categories to exist at the top level directory so we do not end up looping endlessly. """ import inspect import os.path folder = inspect.getfile(test.__class__) folder = os.path.dirname(folder) + categories = set() while folder != '/': 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 + categories.update(categories_str.split(',')) + + folder = os.path.dirname(folder) + + return list(categories) def getCategoriesForTest(self, test):
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits