From faf79f4539841cbf89fe8d53cf35aa91fd8273c9 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sun, 16 Jan 2022 16:01:33 +0530 Subject: Add a test for the --vsenv meson setup option The tests and the unittests both unconditionally call setup_vsenv() because all tests are run using the backend commands directly: ninja, msbuild, etc. There's no way to undo this vs env setup, so the only way to test that --vsenv works is by: 1. Removing all paths in PATH that provide ninja 2. Changing setup_vsenv(force=True) to forcibly set-up a new vsenv when MESON_FORCE_VSENV_FOR_UNITTEST is set 3. Mock-patching build_command, test_command, install_command to use `meson` instead of `ninja` 4. Asserting that 'Activating VS' is in the output for all commands 5. Ensure that compilation works because ninja is picked up from the vs env. I manually checked that this test actually does fail when the previous commit is reverted. --- unittests/baseplatformtests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'unittests/baseplatformtests.py') diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py index 2f8064e..cfc78ce 100644 --- a/unittests/baseplatformtests.py +++ b/unittests/baseplatformtests.py @@ -249,10 +249,10 @@ class BasePlatformTests(TestCase): def run_tests(self, *, inprocess=False, override_envvars=None): if not inprocess: - self._run(self.test_command, workdir=self.builddir, override_envvars=override_envvars) + return self._run(self.test_command, workdir=self.builddir, override_envvars=override_envvars) else: with mock.patch.dict(os.environ, override_envvars): - run_mtest_inprocess(['-C', self.builddir]) + return run_mtest_inprocess(['-C', self.builddir])[1] def install(self, *, use_destdir=True, override_envvars=None): if self.backend is not Backend.ninja: @@ -263,7 +263,7 @@ class BasePlatformTests(TestCase): override_envvars = destdir else: override_envvars.update(destdir) - self._run(self.install_command, workdir=self.builddir, override_envvars=override_envvars) + return self._run(self.install_command, workdir=self.builddir, override_envvars=override_envvars) def uninstall(self, *, override_envvars=None): self._run(self.uninstall_command, workdir=self.builddir, override_envvars=override_envvars) -- cgit v1.1