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
|
||||
|
||||
# helper function to check the compilation when build wasn't successful
|
||||
def checkCompile():
|
||||
def checkCompile(expectToFail=False):
|
||||
ensureChecked(":Qt Creator_CompileOutput_Core::Internal::OutputPaneToggleButton")
|
||||
output = waitForObject(":Qt Creator.Compile Output_Core::OutputWindow")
|
||||
waitFor("len(str(output.plainText))>0",5000)
|
||||
if compileSucceeded(output.plainText):
|
||||
if os.getenv("SYSTEST_DEBUG") == "1":
|
||||
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
|
||||
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
|
||||
|
||||
def compileSucceeded(compileOutput):
|
||||
@@ -220,28 +226,32 @@ def verifyBuildConfig(currentTarget, configName, shouldBeDebug=False, enableShad
|
||||
switchViewTo(ViewConstants.EDIT)
|
||||
|
||||
# verify if building and running of project was successful
|
||||
def verifyBuildAndRun():
|
||||
def verifyBuildAndRun(expectCompileToFail=False):
|
||||
# check compile output if build successful
|
||||
checkCompile()
|
||||
checkCompile(expectCompileToFail)
|
||||
# check application output log
|
||||
appOutput = logApplicationOutput()
|
||||
if appOutput:
|
||||
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)),
|
||||
"Verifying if built app started and closed successfully.")
|
||||
|
||||
# run project for debug and release
|
||||
def runVerify():
|
||||
def runVerify(expectCompileToFailFor=None):
|
||||
availableConfigs = iterateBuildConfigs()
|
||||
if not availableConfigs:
|
||||
test.fatal("Haven't found build configurations, quitting")
|
||||
saveAndExit()
|
||||
for kit, config in availableConfigs:
|
||||
selectBuildConfig(kit, config)
|
||||
expectCompileToFail = False
|
||||
if expectCompileToFailFor is not None and kit in expectCompileToFailFor:
|
||||
expectCompileToFail = True
|
||||
test.log("Using build config '%s'" % config)
|
||||
if runAndCloseApp() == None:
|
||||
checkCompile()
|
||||
if runAndCloseApp(expectCompileToFail) == None:
|
||||
checkCompile(expectCompileToFail)
|
||||
continue
|
||||
verifyBuildAndRun()
|
||||
verifyBuildAndRun(expectCompileToFail)
|
||||
mouseClick(waitForObject(":*Qt Creator.Clear_QToolButton"))
|
||||
|
@@ -454,13 +454,15 @@ def waitForProcessRunning(running=True):
|
||||
|
||||
# run and close an application
|
||||
# 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")
|
||||
clickButton(runButton)
|
||||
waitForCompile(300000)
|
||||
buildSucceeded = checkLastBuild()
|
||||
buildSucceeded = checkLastBuild(expectCompileToFail)
|
||||
ensureChecked(waitForObject(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton"))
|
||||
if not buildSucceeded:
|
||||
if expectCompileToFail:
|
||||
return None
|
||||
test.fatal("Build inside run wasn't successful - leaving test")
|
||||
return None
|
||||
if not waitForProcessRunning():
|
||||
|
@@ -11,6 +11,9 @@ def main():
|
||||
return
|
||||
createProject_Qt_GUI(tempDir(), "SampleApp", buildSystem="qmake")
|
||||
# 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
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
Reference in New Issue
Block a user