forked from PaulWoitaschek/Voice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_screenshots.main.kts
executable file
·47 lines (43 loc) · 1.43 KB
/
update_screenshots.main.kts
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
46
47
#!/usr/bin/env kotlin
import java.io.File
fun runCommand(vararg command: String) {
println("runCommand=${command.toList()}")
val process = ProcessBuilder(command.toList())
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.start()
process.waitFor().also {
check(it == 0) {
"output=${process.errorStream.bufferedReader().readText()}"
}
}
}
// https://issuetracker.google.com/issues/193118030
runCommand("./gradlew", ":app:packageDebugAndroidTest")
runCommand(
"./gradlew",
":app:screenshotDevicesGroupDebugAndroidTest",
"-Pandroid.testInstrumentationRunnerArguments.class=voice.app.misc.ScreenshotCapture",
"-Dorg.gradle.workers.max=1",
)
val deviceMapping = mapOf(
"pixel5" to "phone",
"nexus7" to "tablet",
"nexus10" to "large-tablet",
).flatMap { (device, qualifier) ->
val deviceOutput = File("app/build/outputs/managed_device_android_test_additional_output", device)
listOf(
"book_overview_grid",
"book_overview_list",
"settings",
"folder_picker",
).mapIndexed { index, screenshotName ->
val sourceFile = File(deviceOutput, "$screenshotName.png")
val qualifierFolder = File("app/src/main/play/listings/en-US/graphics", "$qualifier-screenshots")
val targetFile = File(qualifierFolder, "${index + 1}.png")
sourceFile to targetFile
}
}
.forEach { (sourceFile, targetFile) ->
println("copy $sourceFile to $targetFile")
sourceFile.copyTo(targetFile, overwrite = true)
}