diff options
| author | Xavier Claessens <xclaessens@netflix.com> | 2025-09-05 16:06:36 -0400 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-09-06 15:06:40 +0300 |
| commit | 4b7a23c047ef5139f84cf96da37d132fe5fd84bc (patch) | |
| tree | 9f9926eceee899fdc76244f04011be1b02cacdaf | |
| parent | 94300ce8a7e85116c0f2f53a4b57a5bf6ac7e47a (diff) | |
| download | meson-4b7a23c047ef5139f84cf96da37d132fe5fd84bc.tar.gz | |
vsenv: Ignore errors when parsing multiline env values
| -rw-r--r-- | mesonbuild/utils/vsenv.py | 12 | ||||
| -rw-r--r-- | unittests/windowstests.py | 6 |
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) |
