aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-01-13 16:42:09 -0500
committerEli Schwartz <eschwartz93@gmail.com>2023-01-18 11:06:48 -0500
commit1a0eff005483b63259e365bd4d51be7c4bd3b729 (patch)
tree7b64867bb7ac42f9a0b441e4c375b4113eeea47b /unittests
parent5a4168c410fea6fce8867ec60e0ba481d7c61866 (diff)
downloadmeson-1a0eff005483b63259e365bd4d51be7c4bd3b729.zip
meson-1a0eff005483b63259e365bd4d51be7c4bd3b729.tar.gz
meson-1a0eff005483b63259e365bd4d51be7c4bd3b729.tar.bz2
devenv: Allow dumping into file and select a format
It is often more useful to generate shell script than dumping to stdout. It is also important to be able to select the shell format. Formats currently implemented: - sh: Basic VAR=prepend_value:$VAR - export: Same as 'sh', but also export VAR - vscode: Same as 'sh', but without substitutions because they don't seems to work. To be used in launch.json's envFile.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/allplatformstests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 351f79d..a98cd94 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -3973,6 +3973,33 @@ class AllPlatformTests(BasePlatformTests):
self._run(cmd + python_command + [script])
self.assertEqual('This is text.', self._run(cmd + [app]).strip())
+ cmd = self.meson_command + ['devenv', '-C', self.builddir, '--dump']
+ o = self._run(cmd)
+ expected = os.pathsep.join(['/prefix', '$TEST_C', '/suffix'])
+ self.assertIn(f'TEST_C="{expected}"', o)
+ self.assertIn('export TEST_C', o)
+
+ cmd = self.meson_command + ['devenv', '-C', self.builddir, '--dump', '--dump-format', 'sh']
+ o = self._run(cmd)
+ expected = os.pathsep.join(['/prefix', '$TEST_C', '/suffix'])
+ self.assertIn(f'TEST_C="{expected}"', o)
+ self.assertNotIn('export', o)
+
+ cmd = self.meson_command + ['devenv', '-C', self.builddir, '--dump', '--dump-format', 'vscode']
+ o = self._run(cmd)
+ expected = os.pathsep.join(['/prefix', '/suffix'])
+ self.assertIn(f'TEST_C="{expected}"', o)
+ self.assertNotIn('export', o)
+
+ fname = os.path.join(self.builddir, 'dump.env')
+ cmd = self.meson_command + ['devenv', '-C', self.builddir, '--dump', fname]
+ o = self._run(cmd)
+ self.assertEqual(o, '')
+ o = Path(fname).read_text()
+ expected = os.pathsep.join(['/prefix', '$TEST_C', '/suffix'])
+ self.assertIn(f'TEST_C="{expected}"', o)
+ self.assertIn('export TEST_C', o)
+
def test_clang_format_check(self):
if self.backend is not Backend.ninja:
raise SkipTest(f'Skipping clang-format tests with {self.backend.name} backend')