Author: labath Date: Thu Nov 2 15:13:09 2017 New Revision: 317277 URL: http://llvm.org/viewvc/llvm-project?rev=317277&view=rev Log: Remove getCategories mechanism of specifying test categories
Summary: This mechanism was mostly redundant with the file-based .categories mechanism, and it was interfering with it, as any test which implemented a getCategories method would not inherit the filesystem categories. This patch removes it. The existing categories are preserved either by adding a .categories file, or using the @add_test_categories decorator. Reviewers: jingham, clayborg, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D39515 Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/.categories lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/.categories lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/.categories Modified: lldb/trunk/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py lldb/trunk/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py lldb/trunk/packages/Python/lldbsuite/test/test_result.py lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py Modified: lldb/trunk/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py Thu Nov 2 15:13:09 2017 @@ -30,8 +30,5 @@ class SequenceFunctionsTestCase(unittest for element in random.sample(self.seq, 5): self.assertTrue(element in self.seq) - def getCategories(self): - return [] - if __name__ == '__main__': unittest.main() Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py Thu Nov 2 15:13:09 2017 @@ -16,15 +16,13 @@ from lldbsuite.test import lldbutil class ExprDoesntDeadlockTestCase(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946') @expectedFailureAll( oslist=["windows"], bugnumber="Windows doesn't have pthreads, test needs to be ported") + @add_test_categories(["basic_process"]) def test_with_run_command(self): """Test that expr will time out and allow other threads to run if it blocks.""" self.build() Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/.categories URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/.categories?rev=317277&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/.categories (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/.categories Thu Nov 2 15:13:09 2017 @@ -0,0 +1 @@ +basic_process Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py Thu Nov 2 15:13:09 2017 @@ -17,9 +17,6 @@ from lldbsuite.test import lldbutil @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently class LoadUnloadTestCase(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) def setUp(self): Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories?rev=317277&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories Thu Nov 2 15:13:09 2017 @@ -0,0 +1 @@ +basic_process Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py Thu Nov 2 15:13:09 2017 @@ -15,9 +15,6 @@ class TestCStepping(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - def setUp(self): # Call super's setUp(). TestBase.setUp(self) Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py Thu Nov 2 15:13:09 2017 @@ -15,9 +15,6 @@ from lldbsuite.test import lldbutil class HelloWatchpointTestCase(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) def setUp(self): @@ -37,6 +34,7 @@ class HelloWatchpointTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @add_test_categories(["basic_process"]) def test_hello_watchpoint_using_watchpoint_set(self): """Test a simple sequence of watchpoint creation and watchpoint hit.""" self.build(dictionary=self.d) Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py Thu Nov 2 15:13:09 2017 @@ -13,9 +13,6 @@ class TestStepOverWatchpoint(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - @expectedFailureAll( oslist=["linux"], archs=[ @@ -28,6 +25,7 @@ class TestStepOverWatchpoint(TestBase): # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) @expectedFailureAll(oslist=["ios", "watchos", "tvos", "bridgeos"], bugnumber="<rdar://problem/34027183>") # watchpoint tests aren't working on arm64 + @add_test_categories(["basic_process"]) def test(self): """Test stepping over watchpoints.""" self.build() Added: lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/.categories URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/.categories?rev=317277&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/.categories (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/.categories Thu Nov 2 15:13:09 2017 @@ -0,0 +1 @@ +basic_process Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py Thu Nov 2 15:13:09 2017 @@ -14,9 +14,6 @@ class TestStepTarget(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - def setUp(self): # Call super's setUp(). TestBase.setUp(self) Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py Thu Nov 2 15:13:09 2017 @@ -15,16 +15,13 @@ class TestCStepping(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers that we will step to in main: self.main_source = "main.c" - @add_test_categories(['pyapi']) + @add_test_categories(['pyapi', 'basic_process']) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17932') @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr14437") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24777") Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py Thu Nov 2 15:13:09 2017 @@ -13,9 +13,6 @@ from lldbsuite.test import lldbutil class TestObjCStepping(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) def setUp(self): @@ -35,7 +32,7 @@ class TestObjCStepping(TestBase): self.main_source, '// Step over nil should stop here.') @skipUnlessDarwin - @add_test_categories(['pyapi']) + @add_test_categories(['pyapi', 'basic_process']) def test_with_python_api(self): """Test stepping through ObjC method dispatch in various forms.""" self.build() Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Nov 2 15:13:09 2017 @@ -1834,30 +1834,6 @@ class TestBase(Base): # Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable. timeWaitNextLaunch = 1.0 - # Returns the list of categories to which this test case belongs - # by default, look for a ".categories" file, and read its contents - # if no such file exists, traverse the hierarchy - we guarantee - # a .categories to exist at the top level directory so we do not end up - # looping endlessly - subclasses are free to define their own categories - # in whatever way makes sense to them - def getCategories(self): - import inspect - import os.path - folder = inspect.getfile(self.__class__) - folder = os.path.dirname(folder) - 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_file.close() - categories = str.replace(categories, '\n', '') - categories = str.replace(categories, '\r', '') - return categories.split(',') - else: - folder = os.path.dirname(folder) - continue - def generateSource(self, source): template = source + '.template' temp = os.path.join(os.getcwd(), template) Modified: lldb/trunk/packages/Python/lldbsuite/test/test_result.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/test_result.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/test_result.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/test_result.py Thu Nov 2 15:13:09 2017 @@ -105,6 +105,32 @@ class LLDBTestResult(unittest2.TextTestR else: return str(test) + @staticmethod + 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. + """ + import inspect + import os.path + folder = inspect.getfile(test.__class__) + folder = os.path.dirname(folder) + 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_file.close() + categories = str.replace(categories, '\n', '') + categories = str.replace(categories, '\r', '') + return categories.split(',') + else: + folder = os.path.dirname(folder) + continue + + def getCategoriesForTest(self, test): """ Gets all the categories for the currently running test method in test case @@ -114,7 +140,7 @@ class LLDBTestResult(unittest2.TextTestR if test_method is not None and hasattr(test_method, "categories"): test_categories.extend(test_method.categories) - test_categories.extend(test.getCategories()) + test_categories.extend(self._getFileBasedCategories(test)) return test_categories Added: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/.categories URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/.categories?rev=317277&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/.categories (added) +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/.categories Thu Nov 2 15:13:09 2017 @@ -0,0 +1 @@ +lldb-mi Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py?rev=317277&r1=317276&r2=317277&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py Thu Nov 2 15:13:09 2017 @@ -14,9 +14,6 @@ class MiTestCaseBase(Base): myexe = "a.out" mylog = "child.log" - def getCategories(self): - return ['lldb-mi'] - @classmethod def classCleanup(cls): TestBase.RemoveTempFile(cls.myexe) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits