From b3a4649a6a27aa4b70b360445f6d2c600db8dff7 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Thu, 14 Feb 2019 18:48:05 +0000 Subject: [PATCH] [dotest] Fix compiler version number comparison dotest's version comparision function is just a lexicographical compare of the version strings. This is obviously wrong. This patch implements the comparison using distutils.version.LooseVersion as suggested by Zachary. Reviewers: zturner, labath, serge-sans-paille Subscribers: jdoerfert, lldb-commits Differential Revision: https://reviews.llvm.org/D58219 llvm-svn: 354047 --- lldb/packages/Python/lldbsuite/test/lldbtest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 6844ae02ec1dd..f1b0d9a1d5770 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -37,6 +37,7 @@ # System modules import abc import collections +from distutils.version import LooseVersion from functools import wraps import gc import glob @@ -1352,13 +1353,13 @@ def expectedCompilerVersion(self, compiler_version): if (version is None): return True if (operator == '>'): - return self.getCompilerVersion() > version + return LooseVersion(self.getCompilerVersion()) > LooseVersion(version) if (operator == '>=' or operator == '=>'): - return self.getCompilerVersion() >= version + return LooseVersion(self.getCompilerVersion()) >= LooseVersion(version) if (operator == '<'): - return self.getCompilerVersion() < version + return LooseVersion(self.getCompilerVersion()) < LooseVersion(version) if (operator == '<=' or operator == '=<'): - return self.getCompilerVersion() <= version + return LooseVersion(self.getCompilerVersion()) <= LooseVersion(version) if (operator == '!=' or operator == '!' or operator == 'not'): return str(version) not in str(self.getCompilerVersion()) return str(version) in str(self.getCompilerVersion())