diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-04-06 08:16:08 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-04-09 23:11:05 +0530 |
commit | a331bf1162030c9aedc3b9ad33350fe28b7c35db (patch) | |
tree | 23ec062a0601a8d7e8161e5e2b5fa625bbab7cd7 | |
parent | 7e4a67c7906ef736870650031f332a17be6673e6 (diff) | |
download | meson-a331bf1162030c9aedc3b9ad33350fe28b7c35db.zip meson-a331bf1162030c9aedc3b9ad33350fe28b7c35db.tar.gz meson-a331bf1162030c9aedc3b9ad33350fe28b7c35db.tar.bz2 |
unit tests: Run on all backends, not just Ninja
-rwxr-xr-x | run_tests.py | 23 | ||||
-rwxr-xr-x | run_unittests.py | 21 |
2 files changed, 28 insertions, 16 deletions
diff --git a/run_tests.py b/run_tests.py index ebccaa6..7ea633e 100755 --- a/run_tests.py +++ b/run_tests.py @@ -40,14 +40,17 @@ def get_backend_args_for_dir(backend, builddir): return [os.path.split(sln_name)[-1]] return [] -def get_build_target_args(backend, target): +def get_builddir_target_args(backend, builddir, target): + dir_args = get_backend_args_for_dir(backend, builddir) if target is None: - return [] + return dir_args if backend.startswith('vs'): - return ['/target:' + target] - if backend == 'xcode': - return ['-target', target] - return [target] + target_args = ['/target:' + target] + elif backend == 'xcode': + target_args = ['-target', target] + else: + target_args = [target] + return target_args + dir_args def get_backend_commands(backend, debug=False): install_cmd = [] @@ -108,10 +111,10 @@ if __name__ == '__main__': units += ['LinuxlikeTests'] elif mesonlib.is_windows(): units += ['WindowsTests'] - # Unit tests always use the Ninja backend, so just skip them if we're - # testing the VS backend - if backend is Backend.ninja: - returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'] + units) + # Can't pass arguments to unit tests, so set the backend to use in the environment + env = os.environ.copy() + env['MESON_UNIT_TEST_BACKEND'] = backend.name + returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'] + units, env=env) # Ubuntu packages do not have a binary without -6 suffix. if shutil.which('arm-linux-gnueabihf-gcc-6') and not platform.machine().startswith('arm'): print('Running cross compilation tests.\n') diff --git a/run_unittests.py b/run_unittests.py index 7480aad..f7ac140 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -29,7 +29,7 @@ from mesonbuild.environment import Environment from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram from run_tests import exe_suffix, get_fake_options, FakeEnvironment -from run_tests import get_build_target_args, get_backend_commands +from run_tests import get_builddir_target_args, get_backend_commands def get_soname(fname): @@ -330,12 +330,15 @@ class BasePlatformTests(unittest.TestCase): self.prefix = '/usr' self.libdir = os.path.join(self.prefix, 'lib') self.installdir = os.path.join(self.builddir, 'install') - self.meson_command = [sys.executable, os.path.join(src_root, 'meson.py')] + # Get the backend + # FIXME: Extract this from argv? + self.backend = os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja') + self.meson_command = [sys.executable, os.path.join(src_root, 'meson.py'), + '--backend=' + self.backend] self.mconf_command = [sys.executable, os.path.join(src_root, 'mesonconf.py')] self.mintro_command = [sys.executable, os.path.join(src_root, 'mesonintrospect.py')] self.mtest_command = [sys.executable, os.path.join(src_root, 'mesontest.py'), '-C', self.builddir] - # Backend-specific commands - self.backend = os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja') + # Backend-specific build commands self.build_command, self.clean_command, self.test_command, self.install_command, \ self.uninstall_command = get_backend_commands(self.backend) # Test directories @@ -389,8 +392,14 @@ class BasePlatformTests(unittest.TestCase): def build(self, target=None, extra_args=None): if extra_args is None: extra_args = [] - target = get_build_target_args(self.backend, target) - self._run(self.build_command + target + extra_args, workdir=self.builddir) + # Add arguments for building the target (if specified), + # and using the build dir (if required, with VS) + args = get_builddir_target_args(self.backend, self.builddir, target) + self._run(self.build_command + args + extra_args, workdir=self.builddir) + + def clean(self): + dir_args = get_builddir_target_args(self.backend, self.builddir, None) + self._run(self.clean_command + dir_args, workdir=self.builddir) def run_tests(self): self._run(self.test_command, workdir=self.builddir) |