Skip to content

Commit

Permalink
Update kotlin to v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelpasterz committed Aug 19, 2020
1 parent b49d09f commit cbd2f3a
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 46 deletions.
6 changes: 3 additions & 3 deletions test_runner/buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ object Versions {
const val DEX_TEST_PARSER = "2.2.1"

// match to Tools -> Kotlin -> Configure Kotlin Plugin Updates -> Update Channel: Stable
const val KOTLIN = "1.3.72"
const val KOTLIN = "1.4.0"

// https://github.com/Kotlin/kotlinx.coroutines/releases
const val KOTLIN_COROUTINES = "1.3.7"
const val KOTLIN_COROUTINES = "1.3.9"

// https://github.com/remkop/picocli/releases
const val PICOCLI = "4.4.0"
Expand Down Expand Up @@ -53,7 +53,7 @@ object Versions {
const val JSOUP = "1.13.1"

// https://github.com/ktorio/ktor/releases
const val KTOR = "1.3.2"
const val KTOR = "1.4.0"

// https://github.com/qos-ch/logback/releases
const val LOGBACK = "1.2.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ object ConfigurationErrorMessageBuilder {
try {
val errorModel = parseMessage(errorMessage)
val errorMessageBuilder = StringBuilder(messageHeader)
errorMessageBuilder.appendln(createReferenceChain(errorModel.referenceChain))
errorMessageBuilder.appendLine(createReferenceChain(errorModel.referenceChain))
if (errorModel.propertyName != "") {
errorMessageBuilder.appendln(missingElementMessage.format(errorModel.propertyName))
errorMessageBuilder.appendLine(missingElementMessage.format(errorModel.propertyName))
}
errorMessageBuilder.appendln(atMessage.format(errorModel.line, errorModel.column))
errorMessageBuilder.appendLine(atMessage.format(errorModel.line, errorModel.column))
yamlTreeNode?.let {
errorMessageBuilder.appendln(errorNodeMessage.format(resolveErrorNode(yamlTreeNode, errorModel)))
errorMessageBuilder.appendLine(errorNodeMessage.format(resolveErrorNode(yamlTreeNode, errorModel)))
}
errorMessageBuilder.toString().trim()
} catch (error: Exception) {
Expand All @@ -40,9 +40,9 @@ object ConfigurationErrorMessageBuilder {
operator fun invoke(yamlException: MarkedYAMLException): String {
val problemMark = yamlException.problemMark
return StringBuilder(messageHeader + yamlException.problem).apply {
appendln()
appendln(atMessage.format(problemMark.line, problemMark.column))
appendln(errorNodeMessage.format(System.lineSeparator() + problemMark._snippet))
appendLine()
appendLine(atMessage.format(problemMark.line, problemMark.column))
appendLine(errorNodeMessage.format(System.lineSeparator() + problemMark._snippet))
}.toString().trim()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ private fun Locale.prepareDescription() = """
""".trimIndent().addRegionIfExist(region).addTagsIfExists(this)

private fun String.addRegionIfExist(region: String?) =
if (!region.isNullOrEmpty()) StringBuilder(this).appendln("\nregion: $region").trim().toString()
if (!region.isNullOrEmpty()) StringBuilder(this).appendLine("\nregion: $region").trim().toString()
else this

private fun String.addTagsIfExists(locale: Locale) =
if (!locale.tags.isNullOrEmpty()) StringBuilder(this).appendln("\ntags:").appendTagsToList(locale)
if (!locale.tags.isNullOrEmpty()) StringBuilder(this).appendLine("\ntags:").appendTagsToList(locale)
else this

private fun StringBuilder.appendTagsToList(locale: Locale) = apply {
locale.tags.filterNotNull().forEach { tag -> appendln("- $tag") }
locale.tags.filterNotNull().forEach { tag -> appendLine("- $tag") }
}.trim().toString()

private fun String?.orErrorMessage(locale: String) = this ?: throw FlankGeneralError("ERROR: '$locale' is not a valid locale")
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ private fun AndroidModel.prepareDescription() = """
.appendThumbnail(thumbnailUrl).trim()

private fun String.appendList(header: String, items: List<String>?) =
if (!items.isNullOrEmpty()) StringBuilder(this).appendln().appendln(header).appendItems(items).toString().trim()
if (!items.isNullOrEmpty()) StringBuilder(this).appendLine().appendLine(header).appendItems(items).toString().trim()
else this

private fun StringBuilder.appendItems(items: List<String>) = apply {
items.forEach { appendln("- $it") }
items.forEach { appendLine("- $it") }
}

private fun String.appendThumbnail(thumbnailUrl: String?) =
if (!thumbnailUrl.isNullOrBlank()) StringBuilder(this).appendln("\n$THUBNAIL_URL_HEADER $thumbnailUrl").toString()
if (!thumbnailUrl.isNullOrBlank()) StringBuilder(this).appendLine("\n$THUBNAIL_URL_HEADER $thumbnailUrl").toString()
else this

private fun String?.orErrorMessage(modelId: String) = this ?: throw FlankGeneralError("ERROR: '$modelId' is not a valid model")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ private fun AndroidVersion.prepareDescription() = """
year: ${releaseDate.year}
""".trimIndent().addDataIfExists(tags).addVersion(versionString).trim()

private fun String.addVersion(versionString: String) = StringBuilder(this).appendln("\nversionString: $versionString").toString()
private fun String.addVersion(versionString: String) = StringBuilder(this).appendLine("\nversionString: $versionString")
.toString()

private fun String.addDataIfExists(data: List<String?>?) =
if (!data.isNullOrEmpty()) StringBuilder(this).appendln("\n$TAGS_HEADER:").appendDataToList(data)
if (!data.isNullOrEmpty()) StringBuilder(this).appendLine("\n$TAGS_HEADER:").appendDataToList(data)
else this

private fun StringBuilder.appendDataToList(data: List<String?>) = apply {
data.filterNotNull().forEach { item -> appendln("- $item") }
data.filterNotNull().forEach { item -> appendLine("- $item") }
}.toString().trim()

private fun String?.orErrorMessage(versionId: String) = this ?: throw FlankGeneralError("ERROR: '$versionId' is not a valid OS version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ private fun IosModel.prepareDescription() = "".appendList(DEVICE_CAPABILITIES_HE
.appendModelBasicData(this).appendList(SUPPORTED_VERSIONS_HEADER, supportedVersionIds).appendList(TAGS_HEADER, tags).trim()

private fun String.appendList(header: String, items: List<String>?) =
if (!items.isNullOrEmpty()) StringBuilder(this).appendln(header).appendItems(items).toString()
if (!items.isNullOrEmpty()) StringBuilder(this).appendLine(header).appendItems(items).toString()
else this

private fun StringBuilder.appendItems(items: List<String>) = apply {
items.forEach { appendln("- $it") }
items.forEach { appendLine("- $it") }
}

private fun String.appendModelBasicData(model: IosModel) = StringBuilder(this).appendln(
private fun String.appendModelBasicData(model: IosModel) = StringBuilder(this).appendLine(
"""
formFactor: ${model.formFactor}
id: ${model.id}
name: ${model.name}
screenDensity: ${model.screenDensity}
screenX: ${model.screenX}
screenY: ${model.screenY}
formFactor: ${model.formFactor}
id: ${model.id}
name: ${model.name}
screenDensity: ${model.screenDensity}
screenX: ${model.screenX}
screenY: ${model.screenY}
""".trimIndent()
).toString()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ private fun IosVersion.prepareDescription() = """
""".trimIndent().addDataIfExists(SUPPORTED_VERSIONS_HEADER, supportedXcodeVersionIds).addDataIfExists(TAGS_HEADER, tags)

private fun String.addDataIfExists(header: String, data: List<String?>?) =
if (!data.isNullOrEmpty()) StringBuilder(this).appendln("\n$header:").appendDataToList(data)
if (!data.isNullOrEmpty()) StringBuilder(this).appendLine("\n$header:").appendDataToList(data)
else this

private fun StringBuilder.appendDataToList(data: List<String?>) = apply {
data.filterNotNull().forEach { item -> appendln("- $item") }
data.filterNotNull().forEach { item -> appendLine("- $item") }
}.toString().trim()

private fun String?.orErrorMessage(versionId: String) = this ?: throw FlankGeneralError("ERROR: '$versionId' is not a valid OS version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ private suspend fun getAsync(toolResultsStep: ToolResultsStep) = coroutineScope
// This one is a little bit lower but close as possible. The difference is around ~3 seconds.
private fun List<TestCase>.getStartTimestamp(): Timestamp = this
.mapNotNull { it.startTime }
.minBy { it.asUnixTimestamp() }
.minByOrNull { it.asUnixTimestamp() }
?: Timestamp()
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun List<Environment>.createMatrixOutcomeSummaryUsingEnvironments(
testDetails = testDetails ?: "Unknown outcome"
)

private fun List<Environment>.getOutcomeFromEnvironments(): Outcome? = maxBy {
private fun List<Environment>.getOutcomeFromEnvironments(): Outcome? = maxByOrNull {
StepOutcome.order.indexOf(it.environmentResult?.outcome?.summary)
}?.environmentResult?.outcome

Expand All @@ -36,6 +36,6 @@ fun List<Step>.createMatrixOutcomeSummaryUsingSteps(
testDetails = testDetails ?: "Unknown outcome"
)

private fun List<Step>.getOutcomeFromSteps(): Outcome? = maxBy {
private fun List<Step>.getOutcomeFromSteps(): Outcome? = maxByOrNull {
StepOutcome.order.indexOf(it.outcome?.summary)
}?.outcome
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ internal fun IArgs.getLastGcsPath(): String? = Paths

private fun Array<File>.getLastModifiedDirectory(): File? = this
.filter(File::isDirectory)
.maxBy(File::lastModified)
.maxByOrNull(File::lastModified)
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ internal fun beforeRunMessage(args: IArgs, testShardChunks: ShardChunks): String
val testsCount = testShardChunks.sumBy { it.size }

val result = StringBuilder()
result.appendln(
" $testsCount test${s(testsCount)} / $shardCount shard${s(
shardCount
)}"
result.appendLine(
" $testsCount test${s(testsCount)} / $shardCount shard${s(shardCount)}"
)

if (runCount > 1) {
result.appendln(" Running ${runCount}x")
result.appendLine(" Running ${runCount}x")
val runDevices = runCount * shardCount
val runTests = runCount * testsCount
result.appendln(" $runDevices total shard${s(runDevices)}")
result.appendln(" $runTests total test${s(runTests)}")
result.appendLine(" $runDevices total shard${s(runDevices)}")
result.appendLine(" $runTests total test${s(runTests)}")
}

return result.toString()
Expand Down
10 changes: 5 additions & 5 deletions test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class TableColumn(
val header: String,
val data: List<String>,
val dataColor: List<SystemOutColor> = listOf(),
val columnSize: Int = ((data + header).maxBy { it.length }?.length ?: 0) + DEFAULT_COLUMN_PADDING
val columnSize: Int = ((data + header).maxByOrNull { it.length }?.length ?: 0) + DEFAULT_COLUMN_PADDING
)

private data class DataWithSize(
Expand Down Expand Up @@ -78,7 +78,7 @@ private fun StringBuilder.startTable(rowSizes: List<Int>) {
endChar = START_TABLE_END_CHAR,
rowSizes = rowSizes
)
appendln()
appendLine()
}

private fun StringBuilder.rowSeparator(rowSizes: List<Int>) {
Expand All @@ -88,11 +88,11 @@ private fun StringBuilder.rowSeparator(rowSizes: List<Int>) {
endChar = MIDDLE_TABLE_END_CHAR,
rowSizes = rowSizes
)
appendln()
appendLine()
}

private fun StringBuilder.appendData(tableColumns: Array<out TableColumn>, rowSizes: List<Int>, tableStyle: TableStyle) {
val rowCount = (tableColumns.maxBy { it.data.size } ?: tableColumns.first()).data.size
val rowCount = (tableColumns.maxByOrNull { it.data.size } ?: tableColumns.first()).data.size
(0 until rowCount)
.map { rowNumber ->
tableColumns.map {
Expand Down Expand Up @@ -133,7 +133,7 @@ private fun StringBuilder.appendDataRow(data: List<DataWithSize>) {
if (it.centered) append(it.center()) else append(it.leftAligned())
append(TABLE_VERTICAL_LINE)
}
appendln()
appendLine()
}

private fun DataWithSize.leftAligned() = String.format("%-${columnSize}s", " $data")
Expand Down

0 comments on commit cbd2f3a

Please sign in to comment.