From 5196e59ed16aa71c4855a1782c3a33747026a706 Mon Sep 17 00:00:00 2001 From: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> Date: Thu, 1 Oct 2020 06:04:34 +0200 Subject: [PATCH] style: commit files corrected by Detekt (#1165) --- .github/workflows/macos_workflow.yml | 4 + build.gradle.kts | 11 ++ config/detekt.yml | 31 +++-- flank-scripts/build.gradle.kts | 4 +- gradle.properties | 15 +++ integration_tests/build.gradle.kts | 3 +- test_runner/build.gradle.kts | 14 +- .../main/kotlin/ftl/android/AndroidCatalog.kt | 1 - .../src/main/kotlin/ftl/args/ArgsHelper.kt | 72 ++++++----- .../ftl/cli/firebase/test/CommonRunCommand.kt | 3 +- .../NetworkProfilesDescribeCommand.kt | 3 +- .../main/kotlin/ftl/gc/GcAndroidTestMatrix.kt | 1 - .../CreateAndroidInstrumentationTest.kt | 8 +- .../src/main/kotlin/ftl/ios/IosCatalog.kt | 6 +- .../ftl/reports/api/PrepareForJUnitResult.kt | 12 +- .../ftl/reports/outcome/OutcomeMessageEnum.kt | 21 +-- .../kotlin/ftl/reports/util/ReportManager.kt | 41 +++--- .../ftl/run/platform/android/ResolveApks.kt | 3 +- .../ftl/run/platform/common/BeforeRunTests.kt | 8 +- .../src/main/kotlin/ftl/shard/Shard.kt | 1 + .../src/main/kotlin/ftl/shard/ShardCount.kt | 4 +- .../src/main/kotlin/ftl/util/Billing.kt | 1 + .../main/kotlin/ftl/util/LogTableBuilder.kt | 7 +- .../main/kotlin/ftl/util/ObfuscationGson.kt | 8 +- .../src/main/kotlin/ftl/util/StopWatch.kt | 3 +- test_runner/src/test/kotlin/Debug.kt | 6 +- test_runner/src/test/kotlin/ftl/MainTest.kt | 18 +-- .../kotlin/ftl/args/AndroidArgsFileTest.kt | 4 +- .../test/kotlin/ftl/args/AndroidArgsTest.kt | 15 ++- .../test/kotlin/ftl/args/ArgsHelperTest.kt | 17 ++- .../test/kotlin/ftl/args/IosArgsFileTest.kt | 3 +- .../src/test/kotlin/ftl/args/IosArgsTest.kt | 6 +- .../kotlin/ftl/cli/auth/LoginCommandTest.kt | 8 +- .../ftl/cli/firebase/CancelCommandTest.kt | 24 ++-- .../ftl/cli/firebase/RefreshCommandTest.kt | 14 +- .../test/ipblocks/IPBlocksListCommandTest.kt | 122 +++++++++--------- .../NetworkProfileDescribeTest.kt | 60 ++++----- .../src/test/kotlin/ftl/doctor/DoctorTest.kt | 30 +++-- .../ftl/environment/LocalesDescribeTest.kt | 22 ++-- .../android/AndroidModelDescriptionTest.kt | 68 +++++----- .../AndroidSoftwareVersionDescriptionTest.kt | 46 ++++--- .../ios/IosModelDescriptionTest.kt | 46 ++++--- .../ios/IosSoftwareVersionDescriptionTest.kt | 32 +++-- .../test/kotlin/ftl/filter/TestFiltersTest.kt | 3 +- .../kotlin/ftl/gc/GcAndroidTestMatrixTest.kt | 15 ++- .../src/test/kotlin/ftl/json/MatrixMapTest.kt | 8 +- .../CreateMatrixOutcomeSummaryKtTest.kt | 20 +-- .../kotlin/ftl/reports/xml/JUnitXmlTest.kt | 1 - .../kotlin/ftl/run/GenericTestRunnerTest.kt | 121 +++++++++-------- .../src/test/kotlin/ftl/run/TestRunnerTest.kt | 12 +- .../android/IgnoreTestsAnnotationTest.kt | 1 - .../test/kotlin/ftl/shard/ShardCountTest.kt | 9 +- .../src/test/kotlin/ftl/shard/ShardTest.kt | 65 +++++----- .../test/kotlin/ftl/shard/ShardTestCommon.kt | 1 - .../kotlin/ftl/shard/TestMethodTimeTest.kt | 8 +- .../src/test/kotlin/ftl/util/UtilsTest.kt | 5 +- 56 files changed, 638 insertions(+), 457 deletions(-) create mode 100644 gradle.properties diff --git a/.github/workflows/macos_workflow.yml b/.github/workflows/macos_workflow.yml index f2ee3bed7c..a1f4337ed2 100644 --- a/.github/workflows/macos_workflow.yml +++ b/.github/workflows/macos_workflow.yml @@ -35,6 +35,10 @@ jobs: with: arguments: "clean build" + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "[Auto-commit] Added filese fixed by Detekt" + - name: Codecov uses: codecov/codecov-action@v1.0.7 with: diff --git a/build.gradle.kts b/build.gradle.kts index cd8214e769..bee117591d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,6 +12,7 @@ configurations.all { plugins { kotlin(Plugins.Kotlin.PLUGIN_JVM) version Versions.KOTLIN + id(Plugins.DETEKT_PLUGIN) version Versions.DETEKT id(Plugins.BEN_MANES_PLUGIN) version Versions.BEN_MANES } @@ -20,6 +21,16 @@ repositories { mavenCentral() } +subprojects { + afterEvaluate { + if (tasks.findByName("detekt") != null) { + tasks.withType { + dependsOn(tasks["detekt"]) + } + } + } +} + tasks.named("dependencyUpdates", DependencyUpdatesTask::class.java).configure { gradleReleaseChannel = "release-candidate" diff --git a/config/detekt.yml b/config/detekt.yml index 91a9a18811..ea4700d87a 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -1,10 +1,10 @@ build: maxIssues: 0 weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 + # complexity: 2 + # LongParameterList: 1 + # style: 1 + # comments: 1 processors: active: true @@ -106,6 +106,8 @@ formatting: active: true android: false autoCorrect: true + ArgumentListWrapping: + active: false AnnotationOnSeparateLine: active: false autoCorrect: true @@ -115,7 +117,7 @@ formatting: CommentSpacing: active: true autoCorrect: true - EnumEntryNameCase: + EnumEntryNameCase: active: true autoCorrect: false Filename: @@ -130,11 +132,14 @@ formatting: autoCorrect: false Indentation: active: false - autoCorrect: false + autoCorrect: true indentSize: 4 continuationIndentSize: 4 MaximumLineLength: + excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt'] active: false + autoCorrect: true + maxLineLength: 120 ModifierOrdering: active: true autoCorrect: true @@ -144,11 +149,15 @@ formatting: active: true autoCorrect: true NoConsecutiveBlankLines: + excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt'] active: true autoCorrect: true NoEmptyClassBody: active: true autoCorrect: true + NoEmptyFirstLineInMethodBlock: + excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt'] + active: true NoItParamInMultilineLambda: active: false NoLineBreakAfterElse: @@ -179,7 +188,8 @@ formatting: active: true autoCorrect: true ParameterListWrapping: - active: true + excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt'] + active: false autoCorrect: true indentSize: 4 SpacingAroundColon: @@ -257,7 +267,7 @@ naming: propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '(_)?[A-Za-z][A-Za-z0-9]*' VariableMaxLength: - active: false + active: true maximumVariableNameLength: 64 VariableMinLength: active: false @@ -313,6 +323,8 @@ potential-bugs: style: active: true + ClassOrdering: + active: false CollapsibleIfStatements: active: true DataClassContainsFunctions: @@ -346,6 +358,7 @@ style: ForbiddenPublicDataClass: active: true MaxLineLength: + excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt'] active: false maxLineLength: 120 excludePackageStatements: true @@ -405,6 +418,8 @@ style: active: true UnusedPrivateClass: active: true + UnderscoresInNumericLiterals: + active: false UnusedPrivateMember: active: true allowedNames: '(_|ignored|expected|serialVersionUID|plus)' diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index 054648ae36..b5f76eb150 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -5,7 +5,7 @@ plugins { kotlin(Plugins.Kotlin.PLUGIN_JVM) kotlin(Plugins.Kotlin.PLUGIN_SERIALIZATION) version Versions.KOTLIN id(Plugins.PLUGIN_SHADOW_JAR) version Versions.SHADOW - id(Plugins.DETEKT_PLUGIN) version Versions.DETEKT + id(Plugins.DETEKT_PLUGIN) } val artifactID = "flankScripts" @@ -38,7 +38,9 @@ repositories { detekt { input = files("src/main/kotlin", "src/test/kotlin") config = files("../config/detekt.yml") + parallel = true autoCorrect = true + reports { xml { enabled = false diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000000..161c643578 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,15 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2560m -Dfile.encoding=UTF-8 +kotlin.code.style=official +org.gradle.parallel=true +org.gradle.daemon=true diff --git a/integration_tests/build.gradle.kts b/integration_tests/build.gradle.kts index 692ea438c4..16f280f396 100644 --- a/integration_tests/build.gradle.kts +++ b/integration_tests/build.gradle.kts @@ -1,7 +1,7 @@ plugins { java kotlin(Plugins.Kotlin.PLUGIN_JVM) - id(Plugins.DETEKT_PLUGIN) version Versions.DETEKT + id(Plugins.DETEKT_PLUGIN) } group = "org.flank" @@ -19,6 +19,7 @@ detekt { config = files("../config/detekt.yml") autoCorrect = true //auto format for detekt via klint buildUponDefaultConfig = true // preconfigure defaults + parallel = true reports { html.enabled = true // observe findings in your browser with structure and code snippets diff --git a/test_runner/build.gradle.kts b/test_runner/build.gradle.kts index f5263a1912..58b48de865 100644 --- a/test_runner/build.gradle.kts +++ b/test_runner/build.gradle.kts @@ -11,7 +11,7 @@ plugins { application jacoco kotlin(Plugins.Kotlin.PLUGIN_JVM) - id(Plugins.DETEKT_PLUGIN) version Versions.DETEKT + id(Plugins.DETEKT_PLUGIN) id(Plugins.JFROG_BINTRAY) version Versions.BINTRAY id(Plugins.MAVEN_PUBLISH) id(Plugins.PLUGIN_SHADOW_JAR) version Versions.SHADOW @@ -133,11 +133,11 @@ publishing { } detekt { - failFast = true // fail build on any finding input = files("src/main/kotlin", "src/test/kotlin") config = files("../config/detekt.yml") - autoCorrect = true //auto format for detekt via klint - buildUponDefaultConfig = true // preconfigure defaults + parallel = true + failFast = true // fail build on any finding + autoCorrect = true reports { html.enabled = true // observe findings in your browser with structure and code snippets @@ -146,12 +146,6 @@ detekt { } } -subprojects { - tasks.withType { - maxParallelForks = Runtime.getRuntime().availableProcessors() / 2 - } -} - // Kotlin dsl tasks.withType { // Target version of the generated JVM bytecode. It is used for type resolution. diff --git a/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt b/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt index 382926af2b..87fa03aa32 100644 --- a/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt @@ -54,7 +54,6 @@ object AndroidCatalog { versionMap.getOrPut(projectId) { deviceCatalog(projectId).versions.map { it.id } } fun supportedDeviceConfig(modelId: String, versionId: String, projectId: String): DeviceConfigCheck { - val foundModel = deviceCatalog(projectId).models.find { it.id == modelId } ?: return UnsupportedModelId if (!androidVersionIds(projectId).contains(versionId)) return UnsupportedVersionId diff --git a/test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt b/test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt index 19a1db29f4..180f40f49c 100644 --- a/test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt +++ b/test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt @@ -49,14 +49,16 @@ object ArgsHelper { throw FlankGeneralError("'$file' $name doesn't exist") } - private fun String.convertToWindowsPath() = this.replace("/", "\\").replaceFirst("~", System.getProperty("user.home")) + private fun String.convertToWindowsPath() = + this.replace("/", "\\").replaceFirst("~", System.getProperty("user.home")) private fun String.exist() = - if (startsWith(GCS_PREFIX)) GcStorage.exist(this) else File(this).exists() + if (startsWith(GCS_PREFIX)) GcStorage.exist(this) else File(this).exists() fun assertCommonProps(args: IArgs) { assertNotEmpty( - args.project, "The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml\n" + + args.project, + "The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml\n" + "or save service account credential to ${defaultCredentialPath}\n" + " See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id" ) @@ -115,7 +117,12 @@ object ArgsHelper { GcStorage.storage.get(bucket, path) ?: throw FlankGeneralError("The file at '$uri' does not exist") } - fun validateTestMethods(testTargets: List, validTestMethods: Collection, from: String, skipValidation: Boolean = useMock) { + fun validateTestMethods( + testTargets: List, + validTestMethods: Collection, + from: String, + skipValidation: Boolean = useMock + ) { val missingMethods = testTargets - validTestMethods if (!skipValidation && missingMethods.isNotEmpty()) throw FlankConfigurationError("$from is missing methods: $missingMethods.\nValid methods:\n$validTestMethods") @@ -132,7 +139,7 @@ object ArgsHelper { // Due to permission issues, the user may not be able to list or create buckets. fun createGcsBucket(projectId: String, bucket: String): String { if (bucket.isBlank()) return GcToolResults.getDefaultBucket(projectId) - ?: throw FlankGeneralError("Failed to make bucket for $projectId") + ?: throw FlankGeneralError("Failed to make bucket for $projectId") if (useMock) return bucket // test lab supports using a special free storage bucket @@ -140,9 +147,9 @@ object ArgsHelper { if (bucket.startsWith("test-lab-")) return bucket val storage = StorageOptions.newBuilder() - .setCredentials(FtlConstants.credential) - .setProjectId(projectId) - .build().service + .setCredentials(FtlConstants.credential) + .setProjectId(projectId) + .build().service val bucketLabel = mapOf("flank" to "") val storageLocation = "us-central1" @@ -159,11 +166,11 @@ object ArgsHelper { try { storage.create( - BucketInfo.newBuilder(bucket) - .setStorageClass(StorageClass.REGIONAL) - .setLocation(storageLocation) - .setLabels(bucketLabel) - .build() + BucketInfo.newBuilder(bucket) + .setStorageClass(StorageClass.REGIONAL) + .setLocation(storageLocation) + .setLabels(bucketLabel) + .build() ) } catch (e: Exception) { println("Warning: Failed to make bucket for $projectId\nCause: ${e.message}") @@ -177,9 +184,9 @@ object ArgsHelper { if (!defaultCredentialPath.toFile().exists()) return null return JsonObjectParser(JSON_FACTORY).parseAndClose( - Files.newInputStream(defaultCredentialPath), - Charsets.UTF_8, - GenericJson::class.java + Files.newInputStream(defaultCredentialPath), + Charsets.UTF_8, + GenericJson::class.java )["project_id"] as String } catch (e: Exception) { println("Parsing $defaultCredentialPath failed:") @@ -231,13 +238,17 @@ object ArgsHelper { } val (ignoredTests, testsToExecute) = filteredTests.partition { it.ignored } val shards = if (args.disableSharding) { - listOf(Chunk(testsToExecute.map { - TestMethod( - name = it.testName, - isParameterized = it.isParameterizedClass, - time = 0.0 + listOf( + Chunk( + testsToExecute.map { + TestMethod( + name = it.testName, + isParameterized = it.isParameterizedClass, + time = 0.0 + ) + } ) - })) + ) } else { val oldTestResult = GcStorage.downloadJunitXml(args) ?: JUnitTestResult(mutableListOf()) val shardCount = forcedShardCount ?: shardCountByTime(testsToExecute, oldTestResult, args) @@ -245,8 +256,9 @@ object ArgsHelper { } return CalculateShardsResult( - testMethodsAlwaysRun(shards, args), - ignoredTestCases = ignoredTests.map { it.testName }) + testMethodsAlwaysRun(shards, args), + ignoredTestCases = ignoredTests.map { it.testName } + ) } private fun testMethodsAlwaysRun(shards: List, args: IArgs): List { @@ -258,9 +270,9 @@ object ArgsHelper { } fun String.normalizeFilePath(): String = - if (startsWith(GCS_PREFIX)) this - else try { - ArgsHelper.evaluateFilePath(this) - } catch (e: Throwable) { - this - } + if (startsWith(GCS_PREFIX)) this + else try { + ArgsHelper.evaluateFilePath(this) + } catch (e: Throwable) { + this + } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt index 16d5f7fe2a..7c07eb7a4a 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt @@ -49,6 +49,7 @@ abstract class CommonRunCommand { @CommandLine.Option( names = ["--obfuscate"], description = ["Replacing internal test names with unique identifiers when using --dump-shards option " + - "to avoid exposing internal details"]) + "to avoid exposing internal details"] + ) var obfuscate: Boolean = false } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt index 68758f618b..03be98325a 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt @@ -27,6 +27,7 @@ class NetworkProfilesDescribeCommand : Runnable { paramLabel = "PROFILE_ID", defaultValue = "", description = ["The network profile to describe, found" + - " using \$ gcloud beta firebase test network-profiles list."]) + " using \$ gcloud beta firebase test network-profiles list."] + ) var profileId: String = "" } diff --git a/test_runner/src/main/kotlin/ftl/gc/GcAndroidTestMatrix.kt b/test_runner/src/main/kotlin/ftl/gc/GcAndroidTestMatrix.kt index 767326c154..f2896955c3 100644 --- a/test_runner/src/main/kotlin/ftl/gc/GcAndroidTestMatrix.kt +++ b/test_runner/src/main/kotlin/ftl/gc/GcAndroidTestMatrix.kt @@ -34,7 +34,6 @@ object GcAndroidTestMatrix { toolResultsHistory: ToolResultsHistory, additionalApkGcsPaths: List ): Testing.Projects.TestMatrices.Create { - // https://github.com/bootstraponline/studio-google-cloud-testing/blob/203ed2890c27a8078cd1b8f7ae12cf77527f426b/firebase-testing/src/com/google/gct/testing/launcher/CloudTestsLauncher.java#L120 val clientInfo = ClientInfo() .setName("Flank") diff --git a/test_runner/src/main/kotlin/ftl/gc/android/CreateAndroidInstrumentationTest.kt b/test_runner/src/main/kotlin/ftl/gc/android/CreateAndroidInstrumentationTest.kt index 279c29a8db..1af2c29f6c 100644 --- a/test_runner/src/main/kotlin/ftl/gc/android/CreateAndroidInstrumentationTest.kt +++ b/test_runner/src/main/kotlin/ftl/gc/android/CreateAndroidInstrumentationTest.kt @@ -46,9 +46,11 @@ internal fun AndroidInstrumentationTest.setupTestTargets( } uniformSharding = UniformSharding().setNumShards(safeNumUniformShards) } else { - manualSharding = ManualSharding().setTestTargetsForShard(testShards.map { - TestTargetsForShard().setTestTargets(it) - }) + manualSharding = ManualSharding().setTestTargetsForShard( + testShards.map { + TestTargetsForShard().setTestTargets(it) + } + ) } } } diff --git a/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt b/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt index bd9e5310ba..75dd3cf261 100644 --- a/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt @@ -26,7 +26,8 @@ object IosCatalog { fun softwareVersionsAsTable(projectId: String) = getVersionsList(projectId).asPrintableTable() - fun describeSoftwareVersion(projectId: String, versionId: String) = getVersionsList(projectId).getDescription(versionId) + fun describeSoftwareVersion(projectId: String, versionId: String) = + getVersionsList(projectId).getDescription(versionId) private fun getVersionsList(projectId: String) = iosDeviceCatalog(projectId).versions @@ -36,7 +37,8 @@ object IosCatalog { private fun getLocales(projectId: String) = iosDeviceCatalog(projectId).runtimeConfiguration.locales - fun supportedOrientationsAsTable(projectId: String) = iosDeviceCatalog(projectId).runtimeConfiguration.orientations.asPrintableTable() + fun supportedOrientationsAsTable(projectId: String) = + iosDeviceCatalog(projectId).runtimeConfiguration.orientations.asPrintableTable() fun supportedXcode(version: String, projectId: String) = xcodeVersions(projectId).contains(version) diff --git a/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt b/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt index 0111e8edff..7009628d21 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt @@ -39,12 +39,14 @@ private fun TestExecutionData.reduceTestCases() = copy( } ) -internal fun List.removeStackTraces(): List = map(TestExecutionData::removeStackTraces) -private fun TestExecutionData.removeStackTraces() = copy(testCases = testCases.onEach { - if (it.flaky) { - it.stackTraces = emptyList() +internal fun List.removeStackTraces(): List = + map(TestExecutionData::removeStackTraces) + +private fun TestExecutionData.removeStackTraces() = copy( + testCases = testCases.onEach { + if (it.flaky) it.stackTraces = emptyList() } -}) +) // For primary step return stepId instead of primaryStepId private val Step.primaryStepId get() = multiStep?.primaryStepId ?: stepId diff --git a/test_runner/src/main/kotlin/ftl/reports/outcome/OutcomeMessageEnum.kt b/test_runner/src/main/kotlin/ftl/reports/outcome/OutcomeMessageEnum.kt index 788a08c74c..5011fbe29e 100644 --- a/test_runner/src/main/kotlin/ftl/reports/outcome/OutcomeMessageEnum.kt +++ b/test_runner/src/main/kotlin/ftl/reports/outcome/OutcomeMessageEnum.kt @@ -11,11 +11,13 @@ enum class OutcomeMessageEnum(val message: String) { INSTRUMENTATION_ORCHESTRATOR_INCOMPATIBLE( "The test runner class specified by the user or the test APK's " + "manifest file is not compatible with Android Test Orchestrator. " + - "Please use AndroidJUnitRunner version 1.0 or higher"), - NO_TEST_RUNNER_CLASS - ("The test APK does not contain the test runner class specified by " + - "the user or the manifest file. The test runner class name may be " + - "incorrect, or the class may be mislocated in the app APK."), + "Please use AndroidJUnitRunner version 1.0 or higher" + ), + NO_TEST_RUNNER_CLASS( + "The test APK does not contain the test runner class specified by " + + "the user or the manifest file. The test runner class name may be " + + "incorrect, or the class may be mislocated in the app APK." + ), NO_LAUNCHER_ACTIVITY("The app APK does not specify a main launcher activity"), FORBIDDEN_PERMISSIONS("The app declares one or more permissions that are not allowed"), INVALID_ROBO_DIRECTIVES("Cannot have multiple robo-directives with the same resource name"), @@ -29,16 +31,19 @@ enum class OutcomeMessageEnum(val message: String) { MALFORMED_XC_TEST_ZIP( "The XCTest zip file was malformed. The zip did not contain a single " + ".xctestrun file and the contents of the DerivedData/Build/Products " + - "directory."), + "directory." + ), BUILT_FOR_IOS_SIMULATOR("The provided XCTest was built for the iOS simulator rather than for a physical device"), NO_TESTS_IN_XC_TEST_ZIP("The .xctestrun file did not specify any test targets to run"), USE_DESTINATION_ARTIFACTS( "One or more of the test targets defined in the .xctestrun file " + - "specifies \"UseDestinationArtifacts\"), which is not allowed"), + "specifies \"UseDestinationArtifacts\"), which is not allowed" + ), TEST_NOT_APP_HOSTED( "One or more of the test targets defined in the .xctestrun file " + "does not have a host binary to run on the physical iOS device), " + - "which may cause errors when running xcodebuild"), + "which may cause errors when running xcodebuild" + ), NO_CODE_APK("\"hasCode\" is false in the Manifest. Tested APKs must contain code"), INVALID_INPUT_APK("Either the provided input APK path was malformed, the APK file does not exist, or the user does not have permission to access the file"), INVALID_APK_PREVIEW_SDK("Your app targets a preview version of the Android SDK that's incompatible with the selected devices."), diff --git a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt index df250302ae..7fe017d2fb 100644 --- a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt +++ b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt @@ -106,11 +106,16 @@ object ReportManager { HtmlErrorReport ).map { it.run(matrices, testSuite, printToStdout = false, args = args) } } - JUnitReport.run(matrices, testSuite?.apply { - if (ignoredTestCases.isNotEmpty()) { - testsuites?.add(ignoredTestCases.toJunitTestsResults()) - } - }, printToStdout = false, args = args) + JUnitReport.run( + matrices, + testSuite?.apply { + if (ignoredTestCases.isNotEmpty()) { + testsuites?.add(ignoredTestCases.toJunitTestsResults()) + } + }, + printToStdout = false, + args = args + ) when { args.fullJUnitResult -> processFullJunitResult(args, matrices, testShardChunks) args.useLegacyJUnitResult -> processJunitXml(testSuite, args, testShardChunks) @@ -118,14 +123,16 @@ object ReportManager { } } - private fun IgnoredTestCases.toJunitTestsResults() = getSkippedJUnitTestSuite(map { - JUnitTestCase( - classname = it.split("#").first().replace("class ", ""), - name = it.split("#").last(), - time = "0.0", - skipped = null - ) - }) + private fun IgnoredTestCases.toJunitTestsResults() = getSkippedJUnitTestSuite( + map { + JUnitTestCase( + classname = it.split("#").first().replace("class ", ""), + name = it.split("#").last(), + time = "0.0", + skipped = null + ) + } + ) private fun processFullJunitResult(args: IArgs, matrices: MatrixMap, testShardChunks: ShardChunks) { val testSuite = processXmlFromApi(matrices, args, withStackTraces = true) @@ -171,9 +178,11 @@ object ReportManager { ) { val list = createShardEfficiencyList(oldResult, newResult, args, testShardChunks) - println("Actual shard times:\n" + list.joinToString("\n") { - " ${it.shard}: Expected: ${it.expectedTime.roundToInt()}s, Actual: ${it.finalTime.roundToInt()}s, Diff: ${it.timeDiff.roundToInt()}s" - } + "\n") + println( + "Actual shard times:\n" + list.joinToString("\n") { + " ${it.shard}: Expected: ${it.expectedTime.roundToInt()}s, Actual: ${it.finalTime.roundToInt()}s, Diff: ${it.timeDiff.roundToInt()}s" + } + "\n" + ) } private fun processJunitXml( diff --git a/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt b/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt index 6ba106a689..40bedcb488 100644 --- a/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt +++ b/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt @@ -31,6 +31,7 @@ private fun AndroidArgs.additionalApksContexts() = additionalAppTestApks.map { app = (it.app ?: appApk) ?.asFileReference() ?: throw FlankGeneralError("Cannot create app-test apks pair for instrumentation tests, missing app apk for test ${it.test}"), - test = it.test.asFileReference(), environmentVariables = it.environmentVariables + test = it.test.asFileReference(), + environmentVariables = it.environmentVariables ) }.toTypedArray() diff --git a/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunTests.kt b/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunTests.kt index 5660d2cde7..860ab83311 100644 --- a/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunTests.kt +++ b/test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunTests.kt @@ -37,9 +37,11 @@ private fun assertMockUrl() { } private fun deleteMockResultDirOnShutDown(args: IArgs, runGcsPath: String) { - Runtime.getRuntime().addShutdownHook(Thread { - File(args.localResultDir, runGcsPath).deleteRecursively() - }) + Runtime.getRuntime().addShutdownHook( + Thread { + File(args.localResultDir, runGcsPath).deleteRecursively() + } + ) } private fun deleteLocalResultDir(args: IArgs) { diff --git a/test_runner/src/main/kotlin/ftl/shard/Shard.kt b/test_runner/src/main/kotlin/ftl/shard/Shard.kt index 9fb5ff3cbe..6afb90a54d 100644 --- a/test_runner/src/main/kotlin/ftl/shard/Shard.kt +++ b/test_runner/src/main/kotlin/ftl/shard/Shard.kt @@ -11,6 +11,7 @@ data class TestShard( var time: Double, val testMethods: MutableList ) + /** List of shards containing test names as a string. */ typealias StringShards = List> diff --git a/test_runner/src/main/kotlin/ftl/shard/ShardCount.kt b/test_runner/src/main/kotlin/ftl/shard/ShardCount.kt index dee1a5837f..057e064612 100644 --- a/test_runner/src/main/kotlin/ftl/shard/ShardCount.kt +++ b/test_runner/src/main/kotlin/ftl/shard/ShardCount.kt @@ -31,7 +31,9 @@ private fun calculateShardCount( return calculateShardCount( args = args, testsTotalTime = testTotalTime( - testsToRun, previousMethodDurations, args.fallbackTestTime(previousMethodDurations), + testsToRun, + previousMethodDurations, + args.fallbackTestTime(previousMethodDurations), args.defaultClassTestTime ), testsToRunCount = testsToRun.size diff --git a/test_runner/src/main/kotlin/ftl/util/Billing.kt b/test_runner/src/main/kotlin/ftl/util/Billing.kt index 5bc4bbc386..351f976798 100644 --- a/test_runner/src/main/kotlin/ftl/util/Billing.kt +++ b/test_runner/src/main/kotlin/ftl/util/Billing.kt @@ -5,6 +5,7 @@ import java.math.RoundingMode import java.util.concurrent.TimeUnit private val physicalCostPerMinute = divBy60(5) // $5/hr + private val virtualCostPerMinute = divBy60(1) // $1/hr private fun divBy60(value: Long) = BigDecimal(value).divide(BigDecimal(60), 10, RoundingMode.HALF_UP) diff --git a/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt b/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt index 3fa0670a7c..a789263a51 100644 --- a/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt +++ b/test_runner/src/main/kotlin/ftl/util/LogTableBuilder.kt @@ -1,6 +1,7 @@ package ftl.util import com.google.common.annotations.VisibleForTesting +import java.util.Locale enum class TableStyle { DEFAULT, @@ -136,11 +137,11 @@ private fun StringBuilder.appendDataRow(data: List) { appendLine() } -private fun DataWithSize.leftAligned() = String.format("%-${columnSize}s", " $data") +private fun DataWithSize.leftAligned() = String.format(Locale.getDefault(), "%-${columnSize}s", " $data") private fun DataWithSize.center() = String.format( - "%-" + columnSize + "s", - String.format("%" + (data.length + (columnSize - data.length) / 2) + "s", this.data) + "%-" + columnSize + "s", + String.format("%" + (data.length + (columnSize - data.length) / 2) + "s", this.data) ) inline fun TableColumn.applyColorsUsing(mapper: (String) -> SystemOutColor) = copy(dataColor = data.map(mapper)) diff --git a/test_runner/src/main/kotlin/ftl/util/ObfuscationGson.kt b/test_runner/src/main/kotlin/ftl/util/ObfuscationGson.kt index 2b8f26b432..a2465d91a7 100644 --- a/test_runner/src/main/kotlin/ftl/util/ObfuscationGson.kt +++ b/test_runner/src/main/kotlin/ftl/util/ObfuscationGson.kt @@ -45,9 +45,11 @@ private object ObfuscatedIosJsonSerializer : JsonSerializer>> context: JsonSerializationContext ) = JsonArray().also { jsonArray -> src.forEach { list -> - jsonArray.add(JsonArray().also { nestedJsonArray -> - list.forEach { nestedJsonArray.add(obfuscationContext.obfuscateIosTestName(it)) } - }) + jsonArray.add( + JsonArray().also { nestedJsonArray -> + list.forEach { nestedJsonArray.add(obfuscationContext.obfuscateIosTestName(it)) } + } + ) } } } diff --git a/test_runner/src/main/kotlin/ftl/util/StopWatch.kt b/test_runner/src/main/kotlin/ftl/util/StopWatch.kt index 55a082fafc..95c48da8db 100644 --- a/test_runner/src/main/kotlin/ftl/util/StopWatch.kt +++ b/test_runner/src/main/kotlin/ftl/util/StopWatch.kt @@ -1,6 +1,7 @@ package ftl.util import ftl.run.exception.FlankGeneralError +import java.util.Locale import java.util.concurrent.TimeUnit.MILLISECONDS class StopWatch { @@ -27,6 +28,6 @@ class StopWatch { " " else " " - return String.format("%dm$space%ds", minutes, seconds) + return String.format(Locale.getDefault(), "%dm$space%ds", minutes, seconds) } } diff --git a/test_runner/src/test/kotlin/Debug.kt b/test_runner/src/test/kotlin/Debug.kt index 10fc18edf0..608364e6bf 100644 --- a/test_runner/src/test/kotlin/Debug.kt +++ b/test_runner/src/test/kotlin/Debug.kt @@ -1,3 +1,5 @@ +@file:Suppress("InvalidPackageDeclaration") + import ftl.Main import ftl.run.exception.withGlobalExceptionHandling import picocli.CommandLine @@ -18,7 +20,9 @@ fun main() { withGlobalExceptionHandling { CommandLine(Main()).execute( // "--debug", - "firebase", "test", "android", + "firebase", + "test", + "android", "run", // "--dry", // "--dump-shards", diff --git a/test_runner/src/test/kotlin/ftl/MainTest.kt b/test_runner/src/test/kotlin/ftl/MainTest.kt index 98e3a488f4..c5a3c0468d 100644 --- a/test_runner/src/test/kotlin/ftl/MainTest.kt +++ b/test_runner/src/test/kotlin/ftl/MainTest.kt @@ -91,13 +91,15 @@ class MainTest { @Test fun `should terminate jvm with exit status 2 if yml parsing error occurs`() { systemExit.expectSystemExitWithStatus(2) - Main.main(arrayOf( - "firebase", - "test", - "android", - "run", - "--dry", - "-c=./src/test/kotlin/ftl/fixtures/invalid.yml" - )) + Main.main( + arrayOf( + "firebase", + "test", + "android", + "run", + "--dry", + "-c=./src/test/kotlin/ftl/fixtures/invalid.yml" + ) + ) } } diff --git a/test_runner/src/test/kotlin/ftl/args/AndroidArgsFileTest.kt b/test_runner/src/test/kotlin/ftl/args/AndroidArgsFileTest.kt index b911519719..4d2e0e0c57 100644 --- a/test_runner/src/test/kotlin/ftl/args/AndroidArgsFileTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/AndroidArgsFileTest.kt @@ -57,7 +57,6 @@ class AndroidArgsFileTest { } private fun checkConfig(args: AndroidArgs, local: Boolean) { - with(args) { if (local) assert(getString(testApk!!), getString(testApkAbsolutePath)) else assert(testApk, testApkGcs) @@ -76,7 +75,8 @@ class AndroidArgsFileTest { assert(async, true) assert(testTargets, listOf(testName)) assert( - devices, listOf( + devices, + listOf( Device("NexusLowRes", "23", "en", "portrait", isVirtual = true), Device("NexusLowRes", "23", "en", "landscape", isVirtual = true), Device("shamu", "22", "zh_CN", "default", isVirtual = false) diff --git a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt index 0419137f38..3d69e3078e 100644 --- a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt @@ -236,7 +236,8 @@ class AndroidArgsTest { assert(environmentVariables, linkedMapOf("clearPackageData" to "true", "randomEnvVar" to "false")) assert(directoriesToPull, listOf("/sdcard/screenshots", "/sdcard/screenshots2")) assert( - otherFiles, mapOf( + otherFiles, + mapOf( "/sdcard/dir1/file1.txt" to appApkAbsolutePath, "/sdcard/dir2/file2.jpg" to testApkAbsolutePath ) @@ -251,7 +252,8 @@ class AndroidArgsTest { ) ) assert( - devices, listOf( + devices, + listOf( Device("NexusLowRes", "23", "en", "portrait", isVirtual = true), Device("NexusLowRes", "24", "en", "portrait", isVirtual = true) ) @@ -264,7 +266,8 @@ class AndroidArgsTest { assert(repeatTests, 8) assert(filesToDownload, listOf("/sdcard/screenshots", "/sdcard/screenshots2")) assert( - testTargetsAlwaysRun, listOf( + testTargetsAlwaysRun, + listOf( "class example.Test#grantPermission", "class example.Test#grantPermission2" ) @@ -280,7 +283,8 @@ class AndroidArgsTest { fun androidArgsToString() { val androidArgs = AndroidArgs.load(androidNonDefault) assert( - androidArgs.toString(), """ + androidArgs.toString(), + """ AndroidArgs gcloud: results-bucket: mockBucket @@ -414,7 +418,8 @@ AndroidArgs legacy-junit-result: true ignore-failed-tests: false output-style: multi - """.trimIndent(), args.toString() + """.trimIndent(), + args.toString() ) } diff --git a/test_runner/src/test/kotlin/ftl/args/ArgsHelperTest.kt b/test_runner/src/test/kotlin/ftl/args/ArgsHelperTest.kt index 814e9161ba..d47a59c31d 100644 --- a/test_runner/src/test/kotlin/ftl/args/ArgsHelperTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/ArgsHelperTest.kt @@ -47,13 +47,16 @@ class ArgsHelperTest { @Test fun `mergeYmlMaps succeeds`() { - val merged = mergeYmlKeys(mockk() { - every { keys } returns listOf("devices", "test", "apk") - every { group } returns "gcloud" - }, mockk() { - every { keys } returns listOf("xcode-version", "async", "client-details") - every { group } returns "gcloud" - }) + val merged = mergeYmlKeys( + mockk() { + every { keys } returns listOf("devices", "test", "apk") + every { group } returns "gcloud" + }, + mockk() { + every { keys } returns listOf("xcode-version", "async", "client-details") + every { group } returns "gcloud" + } + ) assertThat(merged.keys.size).isEqualTo(1) assertThat(merged["gcloud"]?.size).isEqualTo(6) diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsFileTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsFileTest.kt index d0e643d52a..35b94535bd 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsFileTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsFileTest.kt @@ -47,7 +47,8 @@ class IosArgsFileTest { assert(async, true) assert(testTargets, listOf(testName)) assert( - devices, listOf( + devices, + listOf( Device("iphone8", "11.2", "en_US", "portrait") ) ) diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index 4a4cdde5da..56e12e67cc 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -197,7 +197,8 @@ flank: fun `args toString`() { val args = IosArgs.load(iosNonDefault) assert( - args.toString(), """ + args.toString(), + """ IosArgs gcloud: results-bucket: mockBucket @@ -300,7 +301,8 @@ IosArgs run-timeout: -1 ignore-failed-tests: false output-style: multi - """.trimIndent(), args.toString() + """.trimIndent(), + args.toString() ) } diff --git a/test_runner/src/test/kotlin/ftl/cli/auth/LoginCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/auth/LoginCommandTest.kt index 1a472b9335..975d468a2c 100644 --- a/test_runner/src/test/kotlin/ftl/cli/auth/LoginCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/auth/LoginCommandTest.kt @@ -1,6 +1,5 @@ package ftl.cli.auth -import com.google.common.truth.Truth import com.google.common.truth.Truth.assertThat import ftl.test.util.FlankTestRunner import ftl.test.util.TestHelper.normalizeLineEnding @@ -27,11 +26,12 @@ class LoginCommandTest { CommandLine(command).execute("-h") val output = systemOutRule.log.normalizeLineEnding() - Truth.assertThat(output).startsWith( - """Obtains access credentials for your user account via a web-based authorization + assertThat(output).startsWith( + """Obtains access credentials for your user account via a web-based authorization flow. -login [-h]""".trimIndent()) +login [-h]""".trimIndent() + ) assertThat(command.usageHelpRequested).isTrue() } diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/CancelCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/CancelCommandTest.kt index d163e05cc9..0d08e19d90 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/CancelCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/CancelCommandTest.kt @@ -24,18 +24,18 @@ class CancelCommandTest { val output = systemOutRule.log.normalizeLineEnding() assertThat(output).startsWith( - "Cancels the last Firebase Test Lab run\n" + - "\n" + - "cancel [-h]\n" + - "\n" + - "Description:\n" + - "\n" + - "Selects the most recent run in the results/ folder.\n" + - "Reads in the matrix_ids.json file. Cancels any incomplete matrices.\n" + - "\n" + - "\n" + - "Options:\n" + - " -h, --help Prints this help message\n" + "Cancels the last Firebase Test Lab run\n" + + "\n" + + "cancel [-h]\n" + + "\n" + + "Description:\n" + + "\n" + + "Selects the most recent run in the results/ folder.\n" + + "Reads in the matrix_ids.json file. Cancels any incomplete matrices.\n" + + "\n" + + "\n" + + "Options:\n" + + " -h, --help Prints this help message\n" ) assertThat(command.usageHelpRequested).isTrue() diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/RefreshCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/RefreshCommandTest.kt index a7c45a7e63..cca468adc3 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/RefreshCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/RefreshCommandTest.kt @@ -25,14 +25,17 @@ class RefreshCommandTest { val yamlCfg = Paths.get(parent, "flank.yml") matrixIds.parent.toFile().mkdirs() - Runtime.getRuntime().addShutdownHook(Thread { - File(parent).deleteRecursively() - }) + Runtime.getRuntime().addShutdownHook( + Thread { + File(parent).deleteRecursively() + } + ) if (matrixIds.toFile().exists() && yamlCfg.toFile().exists()) return Files.write( - matrixIds, """ + matrixIds, + """ { "matrix-1": { "matrixId": "matrix-1", @@ -48,7 +51,8 @@ class RefreshCommandTest { ) Files.write( - yamlCfg, """ + yamlCfg, + """ gcloud: app: ../test_projects/android/apks/app-debug.apk test: ../test_projects/android/apks/app-debug-androidTest.apk diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommandTest.kt index 7fdd69ee94..d3224dab4c 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommandTest.kt @@ -42,24 +42,24 @@ class IPBlocksListCommandTest { @Test fun `should print ips for devices`() { val ips = listOf( - DeviceIpBlock().apply { - block = "1.1.1.1/1" - form = "AnyForm" - addedDate = Date().apply { - day = 1 - month = 1 - year = 1111 - } - }, - DeviceIpBlock().apply { - block = "2.2.2.2/2" - form = "OtherForm" - addedDate = Date().apply { - day = 12 - month = 12 - year = 1212 - } + DeviceIpBlock().apply { + block = "1.1.1.1/1" + form = "AnyForm" + addedDate = Date().apply { + day = 1 + month = 1 + year = 1111 } + }, + DeviceIpBlock().apply { + block = "2.2.2.2/2" + form = "OtherForm" + addedDate = Date().apply { + day = 12 + month = 12 + year = 1212 + } + } ) every { deviceIPBlocks() } returns ips @@ -92,51 +92,51 @@ class IPBlocksListCommandTest { @Test fun `should not fail when FTL returns null in any of values`() { val ips = listOf( - DeviceIpBlock().apply { - block = "1.1.1.1/1" - form = "AnyForm" - addedDate = Date().apply { - day = null - month = 1 - year = 1111 - } - }, - DeviceIpBlock().apply { - block = null - form = "MissingIpForm" - addedDate = Date().apply { - day = 12 - month = 2 - year = 1212 - } - }, - DeviceIpBlock().apply { - block = "2.2.2.2/2" - form = "OtherForm" - addedDate = Date().apply { - day = 12 - month = null - year = 1212 - } - }, - DeviceIpBlock().apply { - block = "3.3.3.3/4" - form = "FunnyForm" - addedDate = Date().apply { - day = 8 - month = 2 - year = null - } - }, - DeviceIpBlock().apply { - block = "4.4.4.4/4" - form = null - addedDate = Date().apply { - day = 8 - month = 2 - year = 1523 - } + DeviceIpBlock().apply { + block = "1.1.1.1/1" + form = "AnyForm" + addedDate = Date().apply { + day = null + month = 1 + year = 1111 + } + }, + DeviceIpBlock().apply { + block = null + form = "MissingIpForm" + addedDate = Date().apply { + day = 12 + month = 2 + year = 1212 + } + }, + DeviceIpBlock().apply { + block = "2.2.2.2/2" + form = "OtherForm" + addedDate = Date().apply { + day = 12 + month = null + year = 1212 + } + }, + DeviceIpBlock().apply { + block = "3.3.3.3/4" + form = "FunnyForm" + addedDate = Date().apply { + day = 8 + month = 2 + year = null + } + }, + DeviceIpBlock().apply { + block = "4.4.4.4/4" + form = null + addedDate = Date().apply { + day = 8 + month = 2 + year = 1523 } + } ) every { deviceIPBlocks() } returns ips diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfileDescribeTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfileDescribeTest.kt index 2013c545f4..7c6b39d5c9 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfileDescribeTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfileDescribeTest.kt @@ -39,16 +39,16 @@ class NetworkProfileDescribeTest { @Test fun `should print profile description if data exists`() { val configs = listOf( - NetworkConfiguration().apply { - downRule = makeRule(0.5f) - upRule = makeRule(0.8f) - id = "ANY" - }, - NetworkConfiguration().apply { - downRule = makeRule(0.1f) - upRule = makeRule(0.2f) - id = "DIFFERENT" - } + NetworkConfiguration().apply { + downRule = makeRule(0.5f) + upRule = makeRule(0.8f) + id = "ANY" + }, + NetworkConfiguration().apply { + downRule = makeRule(0.1f) + upRule = makeRule(0.2f) + id = "DIFFERENT" + } ) every { getNetworkConfiguration() } returns configs @@ -87,21 +87,21 @@ class NetworkProfileDescribeTest { @Test fun `should print message if unable to find provided profile`() { val configs = listOf( - NetworkConfiguration().apply { - downRule = makeRule(0.456f) - id = "ANY_1" - upRule = makeRule(0.111f) - }, - NetworkConfiguration().apply { - downRule = makeRule(0.0976f) - id = "ANY_2" - upRule = makeRule(0.234f) - }, - NetworkConfiguration().apply { - downRule = makeRule(0.1f) - id = "ANY_3" - upRule = makeRule(0.11233f) - } + NetworkConfiguration().apply { + downRule = makeRule(0.456f) + id = "ANY_1" + upRule = makeRule(0.111f) + }, + NetworkConfiguration().apply { + downRule = makeRule(0.0976f) + id = "ANY_2" + upRule = makeRule(0.234f) + }, + NetworkConfiguration().apply { + downRule = makeRule(0.1f) + id = "ANY_3" + upRule = makeRule(0.11233f) + } ) every { getNetworkConfiguration() } returns configs @@ -117,11 +117,11 @@ class NetworkProfileDescribeTest { @Test fun `should handle possible null values`() { val configs = listOf( - NetworkConfiguration().apply { - downRule = makeRule(0.456f) - id = "WITH_NULLS" - upRule = TrafficRule().apply { packetLossRatio = 0.123f } - } + NetworkConfiguration().apply { + downRule = makeRule(0.456f) + id = "WITH_NULLS" + upRule = TrafficRule().apply { packetLossRatio = 0.123f } + } ) every { getNetworkConfiguration() } returns configs diff --git a/test_runner/src/test/kotlin/ftl/doctor/DoctorTest.kt b/test_runner/src/test/kotlin/ftl/doctor/DoctorTest.kt index 0cb7ca536f..1fa8e7295b 100644 --- a/test_runner/src/test/kotlin/ftl/doctor/DoctorTest.kt +++ b/test_runner/src/test/kotlin/ftl/doctor/DoctorTest.kt @@ -29,7 +29,8 @@ class DoctorTest { @Test fun androidDoctorTest2() { val lint = validateYaml( - AndroidArgs, """ + AndroidArgs, + """ hi: . foo: bar: 1 @@ -68,7 +69,7 @@ flank: """.trimIndent() ) assertThat(lint).isEqualTo( - """ + """ Unknown top level keys: [hi, foo] Unknown keys in gcloud -> [two] Unknown keys in flank -> [three] @@ -80,7 +81,8 @@ Unknown keys in flank -> [three] @Test fun androidDoctorTest3() { val lint = validateYaml( - AndroidArgs, """ + AndroidArgs, + """ gcloud: app: . test: . @@ -108,8 +110,8 @@ Error node: { // when val actual = validateYaml( - AndroidArgs, - Paths.get("src/test/kotlin/ftl/fixtures/flank_android_failed_configuration.yml") + AndroidArgs, + Paths.get("src/test/kotlin/ftl/fixtures/flank_android_failed_configuration.yml") ) assertEqualsIgnoreNewlineStyle(expectedErrorMessage, actual) } @@ -131,8 +133,8 @@ Error node: { // when val actual = validateYaml( - AndroidArgs, - Paths.get("src/test/kotlin/ftl/fixtures/flank_android_failed_tree.yml") + AndroidArgs, + Paths.get("src/test/kotlin/ftl/fixtures/flank_android_failed_tree.yml") ) assertEqualsIgnoreNewlineStyle(expectedErrorMessage, actual) } @@ -150,7 +152,8 @@ Error node: { @Test fun iosDoctorTest2() { val lint = validateYaml( - IosArgs, """ + IosArgs, + """ hi: . foo: bar: 1 @@ -182,7 +185,7 @@ flank: """.trimIndent() ) assertThat(lint).isEqualTo( - """ + """ Unknown top level keys: [hi, foo] Unknown keys in gcloud -> [two] Unknown keys in flank -> [three] @@ -194,7 +197,8 @@ Unknown keys in flank -> [three] @Test fun iosDoctorTest3() { val lint = validateYaml( - IosArgs, """ + IosArgs, + """ gcloud: test: . xctestrun-file: . @@ -208,7 +212,8 @@ flank: @Test fun `validate result should contains warning about device version if is not compatible with gcloud cli`() { val lint = validateYaml( - IosArgs, """ + IosArgs, + """ gcloud: test: . xctestrun-file: . @@ -225,7 +230,8 @@ flank: @Test fun `should return empty validation message if device version is compatible with gcloud cli`() { val lint = validateYaml( - IosArgs, """ + IosArgs, + """ gcloud: test: . xctestrun-file: . diff --git a/test_runner/src/test/kotlin/ftl/environment/LocalesDescribeTest.kt b/test_runner/src/test/kotlin/ftl/environment/LocalesDescribeTest.kt index 6df93a1c79..067365b3b7 100644 --- a/test_runner/src/test/kotlin/ftl/environment/LocalesDescribeTest.kt +++ b/test_runner/src/test/kotlin/ftl/environment/LocalesDescribeTest.kt @@ -8,11 +8,13 @@ class LocalesDescribeTest { @Test fun `should return locales with tag if any tag exists`() { - val locales = listOf(Locale().apply { - id = "test" - name = "name_test" - tags = listOf("one", "second") - }) + val locales = listOf( + Locale().apply { + id = "test" + name = "name_test" + tags = listOf("one", "second") + } + ) val localesDescription = locales.getLocaleDescription("test").trim() val expected = """ @@ -27,10 +29,12 @@ class LocalesDescribeTest { @Test fun `should return locales without tag header if no tags`() { - val locales = listOf(Locale().apply { - id = "test" - name = "name_test" - }) + val locales = listOf( + Locale().apply { + id = "test" + name = "name_test" + } + ) val localesDescription = locales.getLocaleDescription("test").trim() val expected = """ diff --git a/test_runner/src/test/kotlin/ftl/environment/android/AndroidModelDescriptionTest.kt b/test_runner/src/test/kotlin/ftl/environment/android/AndroidModelDescriptionTest.kt index 90bf031185..3df2e9de23 100644 --- a/test_runner/src/test/kotlin/ftl/environment/android/AndroidModelDescriptionTest.kt +++ b/test_runner/src/test/kotlin/ftl/environment/android/AndroidModelDescriptionTest.kt @@ -9,22 +9,25 @@ import org.junit.Test class AndroidModelDescriptionTest { @Test fun `should return model with tag if any tag exists`() { - val models = listOf(AndroidModel().apply { - id = "walleye" - codename = "walleye" - brand = "Google" - form = "PHYSICAL" - formFactor = "PHONE" - manufacturer = "Google" - name = "Pixel 2" - screenDensity = 420 - screenX = 1080 - screenY = 1920 - supportedAbis = listOf("arm64-v8a", "armeabi-v7a", "armeabi") - supportedVersionIds = listOf("26", "27", "28") - tags = listOf("default") - thumbnailUrl = "https://lh3.googleusercontent.com/j4urvb3lXTaFGZI6IzHmAjum2HQVID1OHPhDB7dOzRvXb2WscSX2RFwEEFFSYhajqRO5Yu0e6FYQ" - }) + val models = listOf( + AndroidModel().apply { + id = "walleye" + codename = "walleye" + brand = "Google" + form = "PHYSICAL" + formFactor = "PHONE" + manufacturer = "Google" + name = "Pixel 2" + screenDensity = 420 + screenX = 1080 + screenY = 1920 + supportedAbis = listOf("arm64-v8a", "armeabi-v7a", "armeabi") + supportedVersionIds = listOf("26", "27", "28") + tags = listOf("default") + thumbnailUrl = + "https://lh3.googleusercontent.com/j4urvb3lXTaFGZI6IzHmAjum2HQVID1OHPhDB7dOzRvXb2WscSX2RFwEEFFSYhajqRO5Yu0e6FYQ" + } + ) val modelDescription = models.getDescription("walleye") val expected = """ @@ -55,21 +58,24 @@ class AndroidModelDescriptionTest { @Test fun `should return model without tag if no tags`() { - val models = listOf(AndroidModel().apply { - id = "walleye" - codename = "walleye" - brand = "Google" - form = "PHYSICAL" - formFactor = "PHONE" - manufacturer = "Google" - name = "Pixel 2" - screenDensity = 420 - screenX = 1080 - screenY = 1920 - supportedAbis = listOf("arm64-v8a", "armeabi-v7a", "armeabi") - supportedVersionIds = listOf("26", "27", "28") - thumbnailUrl = "https://lh3.googleusercontent.com/j4urvb3lXTaFGZI6IzHmAjum2HQVID1OHPhDB7dOzRvXb2WscSX2RFwEEFFSYhajqRO5Yu0e6FYQ" - }) + val models = listOf( + AndroidModel().apply { + id = "walleye" + codename = "walleye" + brand = "Google" + form = "PHYSICAL" + formFactor = "PHONE" + manufacturer = "Google" + name = "Pixel 2" + screenDensity = 420 + screenX = 1080 + screenY = 1920 + supportedAbis = listOf("arm64-v8a", "armeabi-v7a", "armeabi") + supportedVersionIds = listOf("26", "27", "28") + thumbnailUrl = + "https://lh3.googleusercontent.com/j4urvb3lXTaFGZI6IzHmAjum2HQVID1OHPhDB7dOzRvXb2WscSX2RFwEEFFSYhajqRO5Yu0e6FYQ" + } + ) val modelDescription = models.getDescription("walleye") val expected = """ diff --git a/test_runner/src/test/kotlin/ftl/environment/android/AndroidSoftwareVersionDescriptionTest.kt b/test_runner/src/test/kotlin/ftl/environment/android/AndroidSoftwareVersionDescriptionTest.kt index 1e36fa45f7..13237b6f45 100644 --- a/test_runner/src/test/kotlin/ftl/environment/android/AndroidSoftwareVersionDescriptionTest.kt +++ b/test_runner/src/test/kotlin/ftl/environment/android/AndroidSoftwareVersionDescriptionTest.kt @@ -9,18 +9,20 @@ import org.junit.Test class AndroidSoftwareVersionDescriptionTest { @Test fun `should return software version with tag if any tag exists`() { - val versions = listOf(AndroidVersion().apply { - id = "26" - apiLevel = 26 - codeName = "Oreo" - versionString = "8.0.x" - releaseDate = Date().apply { - day = 21 - month = 8 - year = 2017 + val versions = listOf( + AndroidVersion().apply { + id = "26" + apiLevel = 26 + codeName = "Oreo" + versionString = "8.0.x" + releaseDate = Date().apply { + day = 21 + month = 8 + year = 2017 + } + tags = listOf("default") } - tags = listOf("default") - }) + ) val localesDescription = versions.getDescription("26") val expected = """ @@ -40,17 +42,19 @@ class AndroidSoftwareVersionDescriptionTest { @Test fun `should return software version without tag if no tags`() { - val versions = listOf(AndroidVersion().apply { - id = "23" - apiLevel = 23 - codeName = "Marshmallow" - versionString = "6.0.x" - releaseDate = Date().apply { - day = 5 - month = 10 - year = 2015 + val versions = listOf( + AndroidVersion().apply { + id = "23" + apiLevel = 23 + codeName = "Marshmallow" + versionString = "6.0.x" + releaseDate = Date().apply { + day = 5 + month = 10 + year = 2015 + } } - }) + ) val localesDescription = versions.getDescription("23") val expected = """ diff --git a/test_runner/src/test/kotlin/ftl/environment/ios/IosModelDescriptionTest.kt b/test_runner/src/test/kotlin/ftl/environment/ios/IosModelDescriptionTest.kt index 39b5522dce..db10ab27ce 100644 --- a/test_runner/src/test/kotlin/ftl/environment/ios/IosModelDescriptionTest.kt +++ b/test_runner/src/test/kotlin/ftl/environment/ios/IosModelDescriptionTest.kt @@ -9,17 +9,19 @@ import org.junit.Test class IosModelDescriptionTest { @Test fun `should return model with tag if any tag exists`() { - val models = listOf(IosModel().apply { - deviceCapabilities = listOf("accelerometer", "arm64") - formFactor = "PHONE" - id = "iphone6s" - name = "iPhone 6s" - screenDensity = 326 - screenX = 750 - screenY = 1334 - supportedVersionIds = listOf("10.3", "11.2") - tags = listOf("deprecated=10.3", "deprecated=11.2") - }) + val models = listOf( + IosModel().apply { + deviceCapabilities = listOf("accelerometer", "arm64") + formFactor = "PHONE" + id = "iphone6s" + name = "iPhone 6s" + screenDensity = 326 + screenX = 750 + screenY = 1334 + supportedVersionIds = listOf("10.3", "11.2") + tags = listOf("deprecated=10.3", "deprecated=11.2") + } + ) val modelDescription = models.getDescription("iphone6s") val expected = """ @@ -44,16 +46,18 @@ class IosModelDescriptionTest { @Test fun `should return model without tag if no tags`() { - val models = listOf(IosModel().apply { - deviceCapabilities = listOf("accelerometer", "arm64") - formFactor = "PHONE" - id = "iphone6s" - name = "iPhone 6s" - screenDensity = 326 - screenX = 750 - screenY = 1334 - supportedVersionIds = listOf("10.3", "11.2") - }) + val models = listOf( + IosModel().apply { + deviceCapabilities = listOf("accelerometer", "arm64") + formFactor = "PHONE" + id = "iphone6s" + name = "iPhone 6s" + screenDensity = 326 + screenX = 750 + screenY = 1334 + supportedVersionIds = listOf("10.3", "11.2") + } + ) val modelDescription = models.getDescription("iphone6s") val expected = """ diff --git a/test_runner/src/test/kotlin/ftl/environment/ios/IosSoftwareVersionDescriptionTest.kt b/test_runner/src/test/kotlin/ftl/environment/ios/IosSoftwareVersionDescriptionTest.kt index 124f90c3dc..314144eea9 100644 --- a/test_runner/src/test/kotlin/ftl/environment/ios/IosSoftwareVersionDescriptionTest.kt +++ b/test_runner/src/test/kotlin/ftl/environment/ios/IosSoftwareVersionDescriptionTest.kt @@ -9,13 +9,15 @@ class IosSoftwareVersionDescriptionTest { @Test fun `should return software version with tag if any tag exists`() { val versionId = "11.2" - val versions = listOf(IosVersion().apply { - id = versionId - majorVersion = 10 - minorVersion = 3 - tags = listOf("default") - supportedXcodeVersionIds = listOf("10.2.1", "10.3", "11.0", "11.1", "11.2.1", "11.3.1") - }) + val versions = listOf( + IosVersion().apply { + id = versionId + majorVersion = 10 + minorVersion = 3 + tags = listOf("default") + supportedXcodeVersionIds = listOf("10.2.1", "10.3", "11.0", "11.1", "11.2.1", "11.3.1") + } + ) val localesDescription = versions.getDescription(versionId) val expected = """ @@ -38,13 +40,15 @@ class IosSoftwareVersionDescriptionTest { @Test fun `should return software version without tag not exist`() { val versionId = "11.2" - val versions = listOf(IosVersion().apply { - id = versionId - majorVersion = 10 - minorVersion = 3 - tags = null - supportedXcodeVersionIds = listOf("10.2.1", "10.3", "11.0", "11.1", "11.2.1", "11.3.1") - }) + val versions = listOf( + IosVersion().apply { + id = versionId + majorVersion = 10 + minorVersion = 3 + tags = null + supportedXcodeVersionIds = listOf("10.2.1", "10.3", "11.0", "11.1", "11.2.1", "11.3.1") + } + ) val localesDescription = versions.getDescription(versionId) val expected = """ diff --git a/test_runner/src/test/kotlin/ftl/filter/TestFiltersTest.kt b/test_runner/src/test/kotlin/ftl/filter/TestFiltersTest.kt index 019e18f2c5..6173266a34 100644 --- a/test_runner/src/test/kotlin/ftl/filter/TestFiltersTest.kt +++ b/test_runner/src/test/kotlin/ftl/filter/TestFiltersTest.kt @@ -62,7 +62,8 @@ class TestFiltersTest { @Test fun testIgnoreMultipleAnnotations() { val m1 = TestMethod( - "com.example.app.ExampleUiTest#testFails", listOf( + "com.example.app.ExampleUiTest#testFails", + listOf( TestAnnotation("org.junit.runner.RunWith", emptyMap(), false), TestAnnotation("org.junit.Ignore", emptyMap(), false), TestAnnotation("org.junit.Test", emptyMap(), false) diff --git a/test_runner/src/test/kotlin/ftl/gc/GcAndroidTestMatrixTest.kt b/test_runner/src/test/kotlin/ftl/gc/GcAndroidTestMatrixTest.kt index e35c69dee7..e57ced850f 100644 --- a/test_runner/src/test/kotlin/ftl/gc/GcAndroidTestMatrixTest.kt +++ b/test_runner/src/test/kotlin/ftl/gc/GcAndroidTestMatrixTest.kt @@ -119,7 +119,8 @@ class GcAndroidTestMatrixTest { val androidArgs = AndroidArgs.load(StringReader(yaml), null) val testSetup = TestSetup().setEnvironmentVariables( - androidArgs, AndroidTestConfig.Robo( + androidArgs, + AndroidTestConfig.Robo( appApkGcsPath = "", flankRoboDirectives = emptyList(), roboScriptGcsPath = "" @@ -146,7 +147,8 @@ class GcAndroidTestMatrixTest { val androidArgs = AndroidArgs.load(StringReader(yaml), null) val testSetup = TestSetup().setEnvironmentVariables( - androidArgs, AndroidTestConfig.Instrumentation( + androidArgs, + AndroidTestConfig.Instrumentation( appApkGcsPath = "", testApkGcsPath = "", testShards = emptyList(), @@ -174,7 +176,8 @@ class GcAndroidTestMatrixTest { val androidArgs = AndroidArgs.load(StringReader(yaml), null) val testSetup = TestSetup().setEnvironmentVariables( - androidArgs, AndroidTestConfig.Instrumentation( + androidArgs, + AndroidTestConfig.Instrumentation( appApkGcsPath = "", testApkGcsPath = "", testShards = emptyList(), @@ -203,7 +206,8 @@ class GcAndroidTestMatrixTest { val androidArgs = AndroidArgs.load(StringReader(yaml), null) val testSetup = TestSetup().setEnvironmentVariables( - androidArgs, AndroidTestConfig.Instrumentation( + androidArgs, + AndroidTestConfig.Instrumentation( appApkGcsPath = "", testApkGcsPath = "", testShards = emptyList(), @@ -232,7 +236,8 @@ class GcAndroidTestMatrixTest { val androidArgs = AndroidArgs.load(StringReader(yaml), null) val testSetup = TestSetup().setEnvironmentVariables( - androidArgs, AndroidTestConfig.Instrumentation( + androidArgs, + AndroidTestConfig.Instrumentation( appApkGcsPath = "", testApkGcsPath = "", testShards = emptyList(), diff --git a/test_runner/src/test/kotlin/ftl/json/MatrixMapTest.kt b/test_runner/src/test/kotlin/ftl/json/MatrixMapTest.kt index 49caf31b3f..286200d9e7 100644 --- a/test_runner/src/test/kotlin/ftl/json/MatrixMapTest.kt +++ b/test_runner/src/test/kotlin/ftl/json/MatrixMapTest.kt @@ -28,9 +28,11 @@ class MatrixMapTest { private fun matrixForExecution(executionId: Int): SavedMatrix { return createSavedMatrix( testMatrix = testMatrix() - .setResultStorage(createResultsStorage().apply { - toolResultsExecution.executionId = executionId.toString() - }) + .setResultStorage( + createResultsStorage().apply { + toolResultsExecution.executionId = executionId.toString() + } + ) .setState(MatrixState.FINISHED) .setTestMatrixId("123") .setTestExecutions( diff --git a/test_runner/src/test/kotlin/ftl/reports/outcome/CreateMatrixOutcomeSummaryKtTest.kt b/test_runner/src/test/kotlin/ftl/reports/outcome/CreateMatrixOutcomeSummaryKtTest.kt index f21e134b52..a39b7cb112 100644 --- a/test_runner/src/test/kotlin/ftl/reports/outcome/CreateMatrixOutcomeSummaryKtTest.kt +++ b/test_runner/src/test/kotlin/ftl/reports/outcome/CreateMatrixOutcomeSummaryKtTest.kt @@ -75,9 +75,11 @@ class CreateMatrixOutcomeSummaryKtTest { @Test fun `should create TestOutcome list for success robo test - from steps`() { - val steps: List = listOf(make { - outcome = make { summary = "success" } - }) + val steps: List = listOf( + make { + outcome = make { summary = "success" } + } + ) every { steps[0].axisValue() } returns "anyDevice" every { steps.calculateAndroidBillableMinutes(any(), any()) } returns make() val context = TestOutcomeContext( @@ -98,12 +100,14 @@ class CreateMatrixOutcomeSummaryKtTest { @Test fun `should create TestOutcome list for failed robo test - from steps`() { - val steps: List = listOf(make { - outcome = make { - summary = "failure" - failureDetail = make { failedRoboscript = true } + val steps: List = listOf( + make { + outcome = make { + summary = "failure" + failureDetail = make { failedRoboscript = true } + } } - }) + ) every { steps[0].axisValue() } returns "anyDevice" every { steps.calculateAndroidBillableMinutes(any(), any()) } returns make() val context = TestOutcomeContext( diff --git a/test_runner/src/test/kotlin/ftl/reports/xml/JUnitXmlTest.kt b/test_runner/src/test/kotlin/ftl/reports/xml/JUnitXmlTest.kt index aa99c7088f..3783dbf4e4 100644 --- a/test_runner/src/test/kotlin/ftl/reports/xml/JUnitXmlTest.kt +++ b/test_runner/src/test/kotlin/ftl/reports/xml/JUnitXmlTest.kt @@ -381,7 +381,6 @@ junit.framework.Assert.fail(Assert.java:50) @Test fun `merge testTimes`() { - /** * 1. First run generates local merged JUnit XML * - Firbase XML downloaded from each shard diff --git a/test_runner/src/test/kotlin/ftl/run/GenericTestRunnerTest.kt b/test_runner/src/test/kotlin/ftl/run/GenericTestRunnerTest.kt index fb54d6fe7b..10b31321d7 100644 --- a/test_runner/src/test/kotlin/ftl/run/GenericTestRunnerTest.kt +++ b/test_runner/src/test/kotlin/ftl/run/GenericTestRunnerTest.kt @@ -36,7 +36,8 @@ class GenericTestRunnerTest { fun testBeforeRunMessage2() { val result = beforeRunMessage(createMock(2), listOf(Chunk(listOf(TestMethod(name = "", time = 0.0))))).normalizeLineEnding() assert( - result, """ + result, + """ 1 test / 1 shard Running 2x 2 total shards @@ -52,7 +53,8 @@ class GenericTestRunnerTest { List(6) { Chunk(listOf(TestMethod(name = "", time = 0.0))) } ).normalizeLineEnding() assert( - result, """ + result, + """ 6 tests / 6 shards Running 2x 12 total shards @@ -68,7 +70,8 @@ class GenericTestRunnerTest { List(2) { Chunk(List(5) { TestMethod(name = "", time = 0.0) }) } ).normalizeLineEnding() assert( - result, """ + result, + """ 10 tests / 2 shards Running 100x 200 total shards @@ -86,23 +89,27 @@ class GenericTestRunnerTest { val result = beforeRunMessage( createMock(1), listOf( - Chunk(listOf( - TestMethod(name = "t1", time = 0.0), - TestMethod(name = "t2", time = 0.0), - TestMethod(name = "t3", time = 0.0), - TestMethod(name = "c1", time = 0.0, isParameterized = true), - TestMethod(name = "c2", time = 0.0, isParameterized = true), - )), - Chunk(listOf( - TestMethod(name = "t4", time = 0.0), - TestMethod(name = "t5", time = 0.0), - TestMethod(name = "t6", time = 0.0), - TestMethod(name = "t7", time = 0.0), - TestMethod(name = "t8", time = 0.0), - TestMethod(name = "t9", time = 0.0), - TestMethod(name = "t10", time = 0.0), - TestMethod(name = "c3", time = 0.0, isParameterized = true), - )) + Chunk( + listOf( + TestMethod(name = "t1", time = 0.0), + TestMethod(name = "t2", time = 0.0), + TestMethod(name = "t3", time = 0.0), + TestMethod(name = "c1", time = 0.0, isParameterized = true), + TestMethod(name = "c2", time = 0.0, isParameterized = true), + ) + ), + Chunk( + listOf( + TestMethod(name = "t4", time = 0.0), + TestMethod(name = "t5", time = 0.0), + TestMethod(name = "t6", time = 0.0), + TestMethod(name = "t7", time = 0.0), + TestMethod(name = "t8", time = 0.0), + TestMethod(name = "t9", time = 0.0), + TestMethod(name = "t10", time = 0.0), + TestMethod(name = "c3", time = 0.0, isParameterized = true), + ) + ) ) ).normalizeLineEnding().trimIndent() @@ -118,13 +125,17 @@ class GenericTestRunnerTest { val result = beforeRunMessage( createMock(1), listOf( - Chunk(listOf( - TestMethod(name = "c1", time = 0.0, isParameterized = true), - TestMethod(name = "c2", time = 0.0, isParameterized = true), - )), - Chunk(listOf( - TestMethod(name = "c3", time = 0.0, isParameterized = true), - )) + Chunk( + listOf( + TestMethod(name = "c1", time = 0.0, isParameterized = true), + TestMethod(name = "c2", time = 0.0, isParameterized = true), + ) + ), + Chunk( + listOf( + TestMethod(name = "c3", time = 0.0, isParameterized = true), + ) + ) ) ).normalizeLineEnding().trimIndent() @@ -144,23 +155,27 @@ class GenericTestRunnerTest { val result = beforeRunMessage( createMock(10), listOf( - Chunk(listOf( - TestMethod(name = "t1", time = 0.0), - TestMethod(name = "t2", time = 0.0), - TestMethod(name = "t3", time = 0.0), - TestMethod(name = "c1", time = 0.0, isParameterized = true), - TestMethod(name = "c2", time = 0.0, isParameterized = true), - )), - Chunk(listOf( - TestMethod(name = "t4", time = 0.0), - TestMethod(name = "t5", time = 0.0), - TestMethod(name = "t6", time = 0.0), - TestMethod(name = "t7", time = 0.0), - TestMethod(name = "t8", time = 0.0), - TestMethod(name = "t9", time = 0.0), - TestMethod(name = "t10", time = 0.0), - TestMethod(name = "c3", time = 0.0, isParameterized = true), - )) + Chunk( + listOf( + TestMethod(name = "t1", time = 0.0), + TestMethod(name = "t2", time = 0.0), + TestMethod(name = "t3", time = 0.0), + TestMethod(name = "c1", time = 0.0, isParameterized = true), + TestMethod(name = "c2", time = 0.0, isParameterized = true), + ) + ), + Chunk( + listOf( + TestMethod(name = "t4", time = 0.0), + TestMethod(name = "t5", time = 0.0), + TestMethod(name = "t6", time = 0.0), + TestMethod(name = "t7", time = 0.0), + TestMethod(name = "t8", time = 0.0), + TestMethod(name = "t9", time = 0.0), + TestMethod(name = "t10", time = 0.0), + TestMethod(name = "c3", time = 0.0, isParameterized = true), + ) + ) ) ).normalizeLineEnding().trimIndent() @@ -179,13 +194,17 @@ class GenericTestRunnerTest { val result = beforeRunMessage( createMock(10), listOf( - Chunk(listOf( - TestMethod(name = "c1", time = 0.0, isParameterized = true), - TestMethod(name = "c2", time = 0.0, isParameterized = true), - )), - Chunk(listOf( - TestMethod(name = "c3", time = 0.0, isParameterized = true), - )) + Chunk( + listOf( + TestMethod(name = "c1", time = 0.0, isParameterized = true), + TestMethod(name = "c2", time = 0.0, isParameterized = true), + ) + ), + Chunk( + listOf( + TestMethod(name = "c3", time = 0.0, isParameterized = true), + ) + ) ) ).normalizeLineEnding().trimIndent() diff --git a/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt b/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt index 03125ac8fe..2e12eb01f3 100644 --- a/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt +++ b/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt @@ -186,12 +186,14 @@ class TestRunnerTest { private fun getMockedTestMatrix() = TestMatrix().apply { state = "INVALID" testMatrixId = "matrix-12345" - testExecutions = listOf(TestExecution().apply { - resultStorage = ResultStorage().apply { - googleCloudStorage = GoogleCloudStorage().apply { - gcsPath = "any/Path" + testExecutions = listOf( + TestExecution().apply { + resultStorage = ResultStorage().apply { + googleCloudStorage = GoogleCloudStorage().apply { + gcsPath = "any/Path" + } } } - }) + ) } } diff --git a/test_runner/src/test/kotlin/ftl/run/platform/android/IgnoreTestsAnnotationTest.kt b/test_runner/src/test/kotlin/ftl/run/platform/android/IgnoreTestsAnnotationTest.kt index a6483fef8c..e50c74581b 100644 --- a/test_runner/src/test/kotlin/ftl/run/platform/android/IgnoreTestsAnnotationTest.kt +++ b/test_runner/src/test/kotlin/ftl/run/platform/android/IgnoreTestsAnnotationTest.kt @@ -30,7 +30,6 @@ class IgnoreTestsAnnotationTest { @Test fun `InstrumentationContext with @Supress annotation shouldn't have ignoredTestCases in shards`() { - val testContext = runBlocking { AndroidArgs.load(singleSuccessYaml).createAndroidTestContexts() }.single() as InstrumentationTestContext diff --git a/test_runner/src/test/kotlin/ftl/shard/ShardCountTest.kt b/test_runner/src/test/kotlin/ftl/shard/ShardCountTest.kt index 2fa924ac7d..15ff25d291 100644 --- a/test_runner/src/test/kotlin/ftl/shard/ShardCountTest.kt +++ b/test_runner/src/test/kotlin/ftl/shard/ShardCountTest.kt @@ -47,7 +47,8 @@ class ShardCountTest { val result = shardCountByTime( testsToRun, suite, - mockArgs(maxTestShards = -1, shardTime = DEFAULT_TEST_TIME_SEC.toInt())) + mockArgs(maxTestShards = -1, shardTime = DEFAULT_TEST_TIME_SEC.toInt()) + ) assertThat(result).isEqualTo(3) } @@ -60,7 +61,8 @@ class ShardCountTest { val result = shardCountByTime( testsToRun, suite, - mockArgs(maxTestShards = -1, shardTime = DEFAULT_TEST_TIME_SEC.toInt() + 1)) + mockArgs(maxTestShards = -1, shardTime = DEFAULT_TEST_TIME_SEC.toInt() + 1) + ) assertThat(result).isEqualTo(3) } @@ -72,7 +74,8 @@ class ShardCountTest { val result = shardCountByTime( testsToRun, suite, - mockArgs(maxTestShards = -1, shardTime = (DEFAULT_TEST_TIME_SEC * 2).toInt())) + mockArgs(maxTestShards = -1, shardTime = (DEFAULT_TEST_TIME_SEC * 2).toInt()) + ) assertThat(result).isEqualTo(1) } diff --git a/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt b/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt index 20a8a478f7..ff879dfd52 100644 --- a/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt +++ b/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt @@ -108,44 +108,49 @@ class ShardTest { @Test(expected = FlankConfigurationError::class) fun `createShardsByShardCount throws on forcedShardCount = 0`() { createShardsByShardCount( - listOf(), - sample(), - mockArgs(-1, 7), - 0) + listOf(), + sample(), + mockArgs(-1, 7), + 0 + ) } private fun newSuite(testCases: MutableList): JUnitTestResult { - return JUnitTestResult(mutableListOf( + return JUnitTestResult( + mutableListOf( JUnitTestSuite("", - "3", - "0", - -1, - "0", - "0", - "12.032", - "2019-07-27T08:15:04", - "localhost", - "matrix-1234_execution-asdf", - testCases, - null, - null, - null))) + "3", + "0", + -1, + "0", + "0", + "12.032", + "2019-07-27T08:15:04", + "localhost", + "matrix-1234_execution-asdf", + testCases, + null, + null, + null) + ) + ) } private fun shardCountByTime(shardTime: Int): Int { val testsToRun = listOfFlankTestMethod("a/a", "b/b", "c/c") val testCases = mutableListOf( - JUnitTestCase("a", "a", "0.001"), - JUnitTestCase("b", "b", "0.0"), - JUnitTestCase("c", "c", "0.0") + JUnitTestCase("a", "a", "0.001"), + JUnitTestCase("b", "b", "0.0"), + JUnitTestCase("c", "c", "0.0") ) val oldTestResult = newSuite(testCases) return shardCountByTime( - testsToRun, - oldTestResult, - mockArgs(-1, shardTime)) + testsToRun, + oldTestResult, + mockArgs(-1, shardTime) + ) } @Test(expected = FlankConfigurationError::class) @@ -188,11 +193,13 @@ class ShardTest { FlankTestMethod("c/c") ) - val oldTestResult = newSuite(mutableListOf( - JUnitTestCase("a", "a", "5.0"), - JUnitTestCase("b", "b", "10.0"), - JUnitTestCase("c", "c", "10.0") - )) + val oldTestResult = newSuite( + mutableListOf( + JUnitTestCase("a", "a", "5.0"), + JUnitTestCase("b", "b", "10.0"), + JUnitTestCase("c", "c", "10.0") + ) + ) val shardCount = shardCountByTime(testsToRun, oldTestResult, androidMockedArgs) assertEquals(2, shardCount) diff --git a/test_runner/src/test/kotlin/ftl/shard/ShardTestCommon.kt b/test_runner/src/test/kotlin/ftl/shard/ShardTestCommon.kt index 263533b085..bc2408e133 100644 --- a/test_runner/src/test/kotlin/ftl/shard/ShardTestCommon.kt +++ b/test_runner/src/test/kotlin/ftl/shard/ShardTestCommon.kt @@ -10,7 +10,6 @@ import io.mockk.every import io.mockk.mockk internal fun sample(): JUnitTestResult { - val testCases = mutableListOf( JUnitTestCase("a", "a", "1.0"), JUnitTestCase("b", "b", "2.0"), diff --git a/test_runner/src/test/kotlin/ftl/shard/TestMethodTimeTest.kt b/test_runner/src/test/kotlin/ftl/shard/TestMethodTimeTest.kt index 3e774dcf4b..470bcc6fba 100644 --- a/test_runner/src/test/kotlin/ftl/shard/TestMethodTimeTest.kt +++ b/test_runner/src/test/kotlin/ftl/shard/TestMethodTimeTest.kt @@ -11,7 +11,9 @@ class TestMethodTimeTest { val expected = DEFAULT_CLASS_TEST_TIME_SEC val actual = getTestMethodTime( FlankTestMethod(testName = "test#Parametrized1", isParameterizedClass = true), - emptyMap(), DEFAULT_TEST_TIME_SEC, expected + emptyMap(), + DEFAULT_TEST_TIME_SEC, + expected ) assertEquals(expected, actual) } @@ -21,7 +23,9 @@ class TestMethodTimeTest { val expected = DEFAULT_TEST_TIME_SEC val actual = getTestMethodTime( FlankTestMethod(testName = "test#NotParametrized1"), - emptyMap(), expected, DEFAULT_CLASS_TEST_TIME_SEC + emptyMap(), + expected, + DEFAULT_CLASS_TEST_TIME_SEC ) assertEquals(expected, actual) } diff --git a/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt b/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt index fd27b7af5d..650810c259 100644 --- a/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt +++ b/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt @@ -350,7 +350,10 @@ class UtilsTest { val simulatedMain: Thread = object : Thread("simulated-main") { override fun run() { val pb = ProcessBuilder( - "java", "-cp", System.getProperty("java.class.path"), HangingApp::class.java.name + "java", + "-cp", + System.getProperty("java.class.path"), + HangingApp::class.java.name ).redirectError(File(VERIFICATION_FILE)) try { val process = pb.start()