diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-10-12 16:23:57 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-10-12 22:02:57 +0530 |
commit | f3a1e00351119a494c1d3b9ebc8e4194f0ebc52d (patch) | |
tree | 953642d01c5c41fce124f514e708e74982058904 | |
parent | 253fcb37af3f6d853d431d06aaf75c09292342b6 (diff) | |
download | meson-nirbheek/fix-deprecation-notice.tar.gz |
Only print deprecation notice when target version is newnirbheek/fix-deprecation-notice
If a feature is deprecated in version 0.48, don't print the
deprecation notice if the target version is older than that.
We don't really provide a way to disable deprecation notices, and
we shouldn't spam people with messages that they can't do anything
about.
-rw-r--r-- | mesonbuild/interpreterbase.py | 24 | ||||
-rwxr-xr-x | run_unittests.py | 13 |
2 files changed, 33 insertions, 4 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index c0064ab0d..50cac916f 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -185,15 +185,24 @@ class FeatureCheckBase: return '' return mesonlib.project_meson_versions[subproject] + def feature_used_correctly(self, target_version): + ''' + True if the target version is newer than the version in which the + feature was added + ''' + if mesonlib.version_compare_condition_with_min(target_version, self.feature_version): + return True + return False + def use(self, subproject): tv = self.get_target_version(subproject) # No target version if tv == '': return - # Target version is new enough - if mesonlib.version_compare_condition_with_min(tv, self.feature_version): + if self.feature_used_correctly(tv): return - # Feature is too new for target version, register it + # Register the feature and version details if the feature was not used + # correctly (deprecated, or added in newer version, etc) if subproject not in self.feature_registry: self.feature_registry[subproject] = {self.feature_version: set()} register = self.feature_registry[subproject] @@ -258,6 +267,15 @@ class FeatureDeprecated(FeatureCheckBase): 'deprecated since \'{}\': {}' ''.format(tv, self.feature_version, self.feature_name)) + def feature_used_correctly(self, target_version): + ''' + False if the target version is newer than the version in which the + feature was deprecated + ''' + if mesonlib.version_compare_condition_with_min(target_version, self.feature_version): + return False + return True + class FeatureCheckKwargsBase: def __init__(self, feature_name, feature_version, kwargs): diff --git a/run_unittests.py b/run_unittests.py index 9b7e45afc..5499988b3 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2789,6 +2789,7 @@ class FailureTests(BasePlatformTests): with self.assertRaisesRegex(MesonException, match, msg=contents): # Must run in-process or we'll get a generic CalledProcessError self.init(self.srcdir, extra_args=extra_args, inprocess=True) + self.wipe() def obtainMesonOutput(self, contents, match, extra_args, langs, meson_version=None): if langs is None: @@ -2802,7 +2803,9 @@ class FailureTests(BasePlatformTests): f.write("add_languages('{}', required : false)\n".format(lang)) f.write(contents) # Run in-process for speed and consistency with assertMesonRaises - return self.init(self.srcdir, extra_args=extra_args, inprocess=True) + ret = self.init(self.srcdir, extra_args=extra_args, inprocess=True) + self.wipe() + return ret def assertMesonOutputs(self, contents, match, extra_args=None, langs=None, meson_version=None): ''' @@ -2994,6 +2997,14 @@ class FailureTests(BasePlatformTests): msg = '.*WARNING:.*feature.*build_always_stale.*custom_target.*' self.assertMesonDoesNotOutput(vcs_tag, msg, meson_version='>=0.43') + def test_feature_deprecation_messages(self): + self.assertMesonOutputs("import('python3')", + ".*DEPRECATION.*Project targetting.*but.*deprecated.*", + meson_version='>= 0.48.0') + self.assertMesonDoesNotOutput("import('python3')", + ".*DEPRECATION.*Project targetting.*but.*deprecated.*", + meson_version='>= 0.47.0') + def test_missing_subproject_not_required_and_required(self): self.assertMesonRaises("sub1 = subproject('not-found-subproject', required: false)\n" + "sub2 = subproject('not-found-subproject', required: true)", |