Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelpasterz authored and mergify-bot committed Jun 9, 2021
1 parent b725e9f commit 5f10825
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.google.testing.model.TestMatrix as GoogleTestMatrix

object GoogleTestMatrixAndroid :
TestMatrixAndroid.Execute,
(List<Pair<TestMatrixAndroid.Config, TestMatrixAndroid.Type>>) -> List<TestMatrix.Data> by { configTypePairs ->
(List<TestMatrixAndroid.TestSetup>) -> List<TestMatrix.Data> by { configTypePairs ->
runBlocking {
executeAndroidTests(configTypePairs).map(GoogleTestMatrix::toApiModel)
}
Expand Down
7 changes: 6 additions & 1 deletion test_runner/src/main/kotlin/ftl/api/TestAndroidMatrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ object TestMatrixAndroid {
) : Type()
}

interface Execute : (List<Pair<Config, Type>>) -> List<TestMatrix.Data>
data class TestSetup(
val config: Config,
val type: Type
)

interface Execute : (List<TestSetup>) -> List<TestMatrix.Data>
}

typealias ShardChunks = List<List<String>>
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope

suspend fun executeAndroidTests(
typeConfigPairs: List<Pair<TestMatrixAndroid.Config, TestMatrixAndroid.Type>>
): List<TestMatrix> = typeConfigPairs
.foldIndexed(emptyList<Deferred<TestMatrix>>()) { testMatrixTypeIndex, testMatrices, testPair ->
testMatrices + executeAndroidTestMatrix(testPair.second, testMatrixTypeIndex, testPair.first)
testSetups: List<TestMatrixAndroid.TestSetup>
): List<TestMatrix> = testSetups
.foldIndexed(emptyList<Deferred<TestMatrix>>()) { testMatrixTypeIndex, testMatrices, setUp ->
testMatrices + executeAndroidTestMatrix(setUp.type, testMatrixTypeIndex, setUp.config)
}.awaitAll()

private suspend fun executeAndroidTestMatrix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ftl.run.platform
import flank.common.join
import flank.common.logLn
import ftl.api.RemoteStorage
import ftl.api.TestMatrixAndroid
import ftl.api.executeTestMatrixAndroid
import ftl.api.uploadToRemoteStorage
import ftl.args.AndroidArgs
Expand Down Expand Up @@ -45,7 +46,7 @@ internal suspend fun AndroidArgs.runAndroidTests(): TestResult = coroutineScope
allTestShardChunks += context.shards
}
}
.map { context -> createAndroidTestConfig(context.args) to createAndroidTestMatrixType(context) }
.map { createTestSetup(it) }
.run { executeTestMatrixAndroid(this) }
.takeIf { it.isNotEmpty() }
?: throw FlankGeneralError("There are no Android tests to run.")
Expand Down Expand Up @@ -83,3 +84,8 @@ private fun AndroidMatrixTestShards.saveShards(config: AndroidArgs) = saveShardC
size = size,
obfuscatedOutput = config.obfuscateDumpShards
)

private suspend fun createTestSetup(context: AndroidTestContext) = TestMatrixAndroid.TestSetup(
config = createAndroidTestConfig(context.args),
type = context.args.createAndroidTestMatrixType(context)
)
7 changes: 4 additions & 3 deletions test_runner/src/test/kotlin/ftl/gc/GcAndroidTestMatrixTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ftl.gc

import com.google.testing.model.TestSetup
import ftl.api.TestMatrixAndroid
import ftl.api.TestMatrixAndroid.Type
import ftl.args.AndroidArgs
import ftl.client.google.run.android.executeAndroidTests
Expand Down Expand Up @@ -49,7 +50,7 @@ class GcAndroidTestMatrixTest {
)
val config = createAndroidTestConfig(androidArgs)

executeAndroidTests(listOf(config to type))
executeAndroidTests(listOf(TestMatrixAndroid.TestSetup(config, type)))
}
}

Expand Down Expand Up @@ -78,7 +79,7 @@ class GcAndroidTestMatrixTest {

val config = createAndroidTestConfig(androidArgs)

executeAndroidTests(listOf(config to type))
executeAndroidTests(listOf(TestMatrixAndroid.TestSetup(config, type)))
}
}

Expand Down Expand Up @@ -112,7 +113,7 @@ class GcAndroidTestMatrixTest {

val config = createAndroidTestConfig(androidArgs)

executeAndroidTests(listOf(config to type))
executeAndroidTests(listOf(TestMatrixAndroid.TestSetup(config, type)))
}
}

Expand Down

0 comments on commit 5f10825

Please sign in to comment.