Skip to content

Commit 3bbd176

Browse files
committed
[tests] Add mechanism to override lit environment
lit runs its tests with only the environment variables set up by its configuration, which is great for repeatability, but sometimes you want to allow a few controlled leaks. With this change, you can now specify “--param copy_env=FOO:BAR:BAZ” to cause the environment variables FOO, BAR, and BAZ to be visible in lit tests during that run.
1 parent b32e82c commit 3bbd176

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/lit.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,5 +1665,12 @@ if platform.system() == 'Linux':
16651665
config.available_features.add("LinuxDistribution=" + distributor + '-' + release)
16661666
lit_config.note('Running tests on %s-%s' % (distributor, release))
16671667

1668+
# Copy environment variables specified in --param copy_env=..., overriding
1669+
# anything computed here. It's assumed that the person setting this knows what
1670+
# they're doing.
1671+
copy_env = lit_config.params.get('copy_env', None)
1672+
if copy_env is not None:
1673+
for key in copy_env.split(':'):
1674+
config.environment[key] = os.environ[key]
16681675

16691676
lit_config.note("Available features: " + ", ".join(sorted(config.available_features)))

0 commit comments

Comments
 (0)