Merge pull request #2236 from trhd/env

Fix a stack trace caused by environment variables in test setups.
pull/2290/head
Jussi Pakkanen 7 years ago committed by GitHub
commit 9361666bd8
  1. 5
      mesonbuild/interpreter.py
  2. 2
      run_unittests.py
  3. 2
      test cases/unit/2 testsetups/meson.build

@ -2335,7 +2335,7 @@ class Interpreter(InterpreterBase):
else: else:
if not isinstance(envlist, list): if not isinstance(envlist, list):
envlist = [envlist] envlist = [envlist]
env = {} env = EnvironmentVariablesHolder()
for e in envlist: for e in envlist:
if '=' not in e: if '=' not in e:
raise InterpreterException('Env var definition must be of type key=val.') raise InterpreterException('Env var definition must be of type key=val.')
@ -2344,7 +2344,8 @@ class Interpreter(InterpreterBase):
val = val.strip() val = val.strip()
if ' ' in k: if ' ' in k:
raise InterpreterException('Env var key must not have spaces in it.') raise InterpreterException('Env var key must not have spaces in it.')
env[k] = val env.add_var(env.held_object.set, [k, val], kwargs)
env = env.held_object
return env return env
def add_test(self, node, args, kwargs, is_base_test): def add_test(self, node, args, kwargs, is_base_test):

@ -813,6 +813,8 @@ class AllPlatformTests(BasePlatformTests):
self._run(self.mtest_command + ['--setup=empty']) self._run(self.mtest_command + ['--setup=empty'])
# Setup with only env works # Setup with only env works
self._run(self.mtest_command + ['--setup=onlyenv']) self._run(self.mtest_command + ['--setup=onlyenv'])
self._run(self.mtest_command + ['--setup=onlyenv2'])
self._run(self.mtest_command + ['--setup=onlyenv3'])
# Setup with only a timeout works # Setup with only a timeout works
self._run(self.mtest_command + ['--setup=timeout']) self._run(self.mtest_command + ['--setup=timeout'])

@ -16,5 +16,7 @@ test('Test buggy', buggy)
add_test_setup('empty') add_test_setup('empty')
add_test_setup('onlyenv', env : env) add_test_setup('onlyenv', env : env)
add_test_setup('onlyenv2', env : 'TEST_ENV=1')
add_test_setup('onlyenv3', env : ['TEST_ENV=1'])
add_test_setup('wrapper', exe_wrapper : [vg, '--error-exitcode=1']) add_test_setup('wrapper', exe_wrapper : [vg, '--error-exitcode=1'])
add_test_setup('timeout', timeout_multiplier : 20) add_test_setup('timeout', timeout_multiplier : 20)

Loading…
Cancel
Save