-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional-app-test-apks support #542
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8528c70
Parse additionalAppTestApks
bootstraponline 74021e9
Add additional-app-test-apks support
bootstraponline 2cb2f6c
Scope test shards to individual apks
bootstraponline 4b522cf
Set default dispatcher when using async
bootstraponline 672938c
Use default dispatcher when refreshing matrix
bootstraponline cc5be3b
Update TestRunner.kt
bootstraponline File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you thought of making
test
a list, so you don't have a bunch of usages withoutapp
?Something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prototyped adding list support, in particular this complicated the code when parsing from CLI.
I think for the first version of this feature, the more verbose format is easier to maintain. The test run loop also becomes more complex as we have yet another list to iterate through.
I'm open to revisiting this based on feedback in the future.