[lldb] Use lit.with_system_environment to propagate env variables
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 9 Mar 2021 17:44:32 +0000 (09:44 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 9 Mar 2021 18:44:34 +0000 (10:44 -0800)
Use lit's with_system_environment function to propagate environment
variables to the tests. Include the usual suspects, as well as the
variables already explicitly forwarded.

lldb/test/Shell/lit.cfg.py
lldb/test/Unit/lit.cfg.py

index 83e3ef6..fb9412b 100644 (file)
@@ -38,10 +38,14 @@ config.test_source_root = os.path.dirname(__file__)
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.lldb_obj_root, 'test')
 
-# Propagate reproducer environment vars.
-if 'LLDB_CAPTURE_REPRODUCER' in os.environ:
-  config.environment['LLDB_CAPTURE_REPRODUCER'] = os.environ[
-      'LLDB_CAPTURE_REPRODUCER']
+# Propagate environment vars.
+llvm_config.with_system_environment([
+    'FREEBSD_LEGACY_PLUGIN',
+    'HOME',
+    'LLDB_CAPTURE_REPRODUCER',
+    'TEMP',
+    'TMP',
+])
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the
@@ -136,6 +140,3 @@ if platform.system() == 'NetBSD' and os.geteuid() != 0:
         can_set_dbregs = False
 if can_set_dbregs:
     config.available_features.add('dbregs-set')
-
-# pass control variable through
-llvm_config.with_system_environment('FREEBSD_LEGACY_PLUGIN')
index e53bcd3..69aab2a 100644 (file)
@@ -23,8 +23,15 @@ config.test_exec_root = config.test_source_root
 # it needs to be able to find it at runtime.  This is fine if Python is on your
 # system PATH, but if it's not, then this unit test executable will fail to run.
 # We can solve this by forcing the Python directory onto the system path here.
-llvm_config.with_system_environment('PATH')
-llvm_config.with_environment('PATH', os.path.dirname(sys.executable), append_path=True)
+llvm_config.with_system_environment([
+    'HOME',
+    'PATH',
+    'TEMP',
+    'TMP',
+])
+llvm_config.with_environment('PATH',
+                             os.path.dirname(sys.executable),
+                             append_path=True)
 
 # testFormat: The test format to use to interpret tests.
 config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')