Skip to content

Commit

Permalink
Merge branch 'master' into #685-ios-support-for-testplans
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-goral authored Nov 3, 2020
2 parents 09cb4b5 + 1c68cc9 commit d4bc0a2
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 19 deletions.
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Versions {
const val KOTLIN = "1.4.10"

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

// https://github.com/remkop/picocli/releases
const val PICOCLI = "4.5.2"
Expand All @@ -38,7 +38,7 @@ object Versions {
const val GOOGLE_NIO = "0.121.2"

// https://search.maven.org/search?q=a:google-cloud-storage%20g:com.google.cloud
const val GOOGLE_STORAGE = "1.113.1"
const val GOOGLE_STORAGE = "1.113.2"

// https://github.com/google/gson/releases
const val GSON = "2.8.6"
Expand Down Expand Up @@ -79,7 +79,7 @@ object Versions {
const val COMMON_TEXT = "1.9"

// https://github.com/fusesource/jansi/releases
const val JANSI = "1.18"
const val JANSI = "2.0.1"

// https://github.com/ben-manes/gradle-versions-plugin/releases
const val BEN_MANES = "0.33.0"
Expand All @@ -88,9 +88,9 @@ object Versions {
const val PROGUARD = "7.0.0"

// ============== flank-scripts ==============
const val KOTLIN_SERIALIZATION = "1.0.1"
const val ARCHIVE_LIB = "1.1.0"
const val TUKAANI_XZ = "1.0"
const val KOTLIN_SERIALIZATION = "1.0.0"
const val FUEL = "2.3.0"
const val CLIKT = "2.8.0"
const val JCABI_GITHUB = "1.1.2"
Expand Down
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ gcloud:
## The type of iOS test to run. TYPE must be one of: xctest, game-loop. Default: xctest
# type: xctest

## Enables testing special app entitlements. Re-signs an app having special entitlements with a new application-identifier.
## This currently supports testing Push Notifications (aps-environment) entitlement for up to one app in a project.
## Note: Because this changes the app's identifier, make sure none of the resources in your zip file contain direct references to the test app's bundle id.
# test-special-entitlements: false

flank:
# -- FlankYml --

Expand Down
7 changes: 6 additions & 1 deletion test_runner/flank.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ gcloud:
## The type of iOS test to run. TYPE must be one of: xctest, game-loop. Default: xctest
# type: xctest

## Enables testing special app entitlements. Re-signs an app having special entitlements with a new application-identifier.
## This currently supports testing Push Notifications (aps-environment) entitlement for up to one app in a project.
## Note: Because this changes the app's identifier, make sure none of the resources in your zip file contain direct references to the test app's bundle id.
# test-special-entitlements: false

flank:
# -- FlankYml --

Expand Down Expand Up @@ -144,7 +149,7 @@ flank:
## Default: 240.0
# default-class-test-time: 30

## Disables sharding. Useful for parameterized tests.
## Disables sharding. Useful for parameterized tests.
# disable-sharding: false

## always run - these tests are inserted at the beginning of every shard
Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/CreateCommonArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ private val CommonConfig.defaultOutputStyle

private val CommonConfig.hasMultipleExecutions
get() = gcloud.flakyTestAttempts!! > 0 ||
(!flank.disableSharding!! && flank.maxTestShards!! > 0)
(!flank.disableSharding!! && flank.maxTestShards!! > 1)
3 changes: 2 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/CreateIosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ private fun createIosArgs(
xcodeVersion = gcloud.xcodeVersion,
additionalIpas = gcloud.additionalIpas!!.map { it.normalizeFilePath() },
testTargets = flank.testTargets?.filterNotNull().orEmpty(),
obfuscateDumpShards = obfuscate
obfuscateDumpShards = obfuscate,
testSpecialEntitlements = gcloud.testSpecialEntitlements ?: false
)

private fun convertToShardCount(inputValue: Int) =
Expand Down
4 changes: 3 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ data class IosArgs(
val xcodeVersion: String?,
val testTargets: List<String>,
val obfuscateDumpShards: Boolean,
val additionalIpas: List<String>
val additionalIpas: List<String>,
val testSpecialEntitlements: Boolean?
) : IArgs by commonArgs {

override val useLegacyJUnitResult = true
Expand Down Expand Up @@ -45,6 +46,7 @@ IosArgs
additional-ipas: ${ArgsToString.listToString(additionalIpas)}
scenario-numbers: ${ArgsToString.listToString(scenarioNumbers)}
type: ${type?.ymlName}
test-special-entitlements: $testSpecialEntitlements
flank:
max-test-shards: $maxTestShards
Expand Down
12 changes: 12 additions & 0 deletions test_runner/src/main/kotlin/ftl/config/ios/IosGcloudConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ data class IosGcloudConfig @JsonIgnore constructor(
@set:JsonProperty("additional-ipas")
var additionalIpas: List<String>? by data

@set:CommandLine.Option(
names = ["--test-special-entitlements"],
description = ["Enables testing special app entitlements. Re-signs an app having special entitlements with a new" +
" application-identifier. This currently supports testing Push Notifications (aps-environment) entitlement " +
"for up to one app in a project.\n" +
"Note: Because this changes the app's identifier, make sure none of the resources in your zip file contain " +
"direct references to the test app's bundle id."]
)
@set:JsonProperty("test-special-entitlements")
var testSpecialEntitlements: Boolean? by data

constructor() : this(mutableMapOf<String, Any?>().withDefault { null })

companion object : IYmlKeys {
Expand All @@ -73,6 +84,7 @@ data class IosGcloudConfig @JsonIgnore constructor(
xctestrunFile = null
xcodeVersion = null
additionalIpas = emptyList()
testSpecialEntitlements = false
}
}
}
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/gc/GcIosTestMatrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ object GcIosTestMatrix {
.setTestsZip(FileReference().setGcsPath(testZipGcsPath))
.setXctestrun(FileReference().setGcsPath(xctestrunFileGcsPath))
.setXcodeVersion(args.xcodeVersion)
.setTestSpecialEntitlements(args.testSpecialEntitlements)

val iOSTestSetup = IosTestSetup()
.setNetworkProfile(args.networkProfile)
Expand Down
7 changes: 5 additions & 2 deletions test_runner/src/test/kotlin/Debug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ fun main() {
// run "gradle check" to generate required fixtures
val projectId = System.getenv("GOOGLE_CLOUD_PROJECT")
?: "YOUR PROJECT ID"
/*
val quantity = "multiple"
val type = "gameloop"
val extra = "obb"
*/

// Bugsnag keeps the process alive so we must call exitProcess
// https://github.com/bugsnag/bugsnag-java/issues/151
Expand All @@ -24,14 +26,15 @@ fun main() {
// "--debug",
"firebase",
"test",
"android",
"ios",
"run",
// "--dry",
// "--dump-shards",
"--output-style=single",
// "--full-junit-result",
// "--legacy-junit-result",
"-c=test_runner/src/test/kotlin/ftl/fixtures/test_app_cases/flank-$quantity-$type-$extra.yml",
"-c=/Users/piotr/Projekty/gogo/flank/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml",
// "-c=test_runner/src/test/kotlin/ftl/fixtures/test_app_cases/flank-$quantity-$type-$extra.yml",
"--project=$projectId"
// "--client-details=key1=value1,key2=value2"
)
Expand Down
10 changes: 5 additions & 5 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ AndroidArgs
run-timeout: -1
legacy-junit-result: true
ignore-failed-tests: false
output-style: multi
output-style: verbose
disable-results-upload: false
default-class-test-time: 240.0
""".trimIndent(),
Expand Down Expand Up @@ -488,7 +488,7 @@ AndroidArgs
assert(testTargetsAlwaysRun, empty)
assert(disableSharding, false)
assert(runTimeout, "-1")
assert(outputStyle, OutputStyle.Multi)
assert(outputStyle, OutputStyle.Verbose)
assert(fullJUnitResult, false)
}
}
Expand Down Expand Up @@ -1199,17 +1199,17 @@ AndroidArgs
@Test
fun `cli output-style`() {
val cli = AndroidRunCommand()
CommandLine(cli).parseArgs("--output-style=verbose")
CommandLine(cli).parseArgs("--output-style=multi")

val yaml = """
gcloud:
app: $appApk
test: $testApk
"""
assertThat(AndroidArgs.load(yaml).validate().outputStyle).isEqualTo(OutputStyle.Multi)
assertThat(AndroidArgs.load(yaml).validate().outputStyle).isEqualTo(OutputStyle.Verbose)

val args = AndroidArgs.load(yaml, cli).validate()
assertThat(args.outputStyle).isEqualTo(OutputStyle.Verbose)
assertThat(args.outputStyle).isEqualTo(OutputStyle.Multi)
}

@Test(expected = FlankConfigurationError::class)
Expand Down
11 changes: 7 additions & 4 deletions test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class IosArgsTest {
orientation: default
num-flaky-test-attempts: 4
type: xctest
test-special-entitlements: true
flank:
max-test-shards: 7
Expand Down Expand Up @@ -244,6 +245,7 @@ IosArgs
- $testIpa2
scenario-numbers:
type: xctest
test-special-entitlements: true
flank:
max-test-shards: 7
Expand Down Expand Up @@ -306,6 +308,7 @@ IosArgs
additional-ipas:
scenario-numbers:
type: xctest
test-special-entitlements: false
flank:
max-test-shards: 1
Expand All @@ -326,7 +329,7 @@ IosArgs
local-result-dir: results
run-timeout: -1
ignore-failed-tests: false
output-style: multi
output-style: verbose
disable-results-upload: false
default-class-test-time: 240.0
""".trimIndent(),
Expand Down Expand Up @@ -858,17 +861,17 @@ IosArgs
@Test
fun `cli output-style`() {
val cli = IosRunCommand()
CommandLine(cli).parseArgs("--output-style=verbose")
CommandLine(cli).parseArgs("--output-style=multi")

val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
"""
assertThat(IosArgs.load(yaml).outputStyle).isEqualTo(OutputStyle.Multi)
assertThat(IosArgs.load(yaml).outputStyle).isEqualTo(OutputStyle.Verbose)

val args = IosArgs.load(yaml, cli)
assertThat(args.outputStyle).isEqualTo(OutputStyle.Verbose)
assertThat(args.outputStyle).isEqualTo(OutputStyle.Multi)
}

private fun getValidTestsSample() = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,12 @@ class IosRunCommandTest {

assertThat(cmd.config.common.gcloud.type).isEqualTo("a")
}

@Test
fun `should properly parse test-special-entitlements`() {
val cmd = IosRunCommand()
CommandLine(cmd).parseArgs("--test-special-entitlements")

assertThat(cmd.config.platform.gcloud.testSpecialEntitlements).isEqualTo(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.mockk.every
import io.mockk.spyk
import io.mockk.verify
import org.fusesource.jansi.Ansi
import org.fusesource.jansi.AnsiConsole
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
Expand All @@ -21,6 +22,7 @@ class MultiLinePrinterTest {
// given
val ansi = spyk(Ansi.ansi()) { every { this@spyk.toString() } returns "" }
val printChanges = MultiLinePrinter { ansi }
AnsiConsole.systemUninstall()

// when
printChanges(changes1)
Expand Down

0 comments on commit d4bc0a2

Please sign in to comment.