aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-06-09 23:23:38 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-06-10 00:20:03 +0530
commitc1e9c757ebbe7a26b126ee8cb2106f6f8dffa322 (patch)
tree4e1c2a53bead4fe079a7fc40eff3d2c36293da56
parentb6b3905325884c5fd2a502d09680b5a35564f0df (diff)
downloadmeson-c1e9c757ebbe7a26b126ee8cb2106f6f8dffa322.zip
meson-c1e9c757ebbe7a26b126ee8cb2106f6f8dffa322.tar.gz
meson-c1e9c757ebbe7a26b126ee8cb2106f6f8dffa322.tar.bz2
tests: Increase dependencies coverage a bit more
-rw-r--r--mesonbuild/dependencies/ui.py7
-rwxr-xr-xrun_project_tests.py2
-rwxr-xr-xrun_unittests.py66
-rw-r--r--test cases/frameworks/4 qt/meson.build6
4 files changed, 71 insertions, 10 deletions
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
index 7a66a2d..8537a7e 100644
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -427,7 +427,6 @@ class WxDependency(ExternalDependency):
if WxDependency.wx_found is None:
self.check_wxconfig()
if not WxDependency.wx_found:
- # FIXME: this message could be printed after Dependncy found
mlog.log("Neither wx-config-3.0 nor wx-config found; can't detect dependency")
return
@@ -466,11 +465,11 @@ class WxDependency(ExternalDependency):
if modules not in kwargs:
return []
candidates = kwargs[modules]
- if isinstance(candidates, str):
- return [candidates]
+ if not isinstance(candidates, list):
+ candidates = [candidates]
for c in candidates:
if not isinstance(c, str):
- raise DependencyException('wxwidgets module argument is not a string.')
+ raise DependencyException('wxwidgets module argument is not a string')
return candidates
def check_wxconfig(self):
diff --git a/run_project_tests.py b/run_project_tests.py
index 5a88fa4..71d6c0c 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -434,7 +434,7 @@ def detect_tests_to_run():
('objective c', 'objc', backend not in (Backend.ninja, Backend.xcode) or mesonlib.is_windows() or not have_objc_compiler()),
('fortran', 'fortran', backend is not Backend.ninja or not shutil.which('gfortran')),
('swift', 'swift', backend not in (Backend.ninja, Backend.xcode) or not shutil.which('swiftc')),
- ('python3', 'python3', backend is not Backend.ninja or not shutil.which('python3')),
+ ('python3', 'python3', backend is not Backend.ninja),
]
return [(name, gather_tests('test cases/' + subdir), skip) for name, subdir, skip in all_tests]
diff --git a/run_unittests.py b/run_unittests.py
index 96aefc5..bcb55a2 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -468,7 +468,7 @@ class BasePlatformTests(unittest.TestCase):
self.privatedir = os.path.join(self.builddir, 'meson-private')
if inprocess:
try:
- run_configure_inprocess(self.meson_args + args + extra_args)
+ out = run_configure_inprocess(self.meson_args + args + extra_args)[1]
except:
self._print_meson_log()
raise
@@ -479,12 +479,13 @@ class BasePlatformTests(unittest.TestCase):
mesonbuild.mlog.log_file = None
else:
try:
- self._run(self.meson_command + args + extra_args)
+ out = self._run(self.meson_command + args + extra_args)
except unittest.SkipTest:
raise unittest.SkipTest('Project requested skipping: ' + srcdir)
except:
self._print_meson_log()
raise
+ return out
def build(self, target=None, extra_args=None):
if extra_args is None:
@@ -1230,13 +1231,17 @@ class FailureTests(BasePlatformTests):
super().tearDown()
shutil.rmtree(self.srcdir)
- def assertMesonRaises(self, contents, match, extra_args=None):
+ def assertMesonRaises(self, contents, match, extra_args=None, langs=None):
'''
- Assert that running meson configure on the specified contents raises
- the specified error message.
+ Assert that running meson configure on the specified @contents raises
+ a error message matching regex @match.
'''
+ if langs is None:
+ langs = []
with open(self.mbuild, 'w') as f:
f.write("project('failure test', 'c', 'cpp')\n")
+ for lang in langs:
+ f.write("add_languages('{}', required : false)\n".format(lang))
f.write(contents)
# Force tracebacks so we can detect them properly
os.environ['MESON_FORCE_BACKTRACE'] = '1'
@@ -1244,6 +1249,22 @@ class FailureTests(BasePlatformTests):
# Must run in-process or we'll get a generic CalledProcessError
self.init(self.srcdir, extra_args=extra_args, inprocess=True)
+ def assertMesonOutputs(self, contents, match, extra_args=None, langs=None):
+ '''
+ Assert that running meson configure on the specified @contents outputs
+ something that matches regex @match.
+ '''
+ if langs is None:
+ langs = []
+ with open(self.mbuild, 'w') as f:
+ f.write("project('output test', 'c', 'cpp')\n")
+ for lang in langs:
+ f.write("add_languages('{}', required : false)\n".format(lang))
+ f.write(contents)
+ # Run in-process for speed and consistency with assertMesonRaises
+ out = self.init(self.srcdir, extra_args=extra_args, inprocess=True)
+ self.assertRegex(out, match)
+
def test_dependency(self):
if not shutil.which('pkg-config'):
raise unittest.SkipTest('pkg-config not found')
@@ -1256,6 +1277,41 @@ class FailureTests(BasePlatformTests):
for contents, match in a:
self.assertMesonRaises(contents, match)
+ def test_apple_frameworks_dependency(self):
+ if not is_osx():
+ raise unittest.SkipTest('only run on macOS')
+ self.assertMesonRaises("dependency('appleframeworks')",
+ "requires at least one module")
+
+ def test_sdl2_notfound_dependency(self):
+ # Want to test failure, so skip if available
+ if shutil.which('sdl2-config'):
+ raise unittest.SkipTest('sdl2-config found')
+ self.assertMesonRaises("dependency('sdl2', method : 'sdlconfig')", self.dnf)
+ self.assertMesonRaises("dependency('sdl2', method : 'pkg-config')", self.dnf)
+
+ def test_gnustep_notfound_dependency(self):
+ # Want to test failure, so skip if available
+ if shutil.which('gnustep-config'):
+ raise unittest.SkipTest('gnustep-config found')
+ self.assertMesonRaises("dependency('gnustep')",
+ "(requires a Objc compiler|{})".format(self.dnf),
+ langs = ['objc'])
+
+ def test_wx_notfound_dependency(self):
+ # Want to test failure, so skip if available
+ if shutil.which('wx-config-3.0') or shutil.which('wx-config'):
+ raise unittest.SkipTest('wx-config or wx-config-3.0 found')
+ self.assertMesonRaises("dependency('wxwidgets')", self.dnf)
+ self.assertMesonOutputs("dependency('wxwidgets', required : false)",
+ "nor wx-config found")
+
+ def test_wx_dependency(self):
+ if not shutil.which('wx-config-3.0') and not shutil.which('wx-config'):
+ raise unittest.SkipTest('Neither wx-config nor wx-config-3.0 found')
+ self.assertMesonRaises("dependency('wxwidgets', modules : 1)",
+ "module argument is not a string")
+
def test_llvm_dependency(self):
self.assertMesonRaises("dependency('llvm', modules : 'fail')",
"(required.*fail|{})".format(self.dnf))
diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build
index 468b9c9..d9cab6f 100644
--- a/test cases/frameworks/4 qt/meson.build
+++ b/test cases/frameworks/4 qt/meson.build
@@ -8,16 +8,22 @@ foreach qt : ['qt4', 'qt5']
if qt == 'qt5'
qt_modules += qt5_modules
endif
+
# Test that invalid modules are indeed not found
fakeqtdep = dependency(qt, modules : ['DefinitelyNotFound'], required : false, method : get_option('method'))
if fakeqtdep.found()
error('Invalid qt dep incorrectly found!')
endif
+
# Test that partially-invalid modules are indeed not found
fakeqtdep = dependency(qt, modules : ['Core', 'DefinitelyNotFound'], required : false, method : get_option('method'))
if fakeqtdep.found()
error('Invalid qt dep incorrectly found!')
endif
+
+ # Ensure that the "no-Core-module-specified" code branch is hit
+ nocoredep = dependency(qt, modules : ['Gui'], required : qt == 'qt5', method : get_option('method'))
+
# If qt4 modules are found, test that. qt5 is required.
qtdep = dependency(qt, modules : qt_modules, required : qt == 'qt5', method : get_option('method'))
if qtdep.found()