-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathDumpShards.kt
More file actions
45 lines (40 loc) · 1.18 KB
/
DumpShards.kt
File metadata and controls
45 lines (40 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package ftl.run
import ftl.args.AndroidArgs
import ftl.args.IosArgs
import ftl.run.common.prettyPrint
import ftl.run.model.AndroidMatrixTestShards
import ftl.run.platform.android.getAndroidMatrixShards
import ftl.util.FlankFatalError
import java.nio.file.Files
import java.nio.file.Paths
fun dumpShards(args: AndroidArgs) {
if (!args.isInstrumentationTest) throw FlankFatalError(
"Cannot dump shards for non instrumentation test, ensure test apk has been set."
)
val shards: AndroidMatrixTestShards = getAndroidMatrixShards(args)
saveShardChunks(
shardFilePath = ANDROID_SHARD_FILE,
shards = shards,
size = shards.size
)
}
fun dumpShards(args: IosArgs) {
saveShardChunks(
shardFilePath = IOS_SHARD_FILE,
shards = args.testShardChunks,
size = args.testShardChunks.size
)
}
private fun saveShardChunks(
shardFilePath: String,
shards: Any,
size: Int
) {
Files.write(
Paths.get(shardFilePath),
prettyPrint.toJson(shards).toByteArray()
)
println("Saved $size shards to $shardFilePath")
}
const val ANDROID_SHARD_FILE = "android_shards.json"
const val IOS_SHARD_FILE = "ios_shards.json"