Skip to content

Commit

Permalink
Use matrix outcome to set exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Oct 8, 2019
1 parent 060a15b commit cd8b77f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
3 changes: 3 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## next (unreleased)

- [#595](https://github.com/TestArmada/flank/pull/595) Rename `flaky-test-attempts` to `num-flaky-test-attempts`. Rename `repeat-tests` to `num-test-runs`. ([bootstraponline](https://github.com/bootstraponline))
- [#605](https://github.com/TestArmada/flank/pull/605) Improve exit code logging. Use matrix outcome to set exit code. ([bootstraponline](https://github.com/bootstraponline))
- [#597](https://github.com/TestArmada/flank/pull/597) Support parsing testLabExecutionId. [yogurtearl](https://github.com/yogurtearl)
- [#599](https://github.com/TestArmada/flank/pull/599) Disable FAIL_ON_UNKNOWN_PROPERTIES for forward compatibility. [narenkmanoharan](https://github.com/narenkmanoharan)

## v7.0.2

Expand Down
10 changes: 7 additions & 3 deletions test_runner/src/main/kotlin/ftl/json/MatrixMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ class MatrixMap(
var exitCode = 0

map.values.forEach { matrix ->
if (matrix.state != MatrixState.FINISHED) {
println("Error: Matrix not finished: ${matrix.matrixId} ${matrix.state}")
if (matrix.state != MatrixState.FINISHED) {
matrix.logError("not finished")
return 2
}
if (matrix.failed()) {
println("Error: Matrix failed: ${matrix.matrixId} ${matrix.state}")
matrix.logError("failed")
exitCode = 1
}
}

return exitCode
}

private fun SavedMatrix.logError(message: String) {
println("Error: Matrix $message: ${this.matrixId} ${this.state} ${this.webLink}")
}
}
13 changes: 2 additions & 11 deletions test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,14 @@ object ReportManager {
val useFlakyTests = args.flakyTestAttempts > 0
if (useFlakyTests) JUnitDedupe.modify(testSuite)

val testSuccessful = if (useFlakyTests) testSuite?.successful() ?: false else matrices.allSuccessful()

listOf(
CostReport,
MatrixResultsReport
).map {
it.run(matrices, testSuite, printToStdout = true, args = args)
}

if (!testSuccessful) {
if (!matrices.allSuccessful()) {
listOf(
HtmlErrorReport
).map { it.run(matrices, testSuite, printToStdout = false, args = args) }
Expand All @@ -115,14 +113,7 @@ object ReportManager {
JUnitReport.run(matrices, testSuite, printToStdout = false, args = args)
processJunitXml(testSuite, args, testShardChunks)

// FTL has a bug with matrix roll-up when using flakyTestAttempts
// as a work around, we calculate the success based on JUnit XML results.
val exitCode = if (useFlakyTests) {
if (testSuccessful) 0 else 1
} else {
matrices.exitCode()
}
return exitCode
return matrices.exitCode()
}

data class ShardEfficiency(
Expand Down

0 comments on commit cd8b77f

Please sign in to comment.