From 5265ad275ced1c923f322fc264ea43ea679d1652 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 25 May 2022 11:50:18 +0200 Subject: [PATCH] Squish: Allow build to fail for runAndCloseApp() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows to mark current configuration to fail when we trigger a run with implicit build. Change-Id: I5738c49e62bca876c0aeba28af5f8315303620a2 Reviewed-by: Robert Löhning Reviewed-by: --- tests/system/shared/build_utils.py | 30 ++++++++++++++-------- tests/system/shared/project.py | 6 +++-- tests/system/suite_APTW/tst_APTW01/test.py | 5 +++- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/tests/system/shared/build_utils.py b/tests/system/shared/build_utils.py index 300b0ed8ba4..4cf1bf82dcb 100644 --- a/tests/system/shared/build_utils.py +++ b/tests/system/shared/build_utils.py @@ -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")) diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py index 0ee2db614d6..06c7e115e38 100644 --- a/tests/system/shared/project.py +++ b/tests/system/shared/project.py @@ -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(): diff --git a/tests/system/suite_APTW/tst_APTW01/test.py b/tests/system/suite_APTW/tst_APTW01/test.py index 05cd53fe1fc..f1536b2a874 100644 --- a/tests/system/suite_APTW/tst_APTW01/test.py +++ b/tests/system/suite_APTW/tst_APTW01/test.py @@ -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")