Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Adamczyk committed Sep 29, 2020
1 parent f141364 commit c2d2f6d
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 171 deletions.
44 changes: 25 additions & 19 deletions test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ 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" +
"or save service account credential to ${defaultCredentialPath}\n" +
" See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id"
"or save service account credential to ${defaultCredentialPath}\n" +
" See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id"
)

if (args.maxTestShards !in AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE && args.maxTestShards != -1)
Expand Down Expand Up @@ -116,7 +117,12 @@ object ArgsHelper {
GcStorage.storage.get(bucket, path) ?: throw FlankGeneralError("The file at '$uri' does not exist")
}

fun validateTestMethods(testTargets: List<String>, validTestMethods: Collection<String>, from: String, skipValidation: Boolean = useMock) {
fun validateTestMethods(
testTargets: List<String>,
validTestMethods: Collection<String>,
from: String,
skipValidation: Boolean = useMock
) {
val missingMethods = testTargets - validTestMethods

if (!skipValidation && missingMethods.isNotEmpty()) throw FlankConfigurationError("$from is missing methods: $missingMethods.\nValid methods:\n$validTestMethods")
Expand All @@ -133,17 +139,17 @@ 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
// because we don't have access to the root account, it won't show up in the storage list.
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"

Expand All @@ -161,10 +167,10 @@ object ArgsHelper {
try {
storage.create(
BucketInfo.newBuilder(bucket)
.setStorageClass(StorageClass.REGIONAL)
.setLocation(storageLocation)
.setLabels(bucketLabel)
.build()
.setStorageClass(StorageClass.REGIONAL)
.setLocation(storageLocation)
.setLabels(bucketLabel)
.build()
)
} catch (e: Exception) {
println("Warning: Failed to make bucket for $projectId\nCause: ${e.message}")
Expand Down Expand Up @@ -264,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
}
9 changes: 5 additions & 4 deletions test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)

Expand Down Expand Up @@ -71,8 +73,7 @@ If this project has already been granted access, please make sure you are using
on the Blaze or Flame billing plans, and that you have run
gcloud config set billing/quota_project project
If you are still having issues, please email [email protected] for support.""",
e
If you are still having issues, please email [email protected] for support.""", e
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ private fun TestExecutionData.reduceTestCases() = copy(
}
)

internal fun List<TestExecutionData>.removeStackTraces(): List<TestExecutionData> = map(TestExecutionData::removeStackTraces)
internal fun List<TestExecutionData>.removeStackTraces(): List<TestExecutionData> =
map(TestExecutionData::removeStackTraces)

private fun TestExecutionData.removeStackTraces() = copy(
testCases = testCases.onEach {
if (it.flaky) {
it.stackTraces = emptyList()
}
}
if (it.flaky) it.stackTraces = emptyList()
}
)

