summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/utils/vsenv.py12
-rw-r--r--unittests/windowstests.py6
2 files changed, 17 insertions, 1 deletions
diff --git a/mesonbuild/utils/vsenv.py b/mesonbuild/utils/vsenv.py
index 5a023794b..87bd3db00 100644
--- a/mesonbuild/utils/vsenv.py
+++ b/mesonbuild/utils/vsenv.py
@@ -113,7 +113,17 @@ def _setup_vsenv(force: bool) -> bool:
# there is no "=", ignore junk data
pass
else:
- os.environ[k] = v
+ try:
+ os.environ[k] = v
+ except ValueError:
+ # FIXME: When a value contains a newline, the output of SET
+ # command is impossible to parse because it makes not escaping.
+ # `VAR="Hello\n=World"` gets split into two lines:
+ # `VAR=Hello` and `=World`. That 2nd line will cause ValueError
+ # exception here. Just ignore for now because variables we do
+ # care won't have multiline values.
+ pass
+
return True
def setup_vsenv(force: bool = False) -> bool:
diff --git a/unittests/windowstests.py b/unittests/windowstests.py
index 7fa4ab286..2cb1407c1 100644
--- a/unittests/windowstests.py
+++ b/unittests/windowstests.py
@@ -466,6 +466,12 @@ class WindowsTests(BasePlatformTests):
# Studio is picked, as a regression test for
# https://github.com/mesonbuild/meson/issues/9774
env['PATH'] = get_path_without_cmd('ninja', env['PATH'])
+ # Add a multiline variable to test that it is handled correctly
+ # with a line that contains only '=' and a line that would result
+ # in an invalid variable name.
+ # see: https://github.com/mesonbuild/meson/pull/13682
+ env['MULTILINE_VAR_WITH_EQUALS'] = 'Foo\r\n=====\r\n'
+ env['MULTILINE_VAR_WITH_INVALID_NAME'] = 'Foo\n%=Bar\n'
testdir = os.path.join(self.common_test_dir, '1 trivial')
out = self.init(testdir, extra_args=['--vsenv'], override_envvars=env)
self.assertIn('Activating VS', out)