diff options
author | Dave Lee <davelee.com@gmail.com> | 2022-06-16 17:38:47 -0700 |
---|---|---|
committer | Dave Lee <davelee.com@gmail.com> | 2022-06-17 14:34:49 -0700 |
commit | 4cc8f2a017c76af25234afc7c380550e9c93135c (patch) | |
tree | 00d67f518df77141ed8f1434c3f6bc4ce0345ea4 /lldb/packages/Python/lldbsuite/test/lldbtest.py | |
parent | 303c4c37ea49f9cf43e5252c4d97904e344c59cf (diff) | |
download | llvm-4cc8f2a017c76af25234afc7c380550e9c93135c.zip llvm-4cc8f2a017c76af25234afc7c380550e9c93135c.tar.gz llvm-4cc8f2a017c76af25234afc7c380550e9c93135c.tar.bz2 |
[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
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbtest.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index c3dc2a9..2285173 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -4,10 +4,6 @@ LLDB module which provides the abstract base class of lldb test case. The concrete subclass can override lldbtest.TestBase in order to inherit the common behavior for unitest.TestCase.setUp/tearDown implemented in this file. -The subclass should override the attribute mydir in order for the python runtime -to locate the individual test cases when running as part of a large test suite -or when running each test case as a separate python invocation. - ./dotest.py provides a test driver which sets up the environment to run the entire of part of the test suite . Example: @@ -539,7 +535,9 @@ class Base(unittest2.TestCase): Do current directory manipulation. """ # Fail fast if 'mydir' attribute is not overridden. - if not cls.mydir or len(cls.mydir) == 0: + if not cls.mydir: + cls.mydir = Base.compute_mydir(sys.modules[cls.__module__].__file__) + if not cls.mydir: raise Exception("Subclasses must override the 'mydir' attribute.") # Save old working directory. @@ -1703,11 +1701,6 @@ class TestBase(Base): Important things for test class writers: - - Overwrite the mydir class attribute, otherwise your test class won't - run. It specifies the relative directory to the top level 'test' so - the test harness can change to the correct working directory before - running your test. - - The setUp method sets up things to facilitate subsequent interactions with the debugger as part of the test. These include: - populate the test method name |