-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional-app-test-apks support (#542)
* Parse additionalAppTestApks * Add additional-app-test-apks support * Scope test shards to individual apks * Set default dispatcher when using async * Use default dispatcher when refreshing matrix * Update TestRunner.kt
- Loading branch information
1 parent
42bfc7b
commit f9af5aa
Showing
29 changed files
with
367 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package ftl.args | ||
|
||
import com.linkedin.dex.parser.DexParser | ||
import com.linkedin.dex.parser.TestMethod | ||
import ftl.config.FtlConstants | ||
import ftl.filter.TestFilters | ||
import ftl.gc.GcStorage | ||
import ftl.util.Utils | ||
import kotlinx.coroutines.runBlocking | ||
|
||
object AndroidTestShard { | ||
|
||
// computed properties not specified in yaml | ||
fun getTestShardChunks(args: AndroidArgs, testApk: String): List<List<String>> { | ||
if (args.disableSharding) return listOf(emptyList()) | ||
|
||
// Download test APK if necessary so it can be used to validate test methods | ||
var testLocalApk = testApk | ||
if (testApk.startsWith(FtlConstants.GCS_PREFIX)) { | ||
runBlocking { | ||
testLocalApk = GcStorage.download(testApk) | ||
} | ||
} | ||
|
||
val filteredTests = getTestMethods(args, testLocalApk) | ||
return ArgsHelper.calculateShards(filteredTests, args) | ||
} | ||
|
||
private fun getTestMethods(args: AndroidArgs, testLocalApk: String): List<String> { | ||
val allTestMethods = DexParser.findTestMethods(testLocalApk) | ||
require(allTestMethods.isNotEmpty()) { Utils.fatalError("Test APK has no tests") } | ||
val testFilter = TestFilters.fromTestTargets(args.testTargets) | ||
val filteredTests = allTestMethods | ||
.asSequence() | ||
.distinct() | ||
.filter(testFilter.shouldRun) | ||
.map(TestMethod::testName) | ||
.map { "class $it" } | ||
.toList() | ||
require(FtlConstants.useMock || filteredTests.isNotEmpty()) { Utils.fatalError("All tests filtered out") } | ||
return filteredTests | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test_runner/src/main/kotlin/ftl/args/yml/AndroidFlankYml.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ftl.args.yml | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
data class AppTestPair( | ||
val app: String?, | ||
val test: String | ||
) | ||
|
||
/** Flank specific parameters for Android */ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class AndroidFlankYmlParams( | ||
@field:JsonProperty("additional-app-test-apks") | ||
val additionalAppTestApks: List<AppTestPair> = emptyList() | ||
) { | ||
companion object : IYmlKeys { | ||
override val keys = listOf("additional-app-test-apks") | ||
} | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class AndroidFlankYml( | ||
@field:JsonProperty("flank") | ||
private val parsedFlank: AndroidFlankYmlParams? = AndroidFlankYmlParams() | ||
) { | ||
val flank = parsedFlank ?: AndroidFlankYmlParams() | ||
|
||
companion object : IYmlMap { | ||
override val map = mapOf("flank" to AndroidFlankYmlParams.keys) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.