aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-06-09 13:00:20 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-06-09 20:21:01 +0530
commit3a33a8ef49227c2fce1c0c7143e5529b4208d04e (patch)
tree6dfa901a39b608389214ba5a6a8765f9f428fbda /mesonbuild
parented6a5abee853ed5e4d8c1826b17a0dc29843cd6a (diff)
downloadmeson-3a33a8ef49227c2fce1c0c7143e5529b4208d04e.zip
meson-3a33a8ef49227c2fce1c0c7143e5529b4208d04e.tar.gz
meson-3a33a8ef49227c2fce1c0c7143e5529b4208d04e.tar.bz2
unit tests: Add class to generate failing tests
It is not feasible to test all failure modes by creating projects in `test cases/failing` that would be an explosion of files, and that mechanism is too coarse anyway. We have no way to ensure that the expected error is being raised. See FailureTests.test_dependency for an example.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/dependencies/base.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 6fbf8ba..14ec41e 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -59,7 +59,10 @@ class Dependency:
self.compile_args = []
self.link_args = []
self.sources = []
- method = DependencyMethods(kwargs.get('method', 'auto'))
+ method = kwargs.get('method', 'auto')
+ if method not in [e.value for e in DependencyMethods]:
+ raise DependencyException('method {!r} is invalid'.format(method))
+ method = DependencyMethods(method)
# Set the detection method. If the method is set to auto, use any available method.
# If method is set to a specific string, allow only that detection method.
@@ -68,7 +71,7 @@ class Dependency:
elif method in self.get_methods():
self.methods = [method]
else:
- raise MesonException(
+ raise DependencyException(
'Unsupported detection method: {}, allowed methods are {}'.format(
method.value,
mlog.format_list(map(lambda x: x.value, [DependencyMethods.AUTO] + self.get_methods()))))