// For primary step return stepId instead of primaryStepId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ enum class OutcomeMessageEnum(val message: String) {
),
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."
"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"),
Expand Down
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ object ReportManager {
matrices,
testSuite?.apply {
if (ignoredTestCases.isNotEmpty()) {
testsuites?.add(ignoredTestCases.toJunitTestsResults())
}
testsuites?.add(ignoredTestCases.toJunitTestsResults())
}
},
printToStdout = false,
args = args
Expand Down
4 changes: 2 additions & 2 deletions test_runner/src/test/kotlin/ftl/args/ArgsHelperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class ArgsHelperTest {
val merged = mergeYmlKeys(
mockk() {
every { keys } returns listOf("devices", "test", "apk")
every { group } returns "gcloud"
every { group } returns "gcloud"
},
mockk() {
every { keys } returns listOf("xcode-version", "async", "client-details")
every { group } returns "gcloud"
every { group } returns "gcloud"
}
)

Expand Down
3 changes: 1 addition & 2 deletions test_runner/src/test/kotlin/ftl/cli/auth/LoginCommandTest.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -27,7 +26,7 @@ class LoginCommandTest {
CommandLine(command).execute("-h")

val output = systemOutRule.log.normalizeLineEnding()
Truth.assertThat(output).startsWith(
assertThat(output).startsWith(
"""Obtains access credentials for your user account via a web-based authorization
flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ class IPBlocksListCommandTest {
fun `should print ips for devices`() {
val ips = listOf(
DeviceIpBlock().apply {
block = "1.1.1.1/1"
block = "1.1.1.1/1"
form = "AnyForm"
addedDate = Date().apply {
day = 1
day = 1
month = 1
year = 1111
}
},
}
},
DeviceIpBlock().apply {
block = "2.2.2.2/2"
block = "2.2.2.2/2"
form = "OtherForm"
addedDate = Date().apply {
day = 12
day = 12
month = 12
year = 1212
}
}
}
}
)

every { deviceIPBlocks() } returns ips
Expand Down Expand Up @@ -93,50 +93,50 @@ class IPBlocksListCommandTest {
fun `should not fail when FTL returns null in any of values`() {
val ips = listOf(
DeviceIpBlock().apply {
block = "1.1.1.1/1"
block = "1.1.1.1/1"
form = "AnyForm"
addedDate = Date().apply {
day = null
day = null
month = 1
year = 1111
}
},
}
},
DeviceIpBlock().apply {
block = null
block = null
form = "MissingIpForm"
addedDate = Date().apply {
day = 12
day = 12
month = 2
year = 1212
}
},
}
},
DeviceIpBlock().apply {
block = "2.2.2.2/2"
block = "2.2.2.2/2"
form = "OtherForm"
addedDate = Date().apply {
day = 12
day = 12
month = null
year = 1212
}
},
}
},
DeviceIpBlock().apply {
block = "3.3.3.3/4"
block = "3.3.3.3/4"
form = "FunnyForm"
addedDate = Date().apply {
day = 8
day = 8
month = 2
year = null
}
},
}
},
DeviceIpBlock().apply {
block = "4.4.4.4/4"
block = "4.4.4.4/4"
form = null
addedDate = Date().apply {
day = 8
day = 8
month = 2
year = 1523
}
}
}
}
)

every { deviceIPBlocks() } returns ips
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class NetworkProfileDescribeTest {
fun `should print profile description if data exists`() {
val configs = listOf(
NetworkConfiguration().apply {
downRule = makeRule(0.5f)
downRule = makeRule(0.5f)
upRule = makeRule(0.8f)
id = "ANY"
},
},
NetworkConfiguration().apply {
downRule = makeRule(0.1f)
downRule = makeRule(0.1f)
upRule = makeRule(0.2f)
id = "DIFFERENT"
}
}
)
every { getNetworkConfiguration() } returns configs

Expand Down Expand Up @@ -88,20 +88,20 @@ class NetworkProfileDescribeTest {
fun `should print message if unable to find provided profile`() {
val configs = listOf(
NetworkConfiguration().apply {
downRule = makeRule(0.456f)
downRule = makeRule(0.456f)
id = "ANY_1"
upRule = makeRule(0.111f)
},
},
NetworkConfiguration().apply {
downRule = makeRule(0.0976f)
downRule = makeRule(0.0976f)
id = "ANY_2"
upRule = makeRule(0.234f)
},
},
NetworkConfiguration().apply {
downRule = makeRule(0.1f)
downRule = makeRule(0.1f)
id = "ANY_3"
upRule = makeRule(0.11233f)
}
}
)
every { getNetworkConfiguration() } returns configs

Expand All @@ -118,10 +118,10 @@ class NetworkProfileDescribeTest {
fun `should handle possible null values`() {
val configs = listOf(
NetworkConfiguration().apply {
downRule = makeRule(0.456f)
downRule = makeRule(0.456f)
id = "WITH_NULLS"
upRule = TrafficRule().apply { packetLossRatio = 0.123f }
}
}
)
every { getNetworkConfiguration() } returns configs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class LocalesDescribeTest {
val locales = listOf(
Locale().apply {
id = "test"
name = "name_test"
tags = listOf("one", "second")
name = "name_test"
tags = listOf("one", "second")
}
)

Expand All @@ -32,7 +32,7 @@ tags = listOf("one", "second")
val locales = listOf(
Locale().apply {
id = "test"
name = "name_test"
name = "name_test"
}
)

Expand Down
Loading

0 comments on commit c2d2f6d

Please sign in to comment.