unit tests: Run on all backends, not just Ninja
This commit is contained in:
parent
7e4a67c790
commit
a331bf1162
23
run_tests.py
23
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')
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue