Skip to content

Commit

Permalink
Enable linux-like unit tests on all posix-like platforms
Browse files Browse the repository at this point in the history
Enable linux-like unit tests on all posix-like platforms, not just linux,
skipping tests where appropriate.  This enables these tests for OSX and
Cygwin in CI.

* Allow in-process (as well as out of process) tests to be skipped by
returning MESON_SKIP_TEST

This is needed to allow test_old_gnome_module_codepaths to be skipped when
'test cases/frameworks/7 gnome' is missing it's pre-prequisites

* Skip PIC tests on platforms where it's irrelevant

* Apple Clang reports the XCode version number, not the LLVM version number,
so the check for stdc(|++)17 needs adjusting

* Skip tests that only pertain to ELF or RPATH mechanics when irrelevant

* Skip tests that require valac if missing

* Skip asan test on Cygwin
  • Loading branch information
jon-turney committed Mar 5, 2018
1 parent daaa49c commit ac256cb
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import mesonbuild.modules.gnome
from mesonbuild.interpreter import ObjectHolder
from mesonbuild.mesonlib import (
is_linux, is_windows, is_osx, is_cygwin, is_dragonflybsd,
is_windows, is_osx, is_cygwin, is_dragonflybsd,
windows_proof_rmtree, python_command, meson_command, version_compare,
)
from mesonbuild.environment import Environment, detect_ninja
Expand All @@ -49,6 +49,9 @@


def get_dynamic_section_entry(fname, entry):
if is_cygwin() or is_osx():
raise unittest.SkipTest('Test only applicable to ELF platforms')

try:
raw_out = subprocess.check_output(['readelf', '-d', fname],
universal_newlines=True)
Expand Down Expand Up @@ -526,6 +529,8 @@ def init(self, srcdir, extra_args=None, default_args=True, inprocess=False):
if inprocess:
try:
(returncode, out, err) = run_configure(self.meson_mainfile, self.meson_args + args + extra_args)
if 'MESON_SKIP_TEST' in out:
raise unittest.SkipTest('Project requested skipping.')
if returncode != 0:
self._print_meson_log()
print('Stdout:\n')
Expand Down Expand Up @@ -2135,6 +2140,9 @@ def test_pic(self):
is true and not when it is false. This can't be an ordinary test case
because we need to inspect the compiler database.
'''
if is_cygwin() or is_osx():
raise unittest.SkipTest('PIC not relevant')

testdir = os.path.join(self.common_test_dir, '3 static')
self.init(testdir)
compdb = self.get_compdb()
Expand Down Expand Up @@ -2214,6 +2222,8 @@ def test_vala_c_warnings(self):
database.
https://github.com/mesonbuild/meson/issues/864
'''
if not shutil.which('valac'):
raise unittest.SkipTest('valac not installed.')
testdir = os.path.join(self.vala_test_dir, '5 target glib')
self.init(testdir)
compdb = self.get_compdb()
Expand Down Expand Up @@ -2283,6 +2293,9 @@ def test_qt5dependency_qmake_detection(self):
self.assertTrue(msg in mesonlog or msg2 in mesonlog)

def _test_soname_impl(self, libpath, install):
if is_cygwin() or is_osx:
raise unittest.SkipTest('Test only applicable to ELF and linuxlike sonames')

testdir = os.path.join(self.unit_test_dir, '1 soname')
self.init(testdir)
self.build()
Expand Down Expand Up @@ -2356,7 +2369,9 @@ def _test_stds_impl(self, testdir, compiler, p):
# Check that all the listed -std=xxx options for this compiler work
# just fine when used
for v in compiler.get_options()[lang_std].choices:
if compiler.get_id() == 'clang' and version_compare(compiler.version, '<5.0.0') and '17' in v:
if (compiler.get_id() == 'clang' and '17' in v and
(version_compare(compiler.version, '<5.0.0') or
(compiler.clang_type == mesonbuild.compilers.CLANG_OSX and version_compare(compiler.version, '<9.2')))):
continue
std_opt = '{}={}'.format(lang_std, v)
self.init(testdir, ['-D' + std_opt])
Expand Down Expand Up @@ -2489,6 +2504,9 @@ def test_cpp_std_override(self):
self.assertNotIn('-Werror', c03_comp)

def test_run_installed(self):
if is_cygwin() or is_osx():
raise unittest.SkipTest('LD_LIBRARY_PATH and RPATH not applicable')

testdir = os.path.join(self.unit_test_dir, '7 run installed')
self.init(testdir)
self.build()
Expand Down Expand Up @@ -2558,6 +2576,8 @@ def test_introspect_dependencies(self):
self.assertTrue(gobject_found)

def test_build_rpath(self):
if is_cygwin():
raise unittest.SkipTest('Windows PE/COFF binaries do not use RPATH')
testdir = os.path.join(self.unit_test_dir, '11 build_rpath')
self.init(testdir)
self.build()
Expand All @@ -2575,6 +2595,9 @@ def test_build_rpath(self):
self.assertEqual(install_rpath, 'baz')

def test_pch_with_address_sanitizer(self):
if is_cygwin():
raise unittest.SkipTest('asan not available on Cygwin')

testdir = os.path.join(self.common_test_dir, '13 pch')
self.init(testdir, ['-Db_sanitize=address'])
self.build()
Expand Down Expand Up @@ -2627,6 +2650,9 @@ def test_vala_generated_source_buildir_inside_source_tree(self):
Test that valac outputs generated C files in the expected location when
the builddir is a subdir of the source tree.
'''
if not shutil.which('valac'):
raise unittest.SkipTest('valac not installed.')

testdir = os.path.join(self.vala_test_dir, '8 generated sources')
newdir = os.path.join(self.builddir, 'srctree')
shutil.copytree(testdir, newdir)
Expand Down Expand Up @@ -2750,7 +2776,7 @@ def unset_envs():
if __name__ == '__main__':
unset_envs()
cases = ['InternalTests', 'AllPlatformTests', 'FailureTests']
if is_linux():
if not is_windows():
cases += ['LinuxlikeTests']
if should_run_linux_cross_tests():
cases += ['LinuxArmCrossCompileTests']
Expand Down

0 comments on commit ac256cb

Please sign in to comment.