[Lldb-commits] [lldb] r354047 - [dotest] Fix compiler version number comparison

Frederic Riss via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 14 10:48:05 PST 2019


Author: friss
Date: Thu Feb 14 10:48:05 2019
New Revision: 354047

URL: http://llvm.org/viewvc/llvm-project?rev=354047&view=rev
Log:
[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

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=354047&r1=354046&r2=354047&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Feb 14 10:48:05 2019
@@ -37,6 +37,7 @@ from __future__ import print_function
 # System modules
 import abc
 import collections
+from distutils.version import LooseVersion
 from functools import wraps
 import gc
 import glob
@@ -1352,13 +1353,13 @@ class Base(unittest2.TestCase):
         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())




More information about the lldb-commits mailing list