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 0e5a729
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 139 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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ class AndroidModelDescriptionTest {
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"
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"
}
)

Expand Down Expand Up @@ -60,18 +61,19 @@ thumbnailUrl = "https://lh3.googleusercontent.com/j4urvb3lXTaFGZI6IzHmAjum2HQVID
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"
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"
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class AndroidSoftwareVersionDescriptionTest {
val versions = listOf(
AndroidVersion().apply {
id = "26"
apiLevel = 26
codeName = "Oreo"
versionString = "8.0.x"
releaseDate = Date().apply {
apiLevel = 26
codeName = "Oreo"
versionString = "8.0.x"
releaseDate = Date().apply {
day = 21
month = 8
year = 2017
month = 8
year = 2017
}
tags = listOf("default")
tags = listOf("default")
}
)

Expand All @@ -45,13 +45,13 @@ tags = listOf("default")
val versions = listOf(
AndroidVersion().apply {
id = "23"
apiLevel = 23
codeName = "Marshmallow"
versionString = "6.0.x"
releaseDate = Date().apply {
apiLevel = 23
codeName = "Marshmallow"
versionString = "6.0.x"
releaseDate = Date().apply {
day = 5
month = 10
year = 2015
month = 10
year = 2015
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class IosModelDescriptionTest {
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")
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")
}
)

Expand Down Expand Up @@ -49,13 +49,13 @@ 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")
formFactor = "PHONE"
id = "iphone6s"
name = "iPhone 6s"
screenDensity = 326
screenX = 750
screenY = 1334
supportedVersionIds = listOf("10.3", "11.2")
}
)

Expand Down
Loading

0 comments on commit 0e5a729

Please sign in to comment.