diff options
author | Daniel Smith <daniel.smith@qt.io> | 2019-11-26 12:47:39 +0100 |
---|---|---|
committer | Daniel Smith <daniel.smith@qt.io> | 2019-11-27 09:24:38 +0100 |
commit | 556798f875e5501a7322c1cc571701b52c851449 (patch) | |
tree | 5765827cf0fb66ec20f2465ea249d43e9c192e06 /scripts/lancebot | |
parent | 0f6a737ca798ae9c8e0c634715c5cb66681a278a (diff) |
Improve error handling on test application completion
If the results.xml file is not written, abort.
If the results file is written but contains 0 test cases, abort.
Change-Id: I8b701fb81c21392f1b1088eaf584892fdf04b08a
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'scripts/lancebot')
-rw-r--r-- | scripts/lancebot/lancebot.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/scripts/lancebot/lancebot.py b/scripts/lancebot/lancebot.py index efe5d95e..db6d6bfd 100644 --- a/scripts/lancebot/lancebot.py +++ b/scripts/lancebot/lancebot.py @@ -495,7 +495,7 @@ Build SHA: {buildSHA}\nHEAD SHA: {headSHA}") storeSha(refBaseDir, module, "build", headSHA) -def parseResults(file: str): +def parseResults(file: str) -> (): testFunctionsXML = [] testNames = [] testFailures = {} @@ -516,7 +516,9 @@ def parseResults(file: str): "file": incident.childNodes[1].firstChild.nodeValue, "description": incident.childNodes[3].firstChild.nodeValue }) - + except FileNotFoundError: + print(f"ERROR: No results file found. It's most likely that the test executable failed to complete.\n file tried: {file}") + return (False, False, "File Not Found") except Exception as e: print(e) @@ -524,7 +526,7 @@ def parseResults(file: str): if len(testFailures[name]) == 0: del testFailures[name] - return (testFailures, testCount) + return (testFailures, testCount, False) def runTest(testBaseDir, module, testType): @@ -657,8 +659,14 @@ new baselines to Lancelot.") subprocess.run( commandString, universal_newlines=True, shell=False) print("Parsing results.xml...") - resultsData, testCount = parseResults( + resultsData, testCount, error = parseResults( f"{testBaseDir}/{module}/{testDir}/results.xml") + if error: + break + elif not testCount: + print("ERROR: Test executable ran, but no test cases were executed!") + break + formattedResults = json.dumps(resultsData, indent=2) output_file.write( formattedResults if resultsData else "ALL PASS") |