From 4c53d4801cbbb1b573e4ef758f93ead12e1f59a2 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 2 Jun 2020 16:49:03 -0700 Subject: [PATCH] [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. --- lldb/packages/Python/lldbsuite/test/configuration.py | 6 ++++-- lldb/packages/Python/lldbsuite/test/dotest.py | 17 ++++++++--------- lldb/packages/Python/lldbsuite/test/lldbtest.py | 3 +-- .../Python/lldbsuite/test/plugins/builder_base.py | 19 +++++++++---------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 0439c4e..f051522 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -42,8 +42,10 @@ lldb_framework_path = None count = 1 # The 'arch' and 'compiler' can be specified via command line. -arch = None # Must be initialized after option parsing -compiler = None # Must be initialized after option parsing +arch = None +compiler = None +dsymutil = None +sdkroot = None # The overriden dwarf verison. dwarf_version = 0 diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 54e5d4b..80edad8 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -275,9 +275,9 @@ def parseOptionsAndInitTestdirs(): break if args.dsymutil: - os.environ['DSYMUTIL'] = args.dsymutil + configuration.dsymutil = args.dsymutil elif platform_system == 'Darwin': - os.environ['DSYMUTIL'] = seven.get_command_output( + configuration.dsymutil = seven.get_command_output( 'xcrun -find -toolchain default dsymutil') if args.filecheck: @@ -302,7 +302,7 @@ def parseOptionsAndInitTestdirs(): # Set SDKROOT if we are using an Apple SDK if platform_system == 'Darwin' and args.apple_sdk: - os.environ['SDKROOT'] = seven.get_command_output( + configuration.sdkroot = seven.get_command_output( 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (args.apple_sdk)) @@ -310,10 +310,10 @@ def parseOptionsAndInitTestdirs(): configuration.arch = args.arch if configuration.arch.startswith( 'arm') and platform_system == 'Darwin' and not args.apple_sdk: - os.environ['SDKROOT'] = seven.get_command_output( + configuration.sdkroot = seven.get_command_output( 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null') - if not os.path.exists(os.environ['SDKROOT']): - os.environ['SDKROOT'] = seven.get_command_output( + if not os.path.exists(configuration.sdkroot): + configuration.sdkroot = seven.get_command_output( 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null') else: configuration.arch = platform_machine @@ -522,7 +522,7 @@ def setupSysPath(): # Set up the root build directory. 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) + configuration.test_build_dir = os.path.abspath(configuration.test_build_dir) # Set up the LLDB_SRC environment variable, so that the tests can locate # the LLDB source code. @@ -1041,8 +1041,7 @@ def run_suite(): # Set up the working directory. # Note that it's not dotest's job to clean this directory. - build_dir = configuration.test_build_dir - lldbutil.mkdir_p(build_dir) + lldbutil.mkdir_p(configuration.test_build_dir) target_platform = lldb.selected_platform.GetTriple().split('-')[2] diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 04ba7ea..0a640d2 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -668,7 +668,7 @@ class Base(unittest2.TestCase): def getBuildDir(self): """Return the full path to the current test.""" - return os.path.join(os.environ["LLDB_BUILD"], self.mydir, + return os.path.join(configuration.test_build_dir, self.mydir, self.getBuildDirBasename()) def getReproducerDir(self): @@ -682,7 +682,6 @@ class Base(unittest2.TestCase): def makeBuildDir(self): """Create the test-specific working directory, deleting any previous contents.""" - # See also dotest.py which sets up ${LLDB_BUILD}. bdir = self.getBuildDir() if os.path.isdir(bdir): shutil.rmtree(bdir) diff --git a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py index 3c19839..e54431e 100644 --- a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py +++ b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py @@ -63,11 +63,10 @@ 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_test_src and lldb_build and test_subdir and + if not (lldb_test and lldb_test_src and configuration.test_build_dir 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) + build_dir = os.path.join(configuration.test_build_dir, test_subdir, test_name) 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") @@ -111,18 +110,18 @@ def getDsymutilSpec(): Helper function to return the key-value string to specify the dsymutil used for the make system. """ - if "DSYMUTIL" in os.environ: - return "DSYMUTIL={}".format(os.environ["DSYMUTIL"]) - return ""; + if configuration.dsymutil: + return "DSYMUTIL={}".format(configuration.dsymutil) + return "" def getSDKRootSpec(): """ Helper function to return the key-value string to specify the SDK root used for the make system. """ - if "SDKROOT" in os.environ: - return "SDKROOT={}".format(os.environ["SDKROOT"]) - return ""; + if configuration.sdkroot: + return "SDKROOT={}".format(configuration.sdkroot) + return "" def getModuleCacheSpec(): """ @@ -132,7 +131,7 @@ def getModuleCacheSpec(): if configuration.clang_module_cache_dir: return "CLANG_MODULE_CACHE_DIR={}".format( configuration.clang_module_cache_dir) - return ""; + return "" def getCmdLine(d): """ -- 2.7.4