Skip to content

Commit

Permalink
feat: add ios app for gameloop (#1289)
Browse files Browse the repository at this point in the history
* Commit for testing puposes

* Added app for ios v1

* Added tests and fixed crashes

* add app defaults

* Fix tests after merge

Co-authored-by: piotradamczyk5 <[email protected]>
  • Loading branch information
Sloox and piotradamczyk5 authored Nov 3, 2020
1 parent 1c68cc9 commit c74489e
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ gcloud:

## The type of iOS test to run. TYPE must be one of: xctest, game-loop. Default: xctest
# type: xctest

## The path to the application archive (.ipa file) for game-loop testing.
## The path may be in the local filesystem or in Google Cloud Storage using gs:// notation.
## This flag is only valid when --type=game-loop is also set
# app:
# - gs://bucket/additional.ipa OR path/to/local/ipa/file.ipa


## 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.
Expand Down
6 changes: 6 additions & 0 deletions test_runner/flank.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ gcloud:
# - 2
# - 3

## The path to the application archive (.ipa file) for game-loop testing.
## The path may be in the local filesystem or in Google Cloud Storage using gs:// notation.
## This flag is only valid when --type=game-loop is also set
# app:
# - gs://bucket/additional.ipa OR path/to/local/ipa/file.ipa

## The type of iOS test to run. TYPE must be one of: xctest, game-loop. Default: xctest
# type: xctest

Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/args/CreateIosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private fun createIosArgs(
additionalIpas = gcloud.additionalIpas!!.map { it.normalizeFilePath() },
testTargets = flank.testTargets?.filterNotNull().orEmpty(),
obfuscateDumpShards = obfuscate,
app = gcloud.app?.normalizeFilePath().orEmpty(),
testSpecialEntitlements = gcloud.testSpecialEntitlements ?: false
)

Expand Down
2 changes: 2 additions & 0 deletions test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data class IosArgs(
val testTargets: List<String>,
val obfuscateDumpShards: Boolean,
val additionalIpas: List<String>,
val app: String,
val testSpecialEntitlements: Boolean?
) : IArgs by commonArgs {

Expand Down Expand Up @@ -46,6 +47,7 @@ IosArgs
additional-ipas: ${ArgsToString.listToString(additionalIpas)}
scenario-numbers: ${ArgsToString.listToString(scenarioNumbers)}
type: ${type?.ymlName}
app: $app
test-special-entitlements: $testSpecialEntitlements
flank:
Expand Down
11 changes: 10 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ fun IosArgs.validate() = apply {
assertGameloop()
}

fun IosArgs.assertGameloop() {
private fun IosArgs.assertGameloop() {
validateApp()
validateScenarioNumbers()
}

private fun IosArgs.validateApp() {
if (app.isNotEmpty() && type != Type.GAMELOOP) throw FlankConfigurationError("App cannot be defined if type is not equal to game-loop (IOS)")
}

private fun IosArgs.validateScenarioNumbers() {
if (scenarioNumbers.isNotEmpty() && (type != Type.GAMELOOP))
throw FlankConfigurationError("Scenario numbers defined but Type is not Game-loop.")
scenarioNumbers.forEach { it.toIntOrNull() ?: throw FlankConfigurationError("Invalid scenario number provided - $it") }
Expand Down
10 changes: 10 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,15 @@ data class IosGcloudConfig @JsonIgnore constructor(
@set:JsonProperty("additional-ipas")
var additionalIpas: List<String>? by data

@set:CommandLine.Option(
names = ["--app"],
description = ["The path to the application archive (.ipa file) for game-loop testing. " +
"The path may be in the local filesystem or in Google Cloud Storage using gs:// notation. " +
"This flag is only valid when --type=game-loop is also set"]
)
@set:JsonProperty("app")
var app: 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" +
Expand All @@ -84,6 +93,7 @@ data class IosGcloudConfig @JsonIgnore constructor(
xctestrunFile = null
xcodeVersion = null
additionalIpas = emptyList()
app = null
testSpecialEntitlements = false
}
}
Expand Down
27 changes: 27 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ IosArgs
- $testIpa2
scenario-numbers:
type: xctest
app:
test-special-entitlements: true
flank:
Expand Down Expand Up @@ -308,6 +309,7 @@ IosArgs
additional-ipas:
scenario-numbers:
type: xctest
app:
test-special-entitlements: false
flank:
Expand Down Expand Up @@ -1190,6 +1192,31 @@ IosArgs
""".trimIndent()
IosArgs.load(yaml).validate()
}

@Test(expected = FlankConfigurationError::class)
fun `should throw exception if app provided but not type equals gameloop`() {
val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
results-dir: test
app: $testPath
""".trimIndent()
IosArgs.load(yaml).validate()
}

@Test
fun `should not throw exception if app provided and type equals gameloop`() {
val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
results-dir: test
type: game-loop
app: $testPath
""".trimIndent()
IosArgs.load(yaml).validate()
}
}

private fun IosArgs.Companion.load(yamlData: String, cli: IosRunCommand? = null): IosArgs =
Expand Down

0 comments on commit c74489e

Please sign in to comment.