[lldb/Test] Don't use the env to pass around configuration variables (NFC)
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 2 Jun 2020 23:08:11 +0000 (16:08 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 2 Jun 2020 23:11:32 +0000 (16:11 -0700)
Don't use the environment to pass values to the builder that are present
in the dotest configuration module. A subsequent patch will pass the
remaining values through the configuration instead of the environment.

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

index c4e4b61..54e5d4b 100644 (file)
@@ -462,8 +462,6 @@ def parseOptionsAndInitTestdirs():
         configuration.clang_module_cache_dir = os.path.join(
             configuration.test_build_dir, 'module-cache-clang')
 
-    os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir
-
     if args.lldb_libs_dir:
         configuration.lldb_libs_dir = args.lldb_libs_dir
 
@@ -522,7 +520,6 @@ def setupSysPath():
     os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
     # Set up the root build directory.
-    builddir = configuration.test_build_dir
     if not configuration.test_build_dir:
         raise Exception("test_build_dir is not set")
     os.environ["LLDB_BUILD"] = os.path.abspath(configuration.test_build_dir)
@@ -1096,8 +1093,6 @@ def run_suite():
         print("compiler=%s" % configuration.compiler)
 
     # Iterating over all possible architecture and compiler combinations.
-    os.environ["ARCH"] = configuration.arch
-    os.environ["CC"] = configuration.compiler
     configString = "arch=%s compiler=%s" % (configuration.arch,
                                             configuration.compiler)
 
index 0f30f70..3c19839 100644 (file)
@@ -21,17 +21,18 @@ import sys
 # Our imports
 import lldbsuite.test.lldbtest as lldbtest
 import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import configuration
 from lldbsuite.test_event import build_exception
 
 
 def getArchitecture():
     """Returns the architecture in effect the test suite is running with."""
-    return os.environ["ARCH"] if "ARCH" in os.environ else ""
+    return configuration.arch if configuration.arch else ""
 
 
 def getCompiler():
     """Returns the compiler in effect the test suite is running with."""
-    compiler = os.environ.get("CC", "clang")
+    compiler = configuration.compiler if configuration.compiler else "clang"
     compiler = lldbutil.which(compiler)
     return os.path.realpath(compiler)
 
@@ -86,8 +87,8 @@ def getArchSpec(architecture):
     used for the make system.
     """
     arch = architecture if architecture else None
-    if not arch and "ARCH" in os.environ:
-        arch = os.environ["ARCH"]
+    if not arch and configuration.arch:
+        arch = configuration.arch
 
     return ("ARCH=" + arch) if arch else ""
 
@@ -98,8 +99,8 @@ def getCCSpec(compiler):
     used for the make system.
     """
     cc = compiler if compiler else None
-    if not cc and "CC" in os.environ:
-        cc = os.environ["CC"]
+    if not cc and configuration.compiler:
+        cc = configuration.compiler
     if cc:
         return "CC=\"%s\"" % cc
     else:
@@ -128,9 +129,9 @@ def getModuleCacheSpec():
     Helper function to return the key-value string to specify the clang
     module cache used for the make system.
     """
-    if "CLANG_MODULE_CACHE_DIR" in os.environ:
+    if configuration.clang_module_cache_dir:
         return "CLANG_MODULE_CACHE_DIR={}".format(
-            os.environ["CLANG_MODULE_CACHE_DIR"])
+            configuration.clang_module_cache_dir)
     return "";
 
 def getCmdLine(d):