diff options
Diffstat (limited to 'tests/run_tests.py')
-rwxr-xr-x | tests/run_tests.py | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/tests/run_tests.py b/tests/run_tests.py index 3d6c365c..00c8c33f 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -11,15 +11,16 @@ class QtInstallation: def __init__(self): self.int_version = 000 self.qmake_header_path = "/usr/include/qt/" + self.qmake_lib_path = "/usr/lib" def compiler_flags(self): - return "-isystem " + self.qmake_header_path + ("" if isWindows() else " -fPIC") + return "-isystem " + self.qmake_header_path + ("" if isWindows() else " -fPIC") + " -L " + self.qmake_lib_path class Test: def __init__(self, check): self.filename = "" self.minimum_qt_version = 500 - self.maximum_qt_version = 999999 + self.maximum_qt_version = 59999 self.minimum_clang_version = 380 self.compare_everything = False self.isFixedFile = False @@ -35,6 +36,8 @@ class Test: self.qt4compat = False self.only_qt = False self.qt_developer = False + self.header_filter = "" + self.ignore_dirs = "" def isScript(self): return self.filename.endswith(".sh") @@ -62,8 +65,9 @@ class Check: self.name = name self.minimum_clang_version = 380 # clang 3.8.0 self.minimum_qt_version = 500 - self.maximum_qt_version = 999999 + self.maximum_qt_version = 59999 self.enabled = True + self.clazy_standalone_only = False self.tests = [] #------------------------------------------------------------------------------- # utility functions #1 @@ -101,6 +105,9 @@ def load_json(check_name): if 'enabled' in decoded: check.enabled = decoded['enabled'] + if 'clazy_standalone_only' in decoded: + check.clazy_standalone_only = decoded['clazy_standalone_only'] + if 'blacklist_platforms' in decoded: check_blacklist_platforms = decoded['blacklist_platforms'] @@ -151,6 +158,10 @@ def load_json(check_name): test.only_qt = t['only_qt'] if 'qt_developer' in t: test.qt_developer = t['qt_developer'] + if 'header_filter' in t: + test.header_filter = t['header_filter'] + if 'ignore_dirs' in t: + test.ignore_dirs = t['ignore_dirs'] if not test.checks: test.checks.append(test.check.name) @@ -170,9 +181,13 @@ def find_qt_installation(major_version, qmakes): qmake_version_str,success = get_command_output(qmake + " -query QT_VERSION") if success and qmake_version_str.startswith(str(major_version) + "."): qmake_header_path = get_command_output(qmake + " -query QT_INSTALL_HEADERS")[0].strip() + qmake_lib_path = get_command_output(qmake + " -query QT_INSTALL_LIBS")[0].strip() if qmake_header_path: installation.qmake_header_path = qmake_header_path - installation.int_version = int(qmake_version_str.replace(".", "")) + if qmake_lib_path: + installation.qmake_lib_path = qmake_lib_path + ver = qmake_version_str.split('.') + installation.int_version = int(ver[0]) * 10000 + int(ver[1]) * 100 + int(ver[2]) if _verbose: print "Found Qt " + str(installation.int_version) + " using qmake " + qmake break @@ -217,16 +232,23 @@ def clazy_standalone_command(test, qt): if test.qt_developer: result = " -qt-developer " + result + if test.header_filter: + result = " -header-filter " + test.header_filter + " " + result + + if test.ignore_dirs: + result = " -ignore-dirs " + test.ignore_dirs + " " + result + return result def clazy_command(qt, test, filename): if test.isScript(): return "./" + filename - if 'CLAZY_CXX' in os.environ: + if 'CLAZY_CXX' in os.environ: # In case we want to use clazy.bat result = os.environ['CLAZY_CXX'] + more_clazy_args() + qt.compiler_flags() else: - result = "clang -Xclang -load -Xclang " + libraryName() + " -Xclang -add-plugin -Xclang clang-lazy " + more_clazy_args() + qt.compiler_flags() + clang = os.getenv('CLANGXX', 'clang') + result = clang + " -Xclang -load -Xclang " + libraryName() + " -Xclang -add-plugin -Xclang clang-lazy " + more_clazy_args() + qt.compiler_flags() if test.qt4compat: result = result + " -Xclang -plugin-arg-clang-lazy -Xclang qt4-compat " @@ -250,12 +272,12 @@ def clazy_command(qt, test, filename): return result def dump_ast_command(test): - return "clang -std=c++14 -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics -c " + qt_installation(test.qt_major_version).compiler_flags() + " " + test.filename + return "clang -std=c++14 -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics -c " + qt_installation(test.qt_major_version).compiler_flags() + " " + test.flags + " " + test.filename def compiler_name(): if 'CLAZY_CXX' in os.environ: return os.environ['CLAZY_CXX'] # so we can set clazy.bat instead - return 'clang' + return os.getenv('CLANGXX', 'clang') #------------------------------------------------------------------------------- # Get clang version @@ -371,7 +393,16 @@ def extract_word(word, in_file, out_file): in_f.close() out_f.close() +def print_file(filename): + f = open(filename, 'r') + print f.read() + f.close() + + def run_unit_test(test, is_standalone): + if test.check.clazy_standalone_only and not is_standalone: + return True + qt = qt_installation(test.qt_major_version) if _verbose: @@ -380,9 +411,13 @@ def run_unit_test(test, is_standalone): print "Qt headers: " + qt.qmake_header_path if qt.int_version < test.minimum_qt_version or qt.int_version > test.maximum_qt_version or CLANG_VERSION < test.minimum_clang_version: + if (_verbose): + print "Skipping " + test.check_name + " because required version is not available" return True if _platform in test.blacklist_platforms: + if (_verbose): + print "Skipping " + test.check_name + " because it is blacklisted for this platform" return True checkname = test.check.name @@ -412,6 +447,10 @@ def run_unit_test(test, is_standalone): if (not cmd_success and not must_fail) or (cmd_success and must_fail): print "[FAIL] " + checkname + " (Failed to build test. Check " + output_file + " for details)" + print "-------------------" + print "Contents of %s:" % output_file + print_file(output_file) + print "-------------------" print return False @@ -529,4 +568,9 @@ else: for thread in threads: thread.join() -sys.exit(0 if _was_successful else -1) +if _was_successful: + print "SUCCESS" + sys.exit(0) +else: + print "FAIL" + sys.exit(-1) |