From 2fdedc4d0fc73c509669bf9f89863017e0f0989b Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 19 Dec 2018 20:56:07 -0500 Subject: Add meson.override_dependency() Similar to meson.override_find_program() but overrides the result of the dependency() function. Also ensure that dependency() always returns the same result when looking for the same dependency, this fixes cases where parts of the project could be using a system library and other parts use the library provided by a subproject. --- run_unittests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index 658da37..ee5a713 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3980,7 +3980,7 @@ recommended as it is not supported on some platforms''') { 'descriptive_name': 'sub', 'name': 'sub', - 'version': 'undefined' + 'version': '1.0' } ] } @@ -4555,7 +4555,7 @@ class FailureTests(BasePlatformTests): raise unittest.SkipTest('zlib not found with pkg-config') a = (("dependency('zlib', method : 'fail')", "'fail' is invalid"), ("dependency('zlib', static : '1')", "[Ss]tatic.*boolean"), - ("dependency('zlib', version : 1)", "[Vv]ersion.*string or list"), + ("dependency('zlib', version : 1)", "Item must be a list or one of "), ("dependency('zlib', required : 1)", "[Rr]equired.*boolean"), ("dependency('zlib', method : 1)", "[Mm]ethod.*string"), ("dependency('zlibfail')", self.dnf),) -- cgit v1.1 From 943e9368f7198b6c2b069ad024ee798037f3c35e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 25 Nov 2019 14:29:05 -0500 Subject: Simplify dependency() fallback Now that subprojects can override the dependency name, there is no need to provide a variable name for the fallback any more. --- run_unittests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index ee5a713..8479e34 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3981,10 +3981,16 @@ recommended as it is not supported on some platforms''') 'descriptive_name': 'sub', 'name': 'sub', 'version': '1.0' - } + }, + { + 'descriptive_name': 'sub-novar', + 'name': 'sub_novar', + 'version': '1.0', + }, ] } - self.assertDictEqual(res, expected) + res['subprojects'] = sorted(res['subprojects'], key=lambda i: i['name']) + self.assertDictEqual(expected, res) def test_introspection_target_subproject(self): testdir = os.path.join(self.common_test_dir, '45 subproject') -- cgit v1.1 From d40c26e5fd642724155da813a4f2de0c05b52449 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 8 Dec 2019 17:24:49 -0500 Subject: override_dependency: Add failure tests --- run_unittests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index 8479e34..9ebece6 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4778,6 +4778,17 @@ class FailureTests(BasePlatformTests): self.assertMesonOutputs("warning('Array:', ['a', 'b'])", r"WARNING:.* Array: \['a', 'b'\]") + def test_override_dependency_twice(self): + self.assertMesonRaises("meson.override_dependency('foo', declare_dependency())\n" + + "meson.override_dependency('foo', declare_dependency())", + """Tried to override dependency 'foo' which has already been resolved or overridden""") + + @unittest.skipIf(is_windows(), 'zlib is not available on Windows') + def test_override_resolved_dependency(self): + self.assertMesonRaises("dependency('zlib')\n" + + "meson.override_dependency('zlib', declare_dependency())", + """Tried to override dependency 'zlib' which has already been resolved or overridden""") + @unittest.skipUnless(is_windows() or is_cygwin(), "requires Windows (or Windows via Cygwin)") class WindowsTests(BasePlatformTests): ''' -- cgit v1.1