Skip to content

Commit

Permalink
#829 Fixed flaky outcome
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Adamczyk committed Jun 29, 2020
1 parent bae8463 commit 2f2be85
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
22 changes: 16 additions & 6 deletions test_runner/src/main/kotlin/ftl/json/SavedMatrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ftl.reports.api.prepareForJUnitResult
import ftl.util.Billing
import ftl.util.MatrixState.FINISHED
import ftl.util.StepOutcome.failure
import ftl.util.StepOutcome.flaky
import ftl.util.StepOutcome.inconclusive
import ftl.util.StepOutcome.skipped
import ftl.util.StepOutcome.success
Expand Down Expand Up @@ -96,6 +97,7 @@ class SavedMatrix(matrix: TestMatrix) {
.forEach {
updatedFinishedInfo(
stepOutcome = GcToolResults.getExecutionResult(it.testExecution).outcome,
flakyOutcome = GcToolResults.getExecutionResult(it.testExecution).outcome.summary != it.step.outcome.summary,
testSuiteOverviewData = summedTestSuiteOverviewData,
isRoboTests = it.testExecution.testSpecification.androidRoboTest != null,
isVirtualDevice = isVirtualDevice(
Expand All @@ -110,21 +112,29 @@ class SavedMatrix(matrix: TestMatrix) {

private fun updatedFinishedInfo(
stepOutcome: Outcome?,
flakyOutcome: Boolean,
testSuiteOverviewData: TestSuiteOverviewData?,
isRoboTests: Boolean,
isVirtualDevice: Boolean,
billableMinutes: Long?
) {
updateOutcome(stepOutcome)
updateOutcome(stepOutcome, flakyOutcome)
updateOutcomeDetails(stepOutcome, testSuiteOverviewData, isRoboTests)
billableMinutes?.let { updateBillableMinutes(it, isVirtualDevice) }
}

private fun updateOutcome(stepOutcome: Outcome?) {
// the matrix outcome is failure if any step fails
// if the matrix outcome is already set to failure then we can ignore the other step outcomes.
// inconclusive is treated as a failure
if (outcome != failure && outcome != inconclusive) outcome = stepOutcome?.summary ?: outcome
private fun updateOutcome(
stepOutcome: Outcome?,
flakyOutcome: Boolean
) {
outcome = when {
// the matrix outcome is failure if any step fails
// if the matrix outcome is already set to failure then we can ignore the other step outcomes.
// inconclusive is treated as a failure
outcome == failure || outcome == inconclusive -> return
flakyOutcome -> flaky
else -> stepOutcome?.summary ?: outcome
}
}

private fun updateOutcomeDetails(
Expand Down
2 changes: 2 additions & 0 deletions test_runner/src/main/kotlin/ftl/util/SavedMatrixTableUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ftl.util

import ftl.json.SavedMatrix
import ftl.util.StepOutcome.failure
import ftl.util.StepOutcome.flaky
import ftl.util.StepOutcome.success

fun SavedMatrix.asPrintableTable(): String = listOf(this).asPrintableTable()
Expand All @@ -17,6 +18,7 @@ private fun getOutcomeColor(outcome: String): SystemOutColor {
return when (outcome) {
failure -> SystemOutColor.RED
success -> SystemOutColor.GREEN
flaky -> SystemOutColor.BLUE
else -> SystemOutColor.DEFAULT
}
}
Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/util/SystemOutColor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ftl.util
enum class SystemOutColor(val ansiCode: String) {
DEFAULT("\u001B[0m"),
RED("\u001B[31m"),
BLUE("\u001B[34m"),
GREEN("\u001B[32m");

fun applyTo(value: String) = ansiCode + value + DEFAULT.ansiCode
Expand Down

0 comments on commit 2f2be85

Please sign in to comment.