aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-12-31 12:38:59 -0500
committerXavier Claessens <xclaesse@gmail.com>2019-01-16 11:16:46 -0500
commit66ac6f6b3d24e1b38b2417964f4e127d1d37888e (patch)
treee2670fda7b6f7aace0d98ae875bc85e34867a2de
parent339ee5137b57ef21a0d59b660ea08e33724082a7 (diff)
downloadmeson-66ac6f6b3d24e1b38b2417964f4e127d1d37888e.zip
meson-66ac6f6b3d24e1b38b2417964f4e127d1d37888e.tar.gz
meson-66ac6f6b3d24e1b38b2417964f4e127d1d37888e.tar.bz2
find_external_dependency: Return NotFoundDependency()
The returned not-found object can be from any type because we were returning the first of the failed attempts. It also can happen that we don't have any dependency object in which case we should just return NotFoundDependency() object as well instead of raising an exception. That exception was happening before, but dependency_impl() was calling find_external_dependency() in a try block so it was hidden.
-rw-r--r--mesonbuild/dependencies/base.py7
-rwxr-xr-xrun_unittests.py2
2 files changed, 2 insertions, 7 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index c7556e1..64c5100 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -2100,12 +2100,7 @@ def find_external_dependency(name, env, kwargs):
raise DependencyException('Dependency "%s" not found' % (name) +
(', tried %s' % (tried) if tried else ''))
- # return the last failed dependency object
- if pkgdep:
- return pkgdep[-1]
-
- # this should never happen
- raise DependencyException('Dependency "%s" not found, but no dependency object to return' % (name))
+ return NotFoundDependency(env)
def _build_external_dependency_list(name, env, kwargs):
diff --git a/run_unittests.py b/run_unittests.py
index 4d04254..0743de6 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3471,7 +3471,7 @@ class FailureTests(BasePlatformTests):
code = '''zlib_dep = dependency('zlib', required : false)
zlib_dep.get_configtool_variable('foo')
'''
- self.assertMesonRaises(code, "'zlib' is not a config-tool dependency")
+ self.assertMesonRaises(code, ".* is not a config-tool dependency")
code = '''zlib_dep = dependency('zlib', required : false)
dep = declare_dependency(dependencies : zlib_dep)
dep.get_pkgconfig_variable('foo')