# Copyright (C) 2016 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 source("../../shared/qtcreator.py") currentSelectedTreeItem = None sectionInProgress = None genericDebuggers = [] warningOrError = re.compile('
((Error|Warning).*?)
') def main(): global appContext emptySettings = tempDir() __createMinimumIni__(emptySettings) appContext = startQC(['-settingspath', '"%s"' % emptySettings], False) if not startedWithoutPluginError(): return invokeMenuItem("Edit", "Preferences...") qmakeFound = __checkKits__() clickButton(waitForObject(":Options.Cancel_QPushButton")) invokeMenuItem("File", "Exit") __checkCreatedSettings__(emptySettings, qmakeFound) def __createMinimumIni__(emptyParent): qtProjDir = os.path.join(emptyParent, "QtProject") os.mkdir(qtProjDir) iniFile = open(os.path.join(qtProjDir, "QtCreator.ini"), "w") iniFile.write("[%General]\n") iniFile.write("OverrideLanguage=C\n") iniFile.close() def __checkKits__(): global genericDebuggers mouseClick(waitForObjectItem(":Options_QListView", "Kits")) # check compilers expectedCompilers = __getExpectedCompilers__() llvmForBuild = os.getenv("SYSTEST_LLVM_FROM_BUILD", None) if llvmForBuild is not None: internalClangExe = os.path.join(llvmForBuild, "bin", "clang") if platform.system() in ("Microsoft", "Windows"): internalClangExe += ".exe" internalClangExe = os.path.realpath(internalClangExe) # clean symlinks if os.path.exists(internalClangExe): if platform.system() in ("Microsoft", "Windows"): expectedCompilers.append({'^Default LLVM \d{2} bit based on MSVC\d{4}$' : ''}) expectedCompilers.append(internalClangExe) foundCompilers = [] foundCompilerNames = [] clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Compilers") __iterateTree__(":BuildAndRun_QTreeView", __compFunc__, foundCompilers, foundCompilerNames) test.verify(__compareCompilers__(foundCompilers, expectedCompilers), "Verifying found and expected compilers are equal.") # check debugger expectedDebuggers = __getExpectedDebuggers__() clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Debuggers") foundDebugger = [] __iterateTree__(":BuildAndRun_QTreeView", __dbgFunc__, foundDebugger) test.verify(__compareDebuggers__(foundDebugger, expectedDebuggers), "Verifying found and expected debuggers are equal.") if not test.compare(len(genericDebuggers), 2, "Verifying generic debugger count."): test.log(str(genericDebuggers)) # check Qt versions qmakePath = which("qmake") if qmakePath and (not "Using Qt version" in getOutputFromCmdline([qmakePath, "--version"], acceptedError=1)): # ignore dysfunctional qmake, e.g. incomplete qtchooser qmakePath = None foundQt = [] clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Qt Versions") __iterateTree__(":qtdirList_QTreeView", __qtFunc__, foundQt, qmakePath) test.verify(not qmakePath or len(foundQt) == 1, "Was qmake from %s autodetected? Found %s" % (qmakePath, foundQt)) if foundQt: foundQt = foundQt[0] # qmake from "which" should be used in kits # check kits clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Kits") __iterateTree__(":BuildAndRun_QTreeView", __kitFunc__, foundQt, foundCompilerNames) return qmakePath != None def __processSubItems__(treeObjStr, section, parModelIndexStr, doneItems, additionalFunc, *additionalParameters): global currentSelectedTreeItem tree = waitForObject(treeObjStr) model = tree.model() items = dumpIndices(model, section) for it in items: indexName = str(it.data().toString()) itObj = "%s container=%s}" % (objectMap.realName(it)[:-1], parModelIndexStr) alreadyDone = doneItems.count(itObj) doneItems.append(itObj) if alreadyDone: itObj = "%s occurrence='%d'}" % (itObj[:-1], alreadyDone + 1) currentSelectedTreeItem = waitForObject(itObj, 3000) tree.scrollTo(it) mouseClick(currentSelectedTreeItem, 5, 5, 0, Qt.LeftButton) additionalFunc(indexName, *additionalParameters) currentSelectedTreeItem = None if model.rowCount(it) > 0: __processSubItems__(treeObjStr, it, itObj, doneItems, additionalFunc, *additionalParameters) def __iterateTree__(treeObjStr, additionalFunc, *additionalParameters): global currentSelectedTreeItem, sectionInProgress model = waitForObject(treeObjStr).model() # 1st row: Auto-detected, 2nd row: Manual (Debugger has additional section Generic prepended) for sect in dumpIndices(model): sectionInProgress = str(sect.text) doneItems = [] parentModelIndex = "%s container='%s'}" % (objectMap.realName(sect)[:-1], treeObjStr) __processSubItems__(treeObjStr, sect, parentModelIndex, doneItems, additionalFunc, *additionalParameters) sectionInProgress = None def __compFunc__(it, foundComp, foundCompNames): # skip sub section items (will continue on its children) if str(it) == "C" or str(it) == "C++": return try: waitFor("object.exists(':Path.Utils_BaseValidatingLineEdit')", 1000) pathLineEdit = findObject(":Path.Utils_BaseValidatingLineEdit") foundComp.append(str(pathLineEdit.text)) except: varsBatComboStr = "{name='varsBatCombo' type='QComboBox' visible='1'}" varsBatCombo = waitForObjectExists(varsBatComboStr) parameterComboStr = "{type='QComboBox' visible='1' unnamed='1' leftWidget=%s}" % varsBatComboStr try: parameterCombo = findObject(parameterComboStr) parameter = ' ' + str(parameterCombo.currentText) except: parameter = '' foundComp.append({it:str(varsBatCombo.currentText) + parameter}) foundCompNames.append(it) def __dbgFunc__(it, foundDbg): global sectionInProgress, genericDebuggers waitFor("object.exists(':Path.Utils_BaseValidatingLineEdit')", 2000) pathLineEdit = findObject(":Path.Utils_BaseValidatingLineEdit") if sectionInProgress == 'Generic': debugger = str(pathLineEdit.text) test.verify(debugger == 'gdb' or debugger == 'lldb', 'Verifying generic debugger is GDB or LLDB.') genericDebuggers.append(debugger) else: foundDbg.append(str(pathLineEdit.text)) def __qtFunc__(it, foundQt, qmakePath): qtPath = str(waitForObject(":QtSupport__Internal__QtVersionManager.qmake_QLabel").text) if platform.system() in ('Microsoft', 'Windows'): qtPath = qtPath.lower() qmakePath = qmakePath.lower() test.verify(os.path.isfile(qtPath) and os.access(qtPath, os.X_OK), "Verifying found Qt (%s) is executable." % qtPath) # Two Qt versions will be found when using qtchooser: QTCREATORBUG-14697 # Only add qmake from "which" to list if qtPath == qmakePath: foundQt.append(it) try: errorLabel = findObject(":QtSupport__Internal__QtVersionManager.errorLabel.QLabel") test.warning("Detected error or warning: '%s'" % errorLabel.text) except: pass def __kitFunc__(it, foundQt, foundCompNames): global currentSelectedTreeItem, warningOrError if 'Python' in it: # skip Python kits return qtVersionStr = str(waitForObjectExists(":Kits_QtVersion_QComboBox").currentText) # The following may fail if Creator doesn't find a Qt version in PATH. It will then create one # Qt-less kit for each available toolchain instead of just one default Desktop kit. # Since Qt usually is in PATH on the test machines anyway, we consider this too much of a # corner case to add error handling code or make Qt in PATH a hard requirement for the tests. test.compare(it, "Desktop (default)", "Verifying whether default Desktop kit has been created.") if foundQt: test.compare(qtVersionStr, foundQt, "Verifying if Qt versions match.") cCompilerCombo = findObject(":CCompiler:_QComboBox") test.compare(cCompilerCombo.enabled, cCompilerCombo.count > 1, "Verifying whether C compiler combo is enabled/disabled correctly.") cppCompilerCombo = findObject(":CppCompiler:_QComboBox") test.compare(cppCompilerCombo.enabled, cppCompilerCombo.count > 1, "Verifying whether C++ compiler combo is enabled/disabled correctly.") test.verify(str(cCompilerCombo.currentText) in foundCompNames, "Verifying if one of the found C compilers had been set.") test.verify(str(cppCompilerCombo.currentText) in foundCompNames, "Verifying if one of the found C++ compilers had been set.") if currentSelectedTreeItem: foundWarningOrError = warningOrError.search(str(currentSelectedTreeItem.toolTip)) if foundWarningOrError: details = str(foundWarningOrError.group(1)).replace("