forked from qt-creator/qt-creator
Squish: Allow build to fail for runAndCloseApp()
Allows to mark current configuration to fail when we trigger a run with implicit build. Change-Id: I5738c49e62bca876c0aeba28af5f8315303620a2 Reviewed-by: Robert Löhning <robert.loehning@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -56,17 +56,23 @@ def checkLastBuild(expectedToFail=False, createTasksFileOnError=True):
|
|||||||
return not gotErrors
|
return not gotErrors
|
||||||
|
|
||||||
# helper function to check the compilation when build wasn't successful
|
# helper function to check the compilation when build wasn't successful
|
||||||
def checkCompile():
|
def checkCompile(expectToFail=False):
|
||||||
ensureChecked(":Qt Creator_CompileOutput_Core::Internal::OutputPaneToggleButton")
|
ensureChecked(":Qt Creator_CompileOutput_Core::Internal::OutputPaneToggleButton")
|
||||||
output = waitForObject(":Qt Creator.Compile Output_Core::OutputWindow")
|
output = waitForObject(":Qt Creator.Compile Output_Core::OutputWindow")
|
||||||
waitFor("len(str(output.plainText))>0",5000)
|
waitFor("len(str(output.plainText))>0",5000)
|
||||||
if compileSucceeded(output.plainText):
|
if compileSucceeded(output.plainText):
|
||||||
if os.getenv("SYSTEST_DEBUG") == "1":
|
if os.getenv("SYSTEST_DEBUG") == "1":
|
||||||
test.log("Compile Output:\n%s" % str(output.plainText))
|
test.log("Compile Output:\n%s" % str(output.plainText))
|
||||||
test.passes("Compile successful")
|
if expectToFail:
|
||||||
|
test.fail("Compile successful - but was expected to fail.")
|
||||||
|
else:
|
||||||
|
test.passes("Compile successful")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
test.fail("Compile Output:\n%s" % output.plainText)
|
if expectToFail:
|
||||||
|
test.passes("Expected fail - Compile output:\n%s" % str(output.plainText))
|
||||||
|
else:
|
||||||
|
test.fail("Compile Output:\n%s" % str(output.plainText))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def compileSucceeded(compileOutput):
|
def compileSucceeded(compileOutput):
|
||||||
@@ -220,28 +226,32 @@ def verifyBuildConfig(currentTarget, configName, shouldBeDebug=False, enableShad
|
|||||||
switchViewTo(ViewConstants.EDIT)
|
switchViewTo(ViewConstants.EDIT)
|
||||||
|
|
||||||
# verify if building and running of project was successful
|
# verify if building and running of project was successful
|
||||||
def verifyBuildAndRun():
|
def verifyBuildAndRun(expectCompileToFail=False):
|
||||||
# check compile output if build successful
|
# check compile output if build successful
|
||||||
checkCompile()
|
checkCompile(expectCompileToFail)
|
||||||
# check application output log
|
# check application output log
|
||||||
appOutput = logApplicationOutput()
|
appOutput = logApplicationOutput()
|
||||||
if appOutput:
|
if appOutput:
|
||||||
test.verify((re.search(".* exited with code \d+", str(appOutput)) or
|
test.verify((re.search(".* exited with code \d+", str(appOutput)) or
|
||||||
re.search(".* crashed\.", str(appOutput))) and
|
re.search(".* crashed\.", str(appOutput)) or
|
||||||
|
re.search(".* was ended forcefully\.", str(appOutput))) and
|
||||||
re.search('[Ss]tarting.*', str(appOutput)),
|
re.search('[Ss]tarting.*', str(appOutput)),
|
||||||
"Verifying if built app started and closed successfully.")
|
"Verifying if built app started and closed successfully.")
|
||||||
|
|
||||||
# run project for debug and release
|
# run project for debug and release
|
||||||
def runVerify():
|
def runVerify(expectCompileToFailFor=None):
|
||||||
availableConfigs = iterateBuildConfigs()
|
availableConfigs = iterateBuildConfigs()
|
||||||
if not availableConfigs:
|
if not availableConfigs:
|
||||||
test.fatal("Haven't found build configurations, quitting")
|
test.fatal("Haven't found build configurations, quitting")
|
||||||
saveAndExit()
|
saveAndExit()
|
||||||
for kit, config in availableConfigs:
|
for kit, config in availableConfigs:
|
||||||
selectBuildConfig(kit, config)
|
selectBuildConfig(kit, config)
|
||||||
|
expectCompileToFail = False
|
||||||
|
if expectCompileToFailFor is not None and kit in expectCompileToFailFor:
|
||||||
|
expectCompileToFail = True
|
||||||
test.log("Using build config '%s'" % config)
|
test.log("Using build config '%s'" % config)
|
||||||
if runAndCloseApp() == None:
|
if runAndCloseApp(expectCompileToFail) == None:
|
||||||
checkCompile()
|
checkCompile(expectCompileToFail)
|
||||||
continue
|
continue
|
||||||
verifyBuildAndRun()
|
verifyBuildAndRun(expectCompileToFail)
|
||||||
mouseClick(waitForObject(":*Qt Creator.Clear_QToolButton"))
|
mouseClick(waitForObject(":*Qt Creator.Clear_QToolButton"))
|
||||||
|
@@ -454,13 +454,15 @@ def waitForProcessRunning(running=True):
|
|||||||
|
|
||||||
# run and close an application
|
# run and close an application
|
||||||
# returns None if the build failed, False if the subprocess did not start, and True otherwise
|
# returns None if the build failed, False if the subprocess did not start, and True otherwise
|
||||||
def runAndCloseApp():
|
def runAndCloseApp(expectCompileToFail=False):
|
||||||
runButton = waitForObject(":*Qt Creator.Run_Core::Internal::FancyToolButton")
|
runButton = waitForObject(":*Qt Creator.Run_Core::Internal::FancyToolButton")
|
||||||
clickButton(runButton)
|
clickButton(runButton)
|
||||||
waitForCompile(300000)
|
waitForCompile(300000)
|
||||||
buildSucceeded = checkLastBuild()
|
buildSucceeded = checkLastBuild(expectCompileToFail)
|
||||||
ensureChecked(waitForObject(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton"))
|
ensureChecked(waitForObject(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton"))
|
||||||
if not buildSucceeded:
|
if not buildSucceeded:
|
||||||
|
if expectCompileToFail:
|
||||||
|
return None
|
||||||
test.fatal("Build inside run wasn't successful - leaving test")
|
test.fatal("Build inside run wasn't successful - leaving test")
|
||||||
return None
|
return None
|
||||||
if not waitForProcessRunning():
|
if not waitForProcessRunning():
|
||||||
|
@@ -11,6 +11,9 @@ def main():
|
|||||||
return
|
return
|
||||||
createProject_Qt_GUI(tempDir(), "SampleApp", buildSystem="qmake")
|
createProject_Qt_GUI(tempDir(), "SampleApp", buildSystem="qmake")
|
||||||
# run project for debug and release and verify results
|
# run project for debug and release and verify results
|
||||||
runVerify()
|
expectToFail = None
|
||||||
|
if platform.system() in ('Microsoft', 'Windows'):
|
||||||
|
expectToFail = [Targets.DESKTOP_5_4_1_GCC]
|
||||||
|
runVerify(expectToFail)
|
||||||
#close Qt Creator
|
#close Qt Creator
|
||||||
invokeMenuItem("File", "Exit")
|
invokeMenuItem("File", "Exit")
|
||||||
|
Reference in New Issue
Block a user