Skip to content

Commit

Permalink
Add typealias
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelpasterz authored and mergify-bot committed Apr 8, 2021
1 parent 82b0074 commit c8aa7bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/feature/1665-custom-sharding.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ You can now start a flank test run. With the updated config there will still be

## iOS

iOS custom sharding works exactly the same as Android (dump shards, modify, add a path to JSON file, etc) same with small exceptions:
iOS custom sharding works exactly the same as Android (dump shards, modify, add a path to JSON file, etc) with some small exceptions:

* there is no `additional-app-test-apks` feature for iOS
* every shard in iOS is a separate matrix (FTL limitations)
* dump shard JSON is different for xctestrun with test plans and not, therefore there is different custom sharding JSON
* dump shard JSON is different for xctestrun with test plans, therefore there is different custom sharding JSON
structure for both versions.

#### Custom sharding JSON for xctestrun without Test Plans (example)
Expand Down
8 changes: 5 additions & 3 deletions test_runner/src/main/kotlin/ftl/util/ObfuscationGson.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import com.google.gson.JsonSerializer
import com.google.gson.reflect.TypeToken
import java.lang.reflect.Type

private typealias CustomShardChunks = List<Map<String, List<String>>>

val obfuscatePrettyPrinter = GsonBuilder()
.registerTypeHierarchyAdapter(ListOfStringListTypeToken.rawType, ObfuscatedIosJsonSerializer)
.registerTypeAdapter(ListOfStringTypeToken.rawType, ObfuscatedAndroidJsonSerializer)
Expand All @@ -19,7 +21,7 @@ val obfuscatePrettyPrinter = GsonBuilder()
internal object ListOfStringTypeToken : TypeToken<List<String>>()

@VisibleForTesting
internal object ListOfStringListTypeToken : TypeToken<List<Map<String, List<String>>>>()
internal object ListOfStringListTypeToken : TypeToken<CustomShardChunks>()

private object ObfuscatedAndroidJsonSerializer : JsonSerializer<List<String>> {
private val obfuscationContext by lazy { mutableMapOf<String, MutableMap<String, String>>() }
Expand All @@ -36,11 +38,11 @@ private object ObfuscatedAndroidJsonSerializer : JsonSerializer<List<String>> {
}
}

private object ObfuscatedIosJsonSerializer : JsonSerializer<List<Map<String, List<String>>>> {
private object ObfuscatedIosJsonSerializer : JsonSerializer<CustomShardChunks> {
private val obfuscationContext by lazy { mutableMapOf<String, MutableMap<String, String>>() }

override fun serialize(
src: List<Map<String, List<String>>>,
src: CustomShardChunks,
typeOfSrc: Type,
context: JsonSerializationContext
) = JsonArray().also { jsonArray ->
Expand Down

0 comments on commit c8aa7bd

Please sign in to comment.