Skip to content

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Nov 16, 2018
1 parent beb95a8 commit cc1f92b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
7 changes: 2 additions & 5 deletions test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down
11 changes: 9 additions & 2 deletions test_runner/src/main/kotlin/ftl/gc/GcStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit cc1f92b

Please sign in to comment.