From 1394cb9263a17484fea01ce807402dcc95e68e20 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Tue, 14 Aug 2018 12:44:15 +0100 Subject: 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) --- mesonbuild/mesonlib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mesonbuild/mesonlib.py') diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 05a77cd..8a2dc0c 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -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 -- cgit v1.1