mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 23:51:56 +00:00
[lldb][test] NFC, re-use _getTestPath() function
This commit is contained in:
parent
e4d6729710
commit
9ba1512748
@ -7,10 +7,7 @@ Provides the LLDBTestResult class, which holds information about progress
|
||||
and results of a single test run.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# System modules
|
||||
import inspect
|
||||
import os
|
||||
|
||||
# Third-party modules
|
||||
@ -102,22 +99,26 @@ class LLDBTestResult(unittest2.TextTestResult):
|
||||
else:
|
||||
return str(test)
|
||||
|
||||
@staticmethod
|
||||
def _getFileBasedCategories(test):
|
||||
def _getTestPath(self, test):
|
||||
# Use test.test_filename if the test was created with
|
||||
# lldbinline.MakeInlineTest().
|
||||
if test is None:
|
||||
return ""
|
||||
elif hasattr(test, "test_filename"):
|
||||
return test.test_filename
|
||||
else:
|
||||
import inspect
|
||||
return inspect.getsourcefile(test.__class__)
|
||||
|
||||
def _getFileBasedCategories(self, test):
|
||||
"""
|
||||
Returns the list of categories to which this test case belongs by
|
||||
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
|
||||
# Use test.test_filename if the test was created with
|
||||
# lldbinline.MakeInlineTest().
|
||||
if hasattr(test, 'test_filename'):
|
||||
start_path = test.test_filename
|
||||
else:
|
||||
start_path = inspect.getfile(test.__class__)
|
||||
start_path = self._getTestPath(test)
|
||||
|
||||
import os.path
|
||||
folder = os.path.dirname(start_path)
|
||||
|
||||
from lldbsuite import lldb_test_root as test_root
|
||||
@ -198,14 +199,6 @@ class LLDBTestResult(unittest2.TextTestResult):
|
||||
exception = err_tuple[1]
|
||||
return isinstance(exception, build_exception.BuildError)
|
||||
|
||||
def _getTestPath(self, test):
|
||||
if test is None:
|
||||
return ""
|
||||
elif hasattr(test, "test_filename"):
|
||||
return test.test_filename
|
||||
else:
|
||||
return inspect.getsourcefile(test.__class__)
|
||||
|
||||
def _saveBuildErrorTuple(self, test, err):
|
||||
# Adjust the error description so it prints the build command and build error
|
||||
# rather than an uninformative Python backtrace.
|
||||
|
Loading…
Reference in New Issue
Block a user