Skip to content

Commit

Permalink
[lldb][test][NFC] Create a separate LLDB_TEST_SRC var to allow moving…
Browse files Browse the repository at this point in the history
… tests.

Summary:
This creates a separate LLDB_TEST_SRC var to match the existing LLDB_TEST var. LLDB_TEST points to the test framework, LLDB_TEST_SRC points to the tests themselves.

The var points to the same place, but a future patch will move the tree + update var.

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: merge_guards_bot, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71150

(cherry picked from commit 25675d4)
  • Loading branch information
rupprecht authored and JDevlieghere committed Mar 6, 2020
1 parent 8b0c9cc commit 51821f1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 4 additions & 1 deletion lldb/packages/Python/lldbsuite/__init__.py
Expand Up @@ -20,10 +20,13 @@ def find_lldb_root():
# lldbsuite.lldb_root refers to the root of the git/svn source checkout
lldb_root = find_lldb_root()

# lldbsuite.lldb_test_root refers to the root of the python test tree
# lldbsuite.lldb_test_src_root refers to the root of the python test case tree
# (i.e. the actual unit tests).
lldb_test_root = os.path.join(
lldb_root,
"packages",
"Python",
"lldbsuite",
"test")
# TODO(rupprecht): update the above definition after moving test cases:
# lldb_test_root = os.path.join(lldb_root, "test", "API")
1 change: 1 addition & 0 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Expand Up @@ -489,6 +489,7 @@ def setupSysPath():
sys.exit(-1)

os.environ["LLDB_TEST"] = scriptPath
os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root

# Set up the root build directory.
builddir = configuration.test_build_dir
Expand Down
14 changes: 7 additions & 7 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Expand Up @@ -498,7 +498,7 @@ def compute_mydir(test_file):
mydir = TestBase.compute_mydir(__file__)
'''
# /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
rel_prefix = test_file[len(os.environ["LLDB_TEST"]) + 1:]
rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
return os.path.dirname(rel_prefix)

def TraceOn(self):
Expand All @@ -518,10 +518,10 @@ def setUpClass(cls):
# Save old working directory.
cls.oldcwd = os.getcwd()

# Change current working directory if ${LLDB_TEST} is defined.
# See also dotest.py which sets up ${LLDB_TEST}.
if ("LLDB_TEST" in os.environ):
full_dir = os.path.join(os.environ["LLDB_TEST"],
# Change current working directory if ${LLDB_TEST_SRC} is defined.
# See also dotest.py which sets up ${LLDB_TEST_SRC}.
if ("LLDB_TEST_SRC" in os.environ):
full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
cls.mydir)
if traceAlways:
print("Change dir to:", full_dir, file=sys.stderr)
Expand Down Expand Up @@ -656,7 +656,7 @@ def clean_working_directory():

def getSourceDir(self):
"""Return the full path to the current test."""
return os.path.join(os.environ["LLDB_TEST"], self.mydir)
return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)

def getBuildDirBasename(self):
return self.__class__.__module__ + "." + self.testMethodName
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def getLogBasenameForCurrentTest(self, prefix=None):
<session-dir>/<arch>-<compiler>-<test-file>.<test-class>.<test-method>
"""
dname = os.path.join(os.environ["LLDB_TEST"],
dname = os.path.join(os.environ["LLDB_TEST_SRC"],
os.environ["LLDB_SESSION_DIRNAME"])
if not os.path.isdir(dname):
os.mkdir(dname)
Expand Down
7 changes: 4 additions & 3 deletions lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
Expand Up @@ -61,12 +61,13 @@ def getMake(test_subdir, test_name):

# Construct the base make invocation.
lldb_test = os.environ["LLDB_TEST"]
lldb_test_src = os.environ["LLDB_TEST_SRC"]
lldb_build = os.environ["LLDB_BUILD"]
if not (lldb_test and lldb_build and test_subdir and test_name and
(not os.path.isabs(test_subdir))):
if not (lldb_test and lldb_test_src and lldb_build and test_subdir and
test_name and (not os.path.isabs(test_subdir))):
raise Exception("Could not derive test directories")
build_dir = os.path.join(lldb_build, test_subdir, test_name)
src_dir = os.path.join(lldb_test, test_subdir)
src_dir = os.path.join(lldb_test_src, test_subdir)
# This is a bit of a hack to make inline testcases work.
makefile = os.path.join(src_dir, "Makefile")
if not os.path.isfile(makefile):
Expand Down

0 comments on commit 51821f1

Please sign in to comment.