Cleanup TestUniqueTypes.py and add getCompilerVersion() to test harness
- pull up logic to get compiler version from TestUniqueTypes.py into lldbtest.py
- work around an GCC 4.6.3 issue
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@176190 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/lldbtest.py b/test/lldbtest.py
index 766502a..d74299f 100644
--- a/test/lldbtest.py
+++ b/test/lldbtest.py
@@ -531,7 +531,7 @@
def skipIfGcc(func):
"""Decorate the item to skip tests that should be skipped if building with gcc ."""
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
- raise Exception("@skipOnLinux can only be used to decorate a test method")
+ raise Exception("@skipIfGcc can only be used to decorate a test method")
@wraps(func)
def wrapper(*args, **kwargs):
from unittest2 import case
@@ -543,7 +543,6 @@
func(*args, **kwargs)
return wrapper
-
class Base(unittest2.TestCase):
"""
Abstract base for performing lldb (see TestBase) or other generic tests (see
@@ -1015,6 +1014,25 @@
module = builder_module()
return module.getCompiler()
+ def getCompilerVersion(self):
+ """ Returns a string that represents the compiler version.
+ Supports: llvm, clang.
+ """
+ from lldbutil import which
+ version = 'unknown'
+
+ compiler = self.getCompiler()
+ version_output = system([which(compiler), "-v"])[1]
+ for line in version_output.split(os.linesep):
+ compiler_shortname = 'invalid'
+ for c in ["clang", "gcc"]:
+ if c in compiler:
+ compiler_shortname = c
+ m = re.search('%s version ([0-9\.]+)' % compiler_shortname, line)
+ if m:
+ version = m.group(1)
+ return version
+
def getRunOptions(self):
"""Command line option for -A and -C to run this test again, called from
self.dumpSessionInfo()."""