Skip to content

Commit

Permalink
[dotest] Fix compiler version number comparison
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fredriss committed Feb 14, 2019
1 parent 97067d3 commit b3a4649
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Expand Up @@ -37,6 +37,7 @@
# System modules
import abc
import collections
from distutils.version import LooseVersion
from functools import wraps
import gc
import glob
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit b3a4649

Please sign in to comment.