|
Ondrej Holy |
6a43e5 |
From 96e8e019303abe5626e737867e1249ab6eb53dff Mon Sep 17 00:00:00 2001
|
|
Ondrej Holy |
6a43e5 |
From: Xavier Claessens <xavier.claessens@collabora.com>
|
|
Ondrej Holy |
6a43e5 |
Date: Wed, 12 May 2021 16:16:41 -0400
|
|
Ondrej Holy |
6a43e5 |
Subject: [PATCH] interpreter: flatten environment() initial values
|
|
Ondrej Holy |
6a43e5 |
|
|
Ondrej Holy |
6a43e5 |
Turns out listify() flattens by default, but stringlistify() cannot
|
|
Ondrej Holy |
6a43e5 |
flatten... How do I realize this only now?
|
|
Ondrej Holy |
6a43e5 |
|
|
Ondrej Holy |
6a43e5 |
Fixes: #8727
|
|
Ondrej Holy |
6a43e5 |
---
|
|
Ondrej Holy |
6a43e5 |
mesonbuild/interpreter/interpreterobjects.py | 4 +++-
|
|
Ondrej Holy |
6a43e5 |
test cases/common/41 test args/meson.build | 2 +-
|
|
Ondrej Holy |
6a43e5 |
test cases/common/41 test args/tester.py | 4 ++++
|
|
Ondrej Holy |
6a43e5 |
3 files changed, 8 insertions(+), 2 deletions(-)
|
|
Ondrej Holy |
6a43e5 |
|
|
Ondrej Holy |
6a43e5 |
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
|
|
Ondrej Holy |
6a43e5 |
index 7d43752cfcf..10e681aeb46 100644
|
|
Ondrej Holy |
6a43e5 |
--- a/mesonbuild/interpreter/interpreterobjects.py
|
|
Ondrej Holy |
6a43e5 |
+++ b/mesonbuild/interpreter/interpreterobjects.py
|
|
Ondrej Holy |
6a43e5 |
@@ -165,7 +165,9 @@ def __init__(self, initial_values=None, subproject: str = ''):
|
|
Ondrej Holy |
6a43e5 |
for k, v in initial_values.items():
|
|
Ondrej Holy |
6a43e5 |
self.set_method([k, v], {})
|
|
Ondrej Holy |
6a43e5 |
elif initial_values is not None:
|
|
Ondrej Holy |
6a43e5 |
- for e in mesonlib.stringlistify(initial_values):
|
|
Ondrej Holy |
6a43e5 |
+ for e in mesonlib.listify(initial_values):
|
|
Ondrej Holy |
6a43e5 |
+ if not isinstance(e, str):
|
|
Ondrej Holy |
6a43e5 |
+ raise InterpreterException('Env var definition must be a list of strings.')
|
|
Ondrej Holy |
6a43e5 |
if '=' not in e:
|
|
Ondrej Holy |
6a43e5 |
raise InterpreterException('Env var definition must be of type key=val.')
|
|
Ondrej Holy |
6a43e5 |
(k, val) = e.split('=', 1)
|
|
Ondrej Holy |
6a43e5 |
diff --git a/test cases/common/41 test args/meson.build b/test cases/common/41 test args/meson.build
|
|
Ondrej Holy |
6a43e5 |
index 81d34915abe..b21f1ad00b1 100644
|
|
Ondrej Holy |
6a43e5 |
--- a/test cases/common/41 test args/meson.build
|
|
Ondrej Holy |
6a43e5 |
+++ b/test cases/common/41 test args/meson.build
|
|
Ondrej Holy |
6a43e5 |
@@ -23,7 +23,7 @@ test('environment variables 2', e3, env : env2)
|
|
Ondrej Holy |
6a43e5 |
env_array = ['MESONTESTING=picklerror']
|
|
Ondrej Holy |
6a43e5 |
testfile = files('testfile.txt')
|
|
Ondrej Holy |
6a43e5 |
testerpy = find_program('tester.py')
|
|
Ondrej Holy |
6a43e5 |
-test('file arg', testerpy, args : testfile, env : env_array)
|
|
Ondrej Holy |
6a43e5 |
+test('file arg', testerpy, args : testfile, env : [env_array, 'TEST_LIST_FLATTENING=1'])
|
|
Ondrej Holy |
6a43e5 |
|
|
Ondrej Holy |
6a43e5 |
copy = find_program('copyfile.py')
|
|
Ondrej Holy |
6a43e5 |
tester = executable('tester', 'tester.c')
|
|
Ondrej Holy |
6a43e5 |
diff --git a/test cases/common/41 test args/tester.py b/test cases/common/41 test args/tester.py
|
|
Ondrej Holy |
6a43e5 |
index 0b4010ab909..b5884cc61a2 100755
|
|
Ondrej Holy |
6a43e5 |
--- a/test cases/common/41 test args/tester.py
|
|
Ondrej Holy |
6a43e5 |
+++ b/test cases/common/41 test args/tester.py
|
|
Ondrej Holy |
6a43e5 |
@@ -1,6 +1,10 @@
|
|
Ondrej Holy |
6a43e5 |
#!/usr/bin/env python3
|
|
Ondrej Holy |
6a43e5 |
|
|
Ondrej Holy |
6a43e5 |
import sys
|
|
Ondrej Holy |
6a43e5 |
+import os
|
|
Ondrej Holy |
6a43e5 |
+
|
|
Ondrej Holy |
6a43e5 |
+assert os.environ['MESONTESTING'] == 'picklerror'
|
|
Ondrej Holy |
6a43e5 |
+assert os.environ['TEST_LIST_FLATTENING'] == '1'
|
|
Ondrej Holy |
6a43e5 |
|
|
Ondrej Holy |
6a43e5 |
with open(sys.argv[1]) as f:
|
|
Ondrej Holy |
6a43e5 |
if f.read() != 'contents\n':
|