Skip to content

Commit 4cc8f2a

Browse files
committed
[lldb][tests] Automatically call compute_mydir (NFC)
Eliminate boilerplate of having each test manually assign to `mydir` by calling `compute_mydir` in lldbtest.py. Differential Revision: https://reviews.llvm.org/D128077
1 parent 303c4c3 commit 4cc8f2a

File tree

958 files changed

+4
-1862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

958 files changed

+4
-1862
lines changed

lldb/packages/Python/lldbsuite/test/README-TestSuite

Lines changed: 1 addition & 3 deletions

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
The concrete subclass can override lldbtest.TestBase in order to inherit the
55
common behavior for unitest.TestCase.setUp/tearDown implemented in this file.
66
7-
The subclass should override the attribute mydir in order for the python runtime
8-
to locate the individual test cases when running as part of a large test suite
9-
or when running each test case as a separate python invocation.
10-
117
./dotest.py provides a test driver which sets up the environment to run the
128
entire of part of the test suite . Example:
139
@@ -539,7 +535,9 @@ def setUpClass(cls):
539535
Do current directory manipulation.
540536
"""
541537
# Fail fast if 'mydir' attribute is not overridden.
542-
if not cls.mydir or len(cls.mydir) == 0:
538+
if not cls.mydir:
539+
cls.mydir = Base.compute_mydir(sys.modules[cls.__module__].__file__)
540+
if not cls.mydir:
543541
raise Exception("Subclasses must override the 'mydir' attribute.")
544542

545543
# Save old working directory.
@@ -1703,11 +1701,6 @@ class TestBase(Base):
17031701
17041702
Important things for test class writers:
17051703
1706-
- Overwrite the mydir class attribute, otherwise your test class won't
1707-
run. It specifies the relative directory to the top level 'test' so
1708-
the test harness can change to the correct working directory before
1709-
running your test.
1710-
17111704
- The setUp method sets up things to facilitate subsequent interactions
17121705
with the debugger as part of the test. These include:
17131706
- populate the test method name

lldb/test/API/android/platform/TestDefaultCacheLineSize.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212

1313
class DefaultCacheLineSizeTestCase(TestBase):
14-
15-
mydir = TestBase.compute_mydir(__file__)
1614
NO_DEBUG_INFO_TESTCASE = True
1715

1816
@skipUnlessTargetAndroid

lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313

1414
class SBDirCheckerCase(TestBase):
15-
16-
mydir = TestBase.compute_mydir(__file__)
1715
NO_DEBUG_INFO_TESTCASE = True
1816

1917
def setUp(self):

lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
class TestSBCommandReturnObject(TestBase):
12-
13-
mydir = TestBase.compute_mydir(__file__)
1412
NO_DEBUG_INFO_TESTCASE = True
1513

1614
@skipIfNoSBHeaders

lldb/test/API/api/listeners/TestListener.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import six
1111

1212
class ListenToModuleLoadedEvents (TestBase):
13-
14-
mydir = TestBase.compute_mydir(__file__)
1513
NO_DEBUG_INFO_TESTCASE = True
1614

1715
def test_clearing_listener(self):

lldb/test/API/api/log/TestAPILog.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
class APILogTestCase(TestBase):
1313

14-
mydir = TestBase.compute_mydir(__file__)
15-
1614
NO_DEBUG_INFO_TESTCASE = True
1715

1816
def test_api_log(self):

lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
class TestMultipleSimultaneousDebuggers(TestBase):
1515

16-
mydir = TestBase.compute_mydir(__file__)
17-
1816
NO_DEBUG_INFO_TESTCASE = True
1917

2018
@skipIfNoSBHeaders

lldb/test/API/api/multiple-targets/TestMultipleTargets.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313

1414
class TestMultipleTargets(TestBase):
15-
16-
mydir = TestBase.compute_mydir(__file__)
1715
NO_DEBUG_INFO_TESTCASE = True
1816

1917
@skipIf(oslist=["linux"], archs=["arm", "aarch64"])

lldb/test/API/api/multithreaded/TestMultithreaded.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ def setUp(self):
2525
self.generateSource('test_listener_resume.cpp')
2626
self.generateSource('test_stop-hook.cpp')
2727

28-
mydir = TestBase.compute_mydir(__file__)
29-
3028
@skipIfRemote
3129
@skipIfNoSBHeaders
3230
# clang-cl does not support throw or catch (llvm.org/pr24538)

0 commit comments

Comments
 (0)