Correct version_compare_condition_with_min()

Correct version_compare_condition_with_min() for the case where no minimum
version is established by the version constraint.  Add a simple test.

Also fix test_feature_check_usage_subprojects by escaping regex
metacharacters.

if |condition| is '<', '<=' or '!=', the minimum version satisfying the
condition is 0, so the minimum version for a feature is never met.

if |condition| is '>=' or '==', the minimum version satisfying the condition
is the version compared with, so the minimum version for a feature must be
less than or equal to that.

if |condition| is '>', the minimum version satisfying the condition is
greater than the version compared with, so the minimum version for a feature
must be less than that

(it's this last condition that makes this function necessary, as in all
other cases we could establish a definite minimum version which we could
compare to see if it's less than or equal to the current version)
pull/4017/head
Jon Turney 7 years ago
parent 8b3ad3e9a0
commit 1394cb9263
  1. 6
      mesonbuild/mesonlib.py
  2. 9
      run_unittests.py
  3. 1
      test cases/unit/41 featurenew subprojects/meson.build
  4. 3
      test cases/unit/41 featurenew subprojects/subprojects/baz/meson.build

@ -493,9 +493,9 @@ def version_compare_condition_with_min(condition, minimum):
cmpop = operator.le
condition = condition[2:]
elif condition.startswith('<='):
return True
return False
elif condition.startswith('!='):
return True
return False
elif condition.startswith('=='):
cmpop = operator.le
condition = condition[2:]
@ -506,7 +506,7 @@ def version_compare_condition_with_min(condition, minimum):
cmpop = operator.lt
condition = condition[1:]
elif condition.startswith('<'):
return True
return False
else:
cmpop = operator.le

@ -2660,13 +2660,14 @@ recommended as it is not supported on some platforms''')
out = self.init(testdir)
# Parent project warns correctly
self.assertRegex(out, "WARNING: Project targetting '>=0.45'.*'0.47.0': dict")
# Subproject warns correctly
self.assertRegex(out, "|WARNING: Project targetting '>=0.40'.*'0.44.0': disabler")
# Subprojects warn correctly
self.assertRegex(out, r"\|WARNING: Project targetting '>=0.40'.*'0.44.0': disabler")
self.assertRegex(out, r"\|WARNING: Project targetting '!=0.40'.*'0.44.0': disabler")
# Subproject has a new-enough meson_version, no warning
self.assertNotRegex(out, "WARNING: Project targetting.*Python")
# Ensure a summary is printed in the subproject and the outer project
self.assertRegex(out, "|WARNING: Project specifies a minimum meson_version '>=0.40'")
self.assertRegex(out, "| * 0.44.0: {'disabler'}")
self.assertRegex(out, r"\|WARNING: Project specifies a minimum meson_version '>=0.40'")
self.assertRegex(out, r"\| \* 0.44.0: {'disabler'}")
self.assertRegex(out, "WARNING: Project specifies a minimum meson_version '>=0.45'")
self.assertRegex(out, " * 0.47.0: {'dict'}")

@ -4,3 +4,4 @@ foo = {}
subproject('foo')
subproject('bar')
subproject('baz')

@ -0,0 +1,3 @@
project('baz subproject', meson_version: '!=0.40')
disabler()
Loading…
Cancel
Save