From 66ac6f6b3d24e1b38b2417964f4e127d1d37888e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 31 Dec 2018 12:38:59 -0500 Subject: 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. --- mesonbuild/dependencies/base.py | 7 +------ run_unittests.py | 2 +- 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') -- cgit v1.1