From cc1f92b60efc0fab49d7ed0ff44be3ef33ae438d Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Fri, 16 Nov 2018 15:03:15 -0500 Subject: [PATCH] Fix crash --- test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt | 7 ++----- test_runner/src/main/kotlin/ftl/gc/GcStorage.kt | 11 +++++++++-- .../src/main/kotlin/ftl/reports/util/ReportManager.kt | 4 +--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt b/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt index db69e78a06..f4b31b6c37 100644 --- a/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt @@ -10,10 +10,10 @@ import ftl.android.UnsupportedVersionId import ftl.args.ArgsHelper.assertFileExists import ftl.args.ArgsHelper.assertGcsFileExists import ftl.args.ArgsHelper.calculateShards -import ftl.args.ArgsHelper.evaluateFilePath import ftl.args.ArgsHelper.convertShards import ftl.args.ArgsHelper.createGcsBucket import ftl.args.ArgsHelper.createJunitBucket +import ftl.args.ArgsHelper.evaluateFilePath import ftl.args.ArgsHelper.mergeYmlMaps import ftl.args.ArgsHelper.yamlMapper import ftl.args.ArgsToString.devicesToString @@ -29,7 +29,6 @@ import ftl.config.FtlConstants.useMock import ftl.filter.TestFilters import ftl.gc.GcStorage import ftl.reports.xml.model.JUnitTestResult -import ftl.reports.xml.parseIosXml import ftl.shard.Shard import ftl.util.Utils import kotlinx.coroutines.runBlocking @@ -84,9 +83,7 @@ class AndroidArgs( val filteredTests = getTestMethods(testLocalApk) if (true) { - - val oldXmlPath = GcStorage.downloadJunitXml(this) - val oldTestResult = if (oldXmlPath.isNotEmpty()) parseIosXml(oldXmlPath) else JUnitTestResult(mutableListOf()) + val oldTestResult = GcStorage.downloadJunitXml(this) ?: JUnitTestResult(mutableListOf()) val start = System.nanoTime() val result = convertShards(Shard.calculateShardsByTime(filteredTests, oldTestResult, testShards)) diff --git a/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt b/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt index ec9924ccdf..08b939cb33 100644 --- a/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt +++ b/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt @@ -10,6 +10,7 @@ import ftl.args.IosArgs import ftl.config.FtlConstants import ftl.config.FtlConstants.GCS_PREFIX import ftl.reports.xml.model.JUnitTestResult +import ftl.reports.xml.parseIosXml import ftl.reports.xml.xmlToString import ftl.util.Utils.fatalError import ftl.util.Utils.join @@ -81,8 +82,14 @@ object GcStorage { download(args.testApk) // junit xml may not exist. ignore error if it doesn't exist - fun downloadJunitXml(args: IArgs): String = - download(args.junitGcsPath, ignoreError = true) + fun downloadJunitXml(args: IArgs): JUnitTestResult? { + val oldXmlPath = download(args.junitGcsPath, ignoreError = true) + if (oldXmlPath.isNotEmpty()) { + return parseIosXml(Paths.get(oldXmlPath)) + } + + return null + } private fun upload(file: String, fileBytes: ByteArray, rootGcsBucket: String, runGcsPath: String): String { val fileName = Paths.get(file).fileName.toString() diff --git a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt index cdf05f378c..3db6dfb96b 100644 --- a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt +++ b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt @@ -11,7 +11,6 @@ import ftl.reports.MatrixResultsReport import ftl.reports.xml.model.JUnitTestResult import ftl.reports.xml.parseAndroidXml import ftl.reports.xml.parseIosXml -import ftl.reports.xml.xmlToString import ftl.util.ArtifactRegex import ftl.util.resolveLocalRunPath import java.io.File @@ -100,8 +99,7 @@ object ReportManager { private fun processJunitXml(newTestResult: JUnitTestResult?, args: IArgs) { if (newTestResult == null) return - val oldXmlPath = GcStorage.downloadJunitXml(args) - val oldTestResult = if (oldXmlPath.isNotEmpty()) parseIosXml(oldXmlPath) else null + val oldTestResult = GcStorage.downloadJunitXml(args) newTestResult.mergeTestTimes(oldTestResult)