aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py84
1 files changed, 41 insertions, 43 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 0a13174..23b8f2c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -46,9 +46,9 @@ import mesonbuild.modules.gnome
from mesonbuild.interpreter import Interpreter, ObjectHolder
from mesonbuild.ast import AstInterpreter
from mesonbuild.mesonlib import (
+ BuildDirLock, LibType, MachineChoice, PerMachine, Version,
is_windows, is_osx, is_cygwin, is_dragonflybsd, is_openbsd, is_haiku,
windows_proof_rmtree, python_command, version_compare,
- BuildDirLock, Version, PerMachine, LibType
)
from mesonbuild.environment import detect_ninja
from mesonbuild.mesonlib import MesonException, EnvironmentException
@@ -184,10 +184,7 @@ def skip_if_not_language(lang):
try:
env = get_fake_env()
f = getattr(env, 'detect_{}_compiler'.format(lang))
- if lang in ['cs', 'vala', 'java', 'swift']:
- f()
- else:
- f(False)
+ f(MachineChoice.HOST)
except EnvironmentException:
raise unittest.SkipTest('No {} compiler found.'.format(lang))
return func(*args, **kwargs)
@@ -223,7 +220,7 @@ def skip_if_not_base_option(feature):
@functools.wraps(f)
def wrapped(*args, **kwargs):
env = get_fake_env()
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
if feature not in cc.base_options:
raise unittest.SkipTest(
'{} not available with {}'.format(feature, cc.id))
@@ -344,7 +341,7 @@ class InternalTests(unittest.TestCase):
def test_compiler_args_class(self):
cargsfunc = mesonbuild.compilers.CompilerArgs
- cc = mesonbuild.compilers.CCompiler([], 'fake', False)
+ cc = mesonbuild.compilers.CCompiler([], 'fake', False, MachineChoice.HOST)
# Test that bad initialization fails
self.assertRaises(TypeError, cargsfunc, [])
self.assertRaises(TypeError, cargsfunc, [], [])
@@ -430,7 +427,7 @@ class InternalTests(unittest.TestCase):
def test_compiler_args_class_gnuld(self):
cargsfunc = mesonbuild.compilers.CompilerArgs
## Test --start/end-group
- gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', mesonbuild.compilers.CompilerType.GCC_STANDARD, False)
+ gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', mesonbuild.compilers.CompilerType.GCC_STANDARD, False, MachineChoice.HOST)
## Test that 'direct' append and extend works
l = cargsfunc(gcc, ['-Lfoodir', '-lfoo'])
self.assertEqual(l.to_native(copy=True), ['-Lfoodir', '-Wl,--start-group', '-lfoo', '-Wl,--end-group'])
@@ -764,7 +761,7 @@ class InternalTests(unittest.TestCase):
'{}.dll.a', '{}.lib', '{}.dll'),
'static': msvc_static}}
env = get_fake_env()
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
if is_osx():
self._test_all_naming(cc, env, patterns, 'darwin')
elif is_cygwin():
@@ -807,8 +804,8 @@ class InternalTests(unittest.TestCase):
with tempfile.TemporaryDirectory() as tmpdir:
pkgbin = ExternalProgram('pkg-config', command=['pkg-config'], silent=True)
env = get_fake_env()
- compiler = env.detect_c_compiler(False)
- env.coredata.compilers = {'c': compiler}
+ compiler = env.detect_c_compiler(MachineChoice.HOST)
+ env.coredata.compilers.host = {'c': compiler}
env.coredata.compiler_options.host['c_link_args'] = FakeCompilerOptions()
p1 = Path(tmpdir) / '1'
p2 = Path(tmpdir) / '2'
@@ -989,7 +986,7 @@ class InternalTests(unittest.TestCase):
Ensure that the toolset version returns the correct value for this MSVC
'''
env = get_fake_env()
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
if cc.get_argument_syntax() != 'msvc':
raise unittest.SkipTest('Test only applies to MSVC-like compilers')
toolset_ver = cc.get_toolset_version()
@@ -1045,8 +1042,8 @@ class DataTests(unittest.TestCase):
self.assertIsNotNone(md)
env = get_fake_env()
# FIXME: Support other compilers
- cc = env.detect_c_compiler(False)
- cpp = env.detect_cpp_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
+ cpp = env.detect_cpp_compiler(MachineChoice.HOST)
for comp in (cc, cpp):
for opt in comp.get_options().keys():
self.assertIn(opt, md)
@@ -1606,7 +1603,7 @@ class AllPlatformTests(BasePlatformTests):
def test_clike_get_library_dirs(self):
env = get_fake_env()
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
for d in cc.get_library_dirs(env):
self.assertTrue(os.path.exists(d))
self.assertTrue(os.path.isdir(d))
@@ -1622,7 +1619,7 @@ class AllPlatformTests(BasePlatformTests):
'''
testdir = os.path.join(self.common_test_dir, '3 static')
env = get_fake_env(testdir, self.builddir, self.prefix)
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
static_linker = env.detect_static_linker(cc)
if is_windows():
raise unittest.SkipTest('https://github.com/mesonbuild/meson/issues/1526')
@@ -1977,7 +1974,7 @@ class AllPlatformTests(BasePlatformTests):
for lang, evar in langs:
# Detect with evar and do sanity checks on that
if evar in os.environ:
- ecc = getattr(env, 'detect_{}_compiler'.format(lang))(False)
+ ecc = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST)
self.assertTrue(ecc.version)
elinker = env.detect_static_linker(ecc)
# Pop it so we don't use it for the next detection
@@ -2005,7 +2002,7 @@ class AllPlatformTests(BasePlatformTests):
# Check that we actually used the evalue correctly as the compiler
self.assertEqual(ecc.get_exelist(), shlex.split(evalue))
# Do auto-detection of compiler based on platform, PATH, etc.
- cc = getattr(env, 'detect_{}_compiler'.format(lang))(False)
+ cc = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST)
self.assertTrue(cc.version)
linker = env.detect_static_linker(cc)
# Check compiler type
@@ -2056,7 +2053,7 @@ class AllPlatformTests(BasePlatformTests):
for w in wrappercc:
wrappercc_s += shlex.quote(w) + ' '
os.environ[evar] = wrappercc_s
- wcc = getattr(env, 'detect_{}_compiler'.format(lang))(False)
+ wcc = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST)
# Check static linker too
wrapperlinker = python_command + [wrapper] + linker.get_exelist() + linker.get_always_args()
wrapperlinker_s = ''
@@ -2081,7 +2078,7 @@ class AllPlatformTests(BasePlatformTests):
testdir = os.path.join(self.common_test_dir, '138 c cpp and asm')
# Skip if building with MSVC
env = get_fake_env(testdir, self.builddir, self.prefix)
- if env.detect_c_compiler(False).get_id() == 'msvc':
+ if env.detect_c_compiler(MachineChoice.HOST).get_id() == 'msvc':
raise unittest.SkipTest('MSVC can\'t compile assembly')
self.init(testdir)
commands = {'c-asm': {}, 'cpp-asm': {}, 'cpp-c-asm': {}, 'c-cpp-asm': {}}
@@ -2224,7 +2221,7 @@ class AllPlatformTests(BasePlatformTests):
testdir = os.path.join(self.common_test_dir, '5 linkstatic')
env = get_fake_env(testdir, self.builddir, self.prefix)
- if env.detect_c_compiler(False).get_id() == 'clang' and is_windows():
+ if env.detect_c_compiler(MachineChoice.HOST).get_id() == 'clang' and is_windows():
raise unittest.SkipTest('LTO not (yet) supported by windows clang')
self.init(testdir, extra_args='-Db_lto=true')
@@ -2367,7 +2364,7 @@ int main(int argc, char **argv) {
def detect_prebuild_env(self):
env = get_fake_env()
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
stlinker = env.detect_static_linker(cc)
if mesonbuild.mesonlib.is_windows():
object_suffix = 'obj'
@@ -2852,7 +2849,7 @@ recommended as it is not supported on some platforms''')
testdirlib = os.path.join(testdirbase, 'lib')
extra_args = None
env = get_fake_env(testdirlib, self.builddir, self.prefix)
- if env.detect_c_compiler(False).get_id() not in {'msvc', 'clang-cl', 'intel-cl'}:
+ if env.detect_c_compiler(MachineChoice.HOST).get_id() not in {'msvc', 'clang-cl', 'intel-cl'}:
# static libraries are not linkable with -l with msvc because meson installs them
# as .a files which unix_args_to_native will not know as it expects libraries to use
# .lib as extension. For a DLL the import library is installed as .lib. Thus for msvc
@@ -3821,7 +3818,7 @@ class FailureTests(BasePlatformTests):
raise unittest.SkipTest('wx-config, wx-config-3.0 or wx-config-gtk3 found')
self.assertMesonRaises("dependency('wxwidgets')", self.dnf)
self.assertMesonOutputs("dependency('wxwidgets', required : false)",
- "Dependency .*WxWidgets.* found: .*NO.*")
+ "Run-time dependency .*WxWidgets.* found: .*NO.*")
def test_wx_dependency(self):
if not shutil.which('wx-config-3.0') and not shutil.which('wx-config') and not shutil.which('wx-config-gtk3'):
@@ -3868,8 +3865,8 @@ class FailureTests(BasePlatformTests):
'''
env = get_fake_env()
try:
- env.detect_objc_compiler(False)
- env.detect_objcpp_compiler(False)
+ env.detect_objc_compiler(MachineChoice.HOST)
+ env.detect_objcpp_compiler(MachineChoice.HOST)
except EnvironmentException:
code = "add_languages('objc')\nadd_languages('objcpp')"
self.assertMesonRaises(code, "Unknown compiler")
@@ -4022,7 +4019,7 @@ class WindowsTests(BasePlatformTests):
'''
testdir = os.path.join(self.platform_test_dir, '1 basic')
env = get_fake_env(testdir, self.builddir, self.prefix)
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
if cc.get_argument_syntax() != 'msvc':
raise unittest.SkipTest('Not using MSVC')
# To force people to update this test, and also test
@@ -4035,7 +4032,7 @@ class WindowsTests(BasePlatformTests):
# resource compiler depfile generation is not yet implemented for msvc
env = get_fake_env(testdir, self.builddir, self.prefix)
- depfile_works = env.detect_c_compiler(False).get_id() not in {'msvc', 'clang-cl', 'intel-cl'}
+ depfile_works = env.detect_c_compiler(MachineChoice.HOST).get_id() not in {'msvc', 'clang-cl', 'intel-cl'}
self.init(testdir)
self.build()
@@ -4066,7 +4063,7 @@ class WindowsTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '45 vscpp17')
env = get_fake_env(testdir, self.builddir, self.prefix)
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
if cc.get_argument_syntax() != 'msvc':
raise unittest.SkipTest('Test only applies to MSVC-like compilers')
@@ -4100,7 +4097,7 @@ class DarwinTests(BasePlatformTests):
# Try with bitcode enabled
out = self.init(testdir, extra_args='-Db_bitcode=true')
env = get_fake_env(testdir, self.builddir, self.prefix)
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
if cc.id != 'clang':
raise unittest.SkipTest('Not using Clang on OSX')
# Warning was printed
@@ -4360,10 +4357,10 @@ class LinuxlikeTests(BasePlatformTests):
mesonlog = self.get_meson_log()
if qt4 == 0:
self.assertRegex('\n'.join(mesonlog),
- r'Dependency qt4 \(modules: Core\) found: YES 4.* \(pkg-config\)\n')
+ r'Run-time dependency qt4 \(modules: Core\) found: YES 4.* \(pkg-config\)\n')
if qt5 == 0:
self.assertRegex('\n'.join(mesonlog),
- r'Dependency qt5 \(modules: Core\) found: YES 5.* \(pkg-config\)\n')
+ r'Run-time dependency qt5 \(modules: Core\) found: YES 5.* \(pkg-config\)\n')
@skip_if_not_base_option('b_sanitize')
def test_generate_gir_with_address_sanitizer(self):
@@ -4394,7 +4391,7 @@ class LinuxlikeTests(BasePlatformTests):
# Confirm that the dependency was found with qmake
mesonlog = self.get_meson_log()
self.assertRegex('\n'.join(mesonlog),
- r'Dependency qt5 \(modules: Core\) found: YES .* \((qmake|qmake-qt5)\)\n')
+ r'Run-time dependency qt5 \(modules: Core\) found: YES .* \((qmake|qmake-qt5)\)\n')
def _test_soname_impl(self, libpath, install):
if is_cygwin() or is_osx():
@@ -4519,7 +4516,7 @@ class LinuxlikeTests(BasePlatformTests):
'''
testdir = os.path.join(self.common_test_dir, '1 trivial')
env = get_fake_env(testdir, self.builddir, self.prefix)
- cc = env.detect_c_compiler(False)
+ cc = env.detect_c_compiler(MachineChoice.HOST)
self._test_stds_impl(testdir, cc, 'c')
def test_compiler_cpp_stds(self):
@@ -4529,7 +4526,7 @@ class LinuxlikeTests(BasePlatformTests):
'''
testdir = os.path.join(self.common_test_dir, '2 cpp')
env = get_fake_env(testdir, self.builddir, self.prefix)
- cpp = env.detect_cpp_compiler(False)
+ cpp = env.detect_cpp_compiler(MachineChoice.HOST)
self._test_stds_impl(testdir, cpp, 'cpp')
def test_unity_subproj(self):
@@ -5196,7 +5193,10 @@ endian = 'little'
@skipIfNoPkgconfig
def test_pkg_config_option(self):
testdir = os.path.join(self.unit_test_dir, '55 pkg_config_path option')
- self.init(testdir, extra_args=['-Dpkg_config_path=' + os.path.join(testdir, 'host_extra_path')])
+ self.init(testdir, extra_args=[
+ '-Dbuild.pkg_config_path=' + os.path.join(testdir, 'build_extra_path'),
+ '-Dpkg_config_path=' + os.path.join(testdir, 'host_extra_path'),
+ ])
def test_std_remains(self):
# C_std defined in project options must be in effect also when native compiling.
@@ -5781,17 +5781,16 @@ class NativeFileTests(BasePlatformTests):
f.write('@py -3 {} %*'.format(filename))
return batfile
- def helper_for_compiler(self, lang, cb):
+ def helper_for_compiler(self, lang, cb, for_machine = MachineChoice.HOST):
"""Helper for generating tests for overriding compilers for langaugages
with more than one implementation, such as C, C++, ObjC, ObjC++, and D.
"""
env = get_fake_env()
getter = getattr(env, 'detect_{}_compiler'.format(lang))
- if lang not in ['cs']:
- getter = functools.partial(getter, False)
+ getter = functools.partial(getter, for_machine)
cc = getter()
binary, newid = cb(cc)
- env.binaries.host.binaries[lang] = binary
+ env.binaries[for_machine].binaries[lang] = binary
compiler = getter()
self.assertEqual(compiler.id, newid)
@@ -5956,8 +5955,7 @@ class NativeFileTests(BasePlatformTests):
wrapper = self.helper_create_binary_wrapper(binary, version=version_str)
env = get_fake_env()
getter = getattr(env, 'detect_{}_compiler'.format(lang))
- if lang in ['rust']:
- getter = functools.partial(getter, False)
+ getter = functools.partial(getter, MachineChoice.HOST)
env.binaries.host.binaries[lang] = wrapper
compiler = getter()
self.assertEqual(compiler.version, version)
@@ -5985,7 +5983,7 @@ class NativeFileTests(BasePlatformTests):
'swiftc', version='Swift 1.2345', outfile='stderr')
env = get_fake_env()
env.binaries.host.binaries['swift'] = wrapper
- compiler = env.detect_swift_compiler()
+ compiler = env.detect_swift_compiler(MachineChoice.HOST)
self.assertEqual(compiler.version, '1.2345')
def test_native_file_dirs(self):