Skip to content

Commit 4c53d48

Browse files
committed
[lldb/Test] Don't use the env to pass around configuration variables (NFC)
Don't use the environment to pass values to the builder. Use the configuration instead.
1 parent 393ac21 commit 4c53d48

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
count = 1
4343

4444
# The 'arch' and 'compiler' can be specified via command line.
45-
arch = None # Must be initialized after option parsing
46-
compiler = None # Must be initialized after option parsing
45+
arch = None
46+
compiler = None
47+
dsymutil = None
48+
sdkroot = None
4749

4850
# The overriden dwarf verison.
4951
dwarf_version = 0

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ def parseOptionsAndInitTestdirs():
275275
break
276276

277277
if args.dsymutil:
278-
os.environ['DSYMUTIL'] = args.dsymutil
278+
configuration.dsymutil = args.dsymutil
279279
elif platform_system == 'Darwin':
280-
os.environ['DSYMUTIL'] = seven.get_command_output(
280+
configuration.dsymutil = seven.get_command_output(
281281
'xcrun -find -toolchain default dsymutil')
282282

283283
if args.filecheck:
@@ -302,18 +302,18 @@ def parseOptionsAndInitTestdirs():
302302

303303
# Set SDKROOT if we are using an Apple SDK
304304
if platform_system == 'Darwin' and args.apple_sdk:
305-
os.environ['SDKROOT'] = seven.get_command_output(
305+
configuration.sdkroot = seven.get_command_output(
306306
'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
307307
(args.apple_sdk))
308308

309309
if args.arch:
310310
configuration.arch = args.arch
311311
if configuration.arch.startswith(
312312
'arm') and platform_system == 'Darwin' and not args.apple_sdk:
313-
os.environ['SDKROOT'] = seven.get_command_output(
313+
configuration.sdkroot = seven.get_command_output(
314314
'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
315-
if not os.path.exists(os.environ['SDKROOT']):
316-
os.environ['SDKROOT'] = seven.get_command_output(
315+
if not os.path.exists(configuration.sdkroot):
316+
configuration.sdkroot = seven.get_command_output(
317317
'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
318318
else:
319319
configuration.arch = platform_machine
@@ -522,7 +522,7 @@ def setupSysPath():
522522
# Set up the root build directory.
523523
if not configuration.test_build_dir:
524524
raise Exception("test_build_dir is not set")
525-
os.environ["LLDB_BUILD"] = os.path.abspath(configuration.test_build_dir)
525+
configuration.test_build_dir = os.path.abspath(configuration.test_build_dir)
526526

527527
# Set up the LLDB_SRC environment variable, so that the tests can locate
528528
# the LLDB source code.
@@ -1041,8 +1041,7 @@ def run_suite():
10411041

10421042
# Set up the working directory.
10431043
# Note that it's not dotest's job to clean this directory.
1044-
build_dir = configuration.test_build_dir
1045-
lldbutil.mkdir_p(build_dir)
1044+
lldbutil.mkdir_p(configuration.test_build_dir)
10461045

10471046
target_platform = lldb.selected_platform.GetTriple().split('-')[2]
10481047

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def getBuildDirBasename(self):
668668

669669
def getBuildDir(self):
670670
"""Return the full path to the current test."""
671-
return os.path.join(os.environ["LLDB_BUILD"], self.mydir,
671+
return os.path.join(configuration.test_build_dir, self.mydir,
672672
self.getBuildDirBasename())
673673

674674
def getReproducerDir(self):
@@ -682,7 +682,6 @@ def getReproducerDir(self):
682682
def makeBuildDir(self):
683683
"""Create the test-specific working directory, deleting any previous
684684
contents."""
685-
# See also dotest.py which sets up ${LLDB_BUILD}.
686685
bdir = self.getBuildDir()
687686
if os.path.isdir(bdir):
688687
shutil.rmtree(bdir)

lldb/packages/Python/lldbsuite/test/plugins/builder_base.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ def getMake(test_subdir, test_name):
6363
# Construct the base make invocation.
6464
lldb_test = os.environ["LLDB_TEST"]
6565
lldb_test_src = os.environ["LLDB_TEST_SRC"]
66-
lldb_build = os.environ["LLDB_BUILD"]
67-
if not (lldb_test and lldb_test_src and lldb_build and test_subdir and
66+
if not (lldb_test and lldb_test_src and configuration.test_build_dir and test_subdir and
6867
test_name and (not os.path.isabs(test_subdir))):
6968
raise Exception("Could not derive test directories")
70-
build_dir = os.path.join(lldb_build, test_subdir, test_name)
69+
build_dir = os.path.join(configuration.test_build_dir, test_subdir, test_name)
7170
src_dir = os.path.join(lldb_test_src, test_subdir)
7271
# This is a bit of a hack to make inline testcases work.
7372
makefile = os.path.join(src_dir, "Makefile")
@@ -111,18 +110,18 @@ def getDsymutilSpec():
111110
Helper function to return the key-value string to specify the dsymutil
112111
used for the make system.
113112
"""
114-
if "DSYMUTIL" in os.environ:
115-
return "DSYMUTIL={}".format(os.environ["DSYMUTIL"])
116-
return "";
113+
if configuration.dsymutil:
114+
return "DSYMUTIL={}".format(configuration.dsymutil)
115+
return ""
117116

118117
def getSDKRootSpec():
119118
"""
120119
Helper function to return the key-value string to specify the SDK root
121120
used for the make system.
122121
"""
123-
if "SDKROOT" in os.environ:
124-
return "SDKROOT={}".format(os.environ["SDKROOT"])
125-
return "";
122+
if configuration.sdkroot:
123+
return "SDKROOT={}".format(configuration.sdkroot)
124+
return ""
126125

127126
def getModuleCacheSpec():
128127
"""
@@ -132,7 +131,7 @@ def getModuleCacheSpec():
132131
if configuration.clang_module_cache_dir:
133132
return "CLANG_MODULE_CACHE_DIR={}".format(
134133
configuration.clang_module_cache_dir)
135-
return "";
134+
return ""
136135

137136
def getCmdLine(d):
138137
"""

0 commit comments

Comments
 (0)