forked from qt-creator/qt-creator
Squish: Replaced lot of signal code by one simple function
Change-Id: Idb6b663a8b2be217d8769fab5e2f6f9290f37990 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -29,38 +29,9 @@
|
||||
|
||||
import re;
|
||||
|
||||
# dictionary to hold a list of all installed handler functions for all object-signalSignature pairs
|
||||
installedSignalHandlers = {}
|
||||
# flag to indicate whether overrideInstallLazySignalHandler() has been called already
|
||||
overridenInstallLazySignalHandlers = False
|
||||
# flag to indicate whether a tasks file should be created when building ends with errors
|
||||
createTasksFileOnError = True
|
||||
|
||||
# call this function to override installLazySignalHandler()
|
||||
def overrideInstallLazySignalHandler():
|
||||
global overridenInstallLazySignalHandlers
|
||||
if overridenInstallLazySignalHandlers:
|
||||
return
|
||||
overridenInstallLazySignalHandlers = True
|
||||
global installLazySignalHandler
|
||||
installLazySignalHandler = __addSignalHandlerDict__(installLazySignalHandler)
|
||||
|
||||
# avoids adding a handler to a signal twice or more often
|
||||
# do not call this function directly - use overrideInstallLazySignalHandler() instead
|
||||
def __addSignalHandlerDict__(lazySignalHandlerFunction):
|
||||
global installedSignalHandlers
|
||||
def wrappedFunction(name, signalSignature, handlerFunctionName):
|
||||
handlers = installedSignalHandlers.get("%s____%s" % (name,signalSignature))
|
||||
if handlers == None:
|
||||
lazySignalHandlerFunction(name, signalSignature, handlerFunctionName)
|
||||
installedSignalHandlers.setdefault("%s____%s" % (name,signalSignature), [handlerFunctionName])
|
||||
else:
|
||||
if not handlerFunctionName in handlers:
|
||||
lazySignalHandlerFunction(name, signalSignature, handlerFunctionName)
|
||||
handlers.append(handlerFunctionName)
|
||||
installedSignalHandlers.setdefault("%s____%s" % (name,signalSignature), handlers)
|
||||
return wrappedFunction
|
||||
|
||||
# this method checks the last build (if there's one) and logs the number of errors, warnings and
|
||||
# lines within the Issues output
|
||||
# optional parameter can be used to tell this function if the build was expected to fail or not
|
||||
@@ -105,6 +76,12 @@ def compileSucceeded(compileOutput):
|
||||
return None != re.match(".*exited normally\.\n\d\d:\d\d:\d\d: Elapsed time: "
|
||||
"(\d:)?\d{2}:\d\d\.$", str(compileOutput), re.S)
|
||||
|
||||
def waitForCompile(timeout=60000):
|
||||
ensureChecked(":Qt Creator_CompileOutput_Core::Internal::OutputPaneToggleButton")
|
||||
output = waitForObject(":Qt Creator.Compile Output_Core::OutputWindow")
|
||||
if not waitFor("re.match('.*Elapsed time: (\d:)?\d{2}:\d\d\.$', str(output.plainText), re.S)", timeout):
|
||||
test.warning("Waiting for compile timed out after %d s." % (timeout / 1000))
|
||||
|
||||
def dumpBuildIssues(listModel):
|
||||
issueDump = []
|
||||
for row in range(listModel.rowCount()):
|
||||
|
||||
@@ -401,7 +401,7 @@ def runAndCloseApp(withHookInto=False, executable=None, port=None, function=None
|
||||
runButton = waitForObject(":*Qt Creator.Run_Core::Internal::FancyToolButton")
|
||||
clickButton(runButton)
|
||||
if sType != SubprocessType.QT_QUICK_UI:
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000)
|
||||
waitForCompile(300000)
|
||||
buildSucceeded = checkLastBuild()
|
||||
ensureChecked(waitForObject(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton"))
|
||||
if not buildSucceeded:
|
||||
|
||||
@@ -169,43 +169,6 @@ def which(program):
|
||||
return cf
|
||||
return None
|
||||
|
||||
signalObjects = {}
|
||||
|
||||
# do not call this function directly - it's only a helper
|
||||
def __callbackFunction__(object, *args):
|
||||
global signalObjects
|
||||
# test.log("__callbackFunction__: "+objectMap.realName(object))
|
||||
signalObjects[objectMap.realName(object)] += 1
|
||||
|
||||
def waitForSignal(object, signal, timeout=30000):
|
||||
global signalObjects
|
||||
realName = prepareForSignal(object, signal)
|
||||
beforeCount = signalObjects[realName]
|
||||
waitFor("signalObjects[realName] > beforeCount", timeout)
|
||||
|
||||
handledSignal = {}
|
||||
|
||||
def prepareForSignal(object, signal):
|
||||
global signalObjects
|
||||
global handledSignal
|
||||
overrideInstallLazySignalHandler()
|
||||
realName = objectMap.realName(object)
|
||||
# test.log("waitForSignal: "+realName)
|
||||
if realName in handledSignal.keys():
|
||||
if handledSignal[realName] != signal:
|
||||
# The current implementation does not support this.
|
||||
# When an object has two different handled signals, waitForSignal() will only wait
|
||||
# for the first of them to be emitted.
|
||||
test.warning("You are trying to handle two different signals from the same object.",
|
||||
"Adding %s to object %s, which already has handled signal %s. "
|
||||
"This can lead to unexpected results." % (signal, realName, handledSignal[realName]))
|
||||
else:
|
||||
handledSignal[realName] = signal
|
||||
if not (realName in signalObjects):
|
||||
signalObjects[realName] = 0
|
||||
installLazySignalHandler(object, signal, "__callbackFunction__")
|
||||
return realName
|
||||
|
||||
# this function removes the user files of given pro file(s)
|
||||
# can be called with a single string object or a list of strings holding path(s) to
|
||||
# the pro file(s) returns False if it could not remove all user files or has been
|
||||
|
||||
@@ -59,7 +59,7 @@ def main():
|
||||
# try to build project
|
||||
test.log("Testing build configuration: " + config)
|
||||
invokeMenuItem("Build", "Build All")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
# verify build successful
|
||||
ensureChecked(waitForObject(":Qt Creator_CompileOutput_Core::Internal::OutputPaneToggleButton"))
|
||||
compileOutput = waitForObject(":Qt Creator.Compile Output_Core::OutputWindow")
|
||||
|
||||
@@ -46,7 +46,7 @@ def main():
|
||||
# try to compile
|
||||
test.log("Testing build configuration: " + config)
|
||||
clickButton(waitForObject(":*Qt Creator.Build Project_Core::Internal::FancyToolButton"))
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
# check output if build successful
|
||||
ensureChecked(waitForObject(":Qt Creator_CompileOutput_Core::Internal::OutputPaneToggleButton"))
|
||||
waitFor("object.exists(':*Qt Creator.Cancel Build_QToolButton')", 20000)
|
||||
|
||||
@@ -58,7 +58,7 @@ def main():
|
||||
test.log("Testing build configuration: " + config)
|
||||
clickButton(waitForObject(":*Qt Creator.Build Project_Core::Internal::FancyToolButton"))
|
||||
# wait until build finished
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
# open issues list view
|
||||
ensureChecked(waitForObject(":Qt Creator_Issues_Core::Internal::OutputPaneToggleButton"))
|
||||
issuesView = waitForObject(":Qt Creator.Issues_QListView")
|
||||
|
||||
@@ -54,7 +54,7 @@ def main():
|
||||
# build project 2
|
||||
clickButton(waitForObject(":*Qt Creator.Build Project_Core::Internal::FancyToolButton"))
|
||||
# wait for build to complete
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
# check output if build successful
|
||||
ensureChecked(waitForObject(":Qt Creator_CompileOutput_Core::Internal::OutputPaneToggleButton"))
|
||||
outputLog = str(waitForObject(":Qt Creator.Compile Output_Core::OutputWindow").plainText)
|
||||
|
||||
@@ -103,7 +103,7 @@ def performDebugging(workingDir, projectName, checkedTargets):
|
||||
verifyBuildConfig(len(checkedTargets), kit, True)
|
||||
progressBarWait(10000)
|
||||
invokeMenuItem("Build", "Rebuild All")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
isMsvc = isMsvcConfig(len(checkedTargets), kit)
|
||||
allowAppThroughWinFW(workingDir, projectName, False)
|
||||
clickButton(waitForObject(":*Qt Creator.Start Debugging_Core::Internal::FancyToolButton"))
|
||||
|
||||
@@ -75,8 +75,7 @@ def performTest(workingDir, projectName, targetCount, availableConfigs, disableO
|
||||
switchViewTo(ViewConstants.EDIT)
|
||||
# explicitly build before start debugging for adding the executable as allowed program to WinFW
|
||||
invokeMenuItem("Build", "Rebuild All")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}",
|
||||
"buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
if not checkCompile():
|
||||
test.fatal("Compile had errors... Skipping current build config")
|
||||
continue
|
||||
|
||||
@@ -70,8 +70,7 @@ def main():
|
||||
verifyBuildConfig(len(checkedTargets), kit, True, enableQmlDebug=True)
|
||||
# explicitly build before start debugging for adding the executable as allowed program to WinFW
|
||||
invokeMenuItem("Build", "Rebuild All")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}",
|
||||
"buildQueueFinished(bool)", 300000)
|
||||
waitForCompile(300000)
|
||||
if not checkCompile():
|
||||
test.fatal("Compile had errors... Skipping current build config")
|
||||
continue
|
||||
|
||||
@@ -60,10 +60,6 @@ def testRenameId():
|
||||
files = ["Core.ContextMenu\\.qml", "Core.GridMenu\\.qml", "Core.ListMenu\\.qml", "focus\\.qml"]
|
||||
originalTexts = {}
|
||||
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
|
||||
# temporarily store editor content for synchronizing purpose
|
||||
# usage of formerTxt is done because I couldn't get waitForSignal() to work
|
||||
# it always stored a different object into the signalObjects map as it looked up afterwards
|
||||
# although used objectMap.realName() for both
|
||||
formerTxt = editor.plainText
|
||||
for file in files:
|
||||
openDocument("focus.QML.qml.%s" % file)
|
||||
|
||||
@@ -65,9 +65,9 @@ def main():
|
||||
continue
|
||||
test.log("Testing build configuration: " + config)
|
||||
invokeMenuItem("Build", "Run qmake")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
invokeMenuItem("Build", "Rebuild All")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000)
|
||||
waitForCompile(300000)
|
||||
checkCompile()
|
||||
checkLastBuild()
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ def main():
|
||||
invokeMenuItem("Build", "Rebuild All")
|
||||
|
||||
# Wait for, and test if the build succeeded
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000)
|
||||
waitForCompile(300000)
|
||||
checkCompile()
|
||||
checkLastBuild()
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ def main():
|
||||
% (qVer, Targets.getStringForTarget(targ)))
|
||||
result = modifyRunSettingsForHookInto(projectName, len(checkedTargets), 11223)
|
||||
invokeMenuItem("Build", "Build All")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
if not checkCompile():
|
||||
test.fatal("Compile failed")
|
||||
else:
|
||||
|
||||
@@ -41,7 +41,7 @@ def main():
|
||||
test.log("Building project Qt Quick %d Extension Plugin (%s)"
|
||||
% (quickVer, Targets.getStringForTarget(targ)))
|
||||
invokeMenuItem("Build","Build All")
|
||||
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
|
||||
waitForCompile()
|
||||
checkCompile()
|
||||
checkLastBuild()
|
||||
invokeMenuItem("File", "Close All Projects and Editors")
|
||||
|
||||
Reference in New Issue
Block a user