diff --git a/test_runner/buildSrc/src/main/kotlin/Deps.kt b/test_runner/buildSrc/src/main/kotlin/Deps.kt index 68cd264cb1..fc5223b3d5 100644 --- a/test_runner/buildSrc/src/main/kotlin/Deps.kt +++ b/test_runner/buildSrc/src/main/kotlin/Deps.kt @@ -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" @@ -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" diff --git a/test_runner/src/main/kotlin/ftl/args/yml/errors/ConfigurationErrorMessageBuilder.kt b/test_runner/src/main/kotlin/ftl/args/yml/errors/ConfigurationErrorMessageBuilder.kt index bae86851d6..c974abfd70 100644 --- a/test_runner/src/main/kotlin/ftl/args/yml/errors/ConfigurationErrorMessageBuilder.kt +++ b/test_runner/src/main/kotlin/ftl/args/yml/errors/ConfigurationErrorMessageBuilder.kt @@ -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) { @@ -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() } diff --git a/test_runner/src/main/kotlin/ftl/environment/LocalesDescription.kt b/test_runner/src/main/kotlin/ftl/environment/LocalesDescription.kt index b26c704fbd..dec88999d0 100644 --- a/test_runner/src/main/kotlin/ftl/environment/LocalesDescription.kt +++ b/test_runner/src/main/kotlin/ftl/environment/LocalesDescription.kt @@ -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") diff --git a/test_runner/src/main/kotlin/ftl/environment/android/AndroidModelDescription.kt b/test_runner/src/main/kotlin/ftl/environment/android/AndroidModelDescription.kt index 17dbdfaf4b..fd2ece6d06 100644 --- a/test_runner/src/main/kotlin/ftl/environment/android/AndroidModelDescription.kt +++ b/test_runner/src/main/kotlin/ftl/environment/android/AndroidModelDescription.kt @@ -25,15 +25,15 @@ private fun AndroidModel.prepareDescription() = """ .appendThumbnail(thumbnailUrl).trim() private fun String.appendList(header: String, items: List?) = - 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) = 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") diff --git a/test_runner/src/main/kotlin/ftl/environment/android/AndroidSoftwareVersionDescription.kt b/test_runner/src/main/kotlin/ftl/environment/android/AndroidSoftwareVersionDescription.kt index 1b09e4f87d..6317628e62 100644 --- a/test_runner/src/main/kotlin/ftl/environment/android/AndroidSoftwareVersionDescription.kt +++ b/test_runner/src/main/kotlin/ftl/environment/android/AndroidSoftwareVersionDescription.kt @@ -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?) = - 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) = 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") diff --git a/test_runner/src/main/kotlin/ftl/environment/ios/IosModelDescription.kt b/test_runner/src/main/kotlin/ftl/environment/ios/IosModelDescription.kt index 4ccbcf9257..b0b2f88869 100644 --- a/test_runner/src/main/kotlin/ftl/environment/ios/IosModelDescription.kt +++ b/test_runner/src/main/kotlin/ftl/environment/ios/IosModelDescription.kt @@ -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?) = - 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) = 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() diff --git a/test_runner/src/main/kotlin/ftl/environment/ios/IosSoftwareVersionDescription.kt b/test_runner/src/main/kotlin/ftl/environment/ios/IosSoftwareVersionDescription.kt index 52886c6c56..507597c54b 100644 --- a/test_runner/src/main/kotlin/ftl/environment/ios/IosSoftwareVersionDescription.kt +++ b/test_runner/src/main/kotlin/ftl/environment/ios/IosSoftwareVersionDescription.kt @@ -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?) = - 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) = 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") diff --git a/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt b/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt index 156f854d2d..ce10445902 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt @@ -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.getStartTimestamp(): Timestamp = this .mapNotNull { it.startTime } - .minBy { it.asUnixTimestamp() } + .minByOrNull { it.asUnixTimestamp() } ?: Timestamp() diff --git a/test_runner/src/main/kotlin/ftl/reports/outcome/TestOutcome.kt b/test_runner/src/main/kotlin/ftl/reports/outcome/TestOutcome.kt index d064a16e28..691a467677 100644 --- a/test_runner/src/main/kotlin/ftl/reports/outcome/TestOutcome.kt +++ b/test_runner/src/main/kotlin/ftl/reports/outcome/TestOutcome.kt @@ -22,7 +22,7 @@ fun List.createMatrixOutcomeSummaryUsingEnvironments( testDetails = testDetails ?: "Unknown outcome" ) -private fun List.getOutcomeFromEnvironments(): Outcome? = maxBy { +private fun List.getOutcomeFromEnvironments(): Outcome? = maxByOrNull { StepOutcome.order.indexOf(it.environmentResult?.outcome?.summary) }?.environmentResult?.outcome @@ -36,6 +36,6 @@ fun List.createMatrixOutcomeSummaryUsingSteps( testDetails = testDetails ?: "Unknown outcome" ) -private fun List.getOutcomeFromSteps(): Outcome? = maxBy { +private fun List.getOutcomeFromSteps(): Outcome? = maxByOrNull { StepOutcome.order.indexOf(it.outcome?.summary) }?.outcome diff --git a/test_runner/src/main/kotlin/ftl/run/common/GetLastGcsPath.kt b/test_runner/src/main/kotlin/ftl/run/common/GetLastGcsPath.kt index 8ba9a4e1bd..17bd2f8a8e 100644 --- a/test_runner/src/main/kotlin/ftl/run/common/GetLastGcsPath.kt +++ b/test_runner/src/main/kotlin/ftl/run/common/GetLastGcsPath.kt @@ -13,4 +13,4 @@ internal fun IArgs.getLastGcsPath(): String? = Paths private fun Array.getLastModifiedDirectory(): File? = this .filter(File::isDirectory) - .maxBy(File::lastModified) + .maxByOrNull(File::lastModified) diff --git a/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunMessage.kt b/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunMessage.kt index 6b71befb30..353df5a562 100644 --- a/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunMessage.kt +++ b/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunMessage.kt @@ -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() diff --git a/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt b/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt index 8744708be0..3fa0670a7c 100644 --- a/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt +++ b/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt @@ -11,7 +11,7 @@ data class TableColumn( val header: String, val data: List, val dataColor: List = 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( @@ -78,7 +78,7 @@ private fun StringBuilder.startTable(rowSizes: List) { endChar = START_TABLE_END_CHAR, rowSizes = rowSizes ) - appendln() + appendLine() } private fun StringBuilder.rowSeparator(rowSizes: List) { @@ -88,11 +88,11 @@ private fun StringBuilder.rowSeparator(rowSizes: List) { endChar = MIDDLE_TABLE_END_CHAR, rowSizes = rowSizes ) - appendln() + appendLine() } private fun StringBuilder.appendData(tableColumns: Array, rowSizes: List, 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 { @@ -133,7 +133,7 @@ private fun StringBuilder.appendDataRow(data: List) { 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")