From 10b90204f413993bb834e0bc9fd3dd047aa643cf Mon Sep 17 00:00:00 2001 From: kevalpatel2106 Date: Fri, 10 Mar 2023 17:34:40 +0000 Subject: [PATCH] Exporting the test failure reason in VDTESTING_FAILURE_REASON --- README.md | 1 + main.go | 18 +++++++++++++----- step.yml | 7 ++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index be02c59..ff5c5ce 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris | Environment Variable | Description | | --- | --- | | `VDTESTING_DOWNLOADED_FILES_DIR` | The directory containing the downloaded files if you have set `directories_to_pull` and `download_test_results` inputs above. | +| `VDTESTING_FAILURE_REASON` | A string containing the outcome and if the test failed. This can be any of these possible values: Crashed, NotInstalled, OtherNativeCrash, TimedOut, UnableToCrawl. Default value None if unable to triage the failure result. | ## 🙋 Contributing diff --git a/main.go b/main.go index 3ff2912..8dd882a 100755 --- a/main.go +++ b/main.go @@ -149,23 +149,31 @@ func main() { outcome = colorstring.Green(outcome) case "failure": successful = false + failureReason := "None" + if step.Outcome.FailureDetail != nil { if step.Outcome.FailureDetail.Crashed { - outcome += "(Crashed)" + failureReason = "Crashed" } if step.Outcome.FailureDetail.NotInstalled { - outcome += "(NotInstalled)" + failureReason = "NotInstalled" } if step.Outcome.FailureDetail.OtherNativeCrash { - outcome += "(OtherNativeCrash)" + failureReason = "OtherNativeCrash" } if step.Outcome.FailureDetail.TimedOut { - outcome += "(TimedOut)" + failureReason = "TimedOut" } if step.Outcome.FailureDetail.UnableToCrawl { - outcome += "(UnableToCrawl)" + failureReason = "UnableToCrawl" } + outcome += "(" + failureReason + ")" + } + + if err := tools.ExportEnvironmentWithEnvman("VDTESTING_FAILURE_REASON", outcome); err != nil { + log.Warnf("Failed to export environment (VDTESTING_FAILURE_REASON), error: %s", err) } + outcome = colorstring.Red(outcome) case "inconclusive": successful = false diff --git a/step.yml b/step.yml index 2d2e789..f3c3082 100755 --- a/step.yml +++ b/step.yml @@ -437,4 +437,9 @@ outputs: opts: title: "Downloaded files directory" description: "The directory containing the downloaded files if you have set `directories_to_pull` and `download_test_results` inputs above." - summary: "The directory containing the downloaded files if you have set `directories_to_pull` and `download_test_results` inputs above." \ No newline at end of file + summary: "The directory containing the downloaded files if you have set `directories_to_pull` and `download_test_results` inputs above." - VDTESTING_DOWNLOADED_FILES_DIR: + - VDTESTING_FAILURE_REASON: + opts: + title: "Failure reason for the UI tests" + description: "A string containing the outcome and if the test failed." + summary: "A string containing the outcome and if the test failed. This can be any of these possible values: Crashed, NotInstalled, OtherNativeCrash, TimedOut, UnableToCrawl. Default value None if unable to triage the failure result." \ No newline at end of file