From 6486d8ef425512c3ce381de6812cee04181a2702 Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Wed, 7 Aug 2024 15:51:49 +1000 Subject: [PATCH 1/3] feat(apple): support preferredScreenCaptureFormat --- .../vendor/apple/ios/XcresultConfiguration.kt | 11 +++++++++++ docs/runner/apple/configure/ios.md | 15 +++++++++++++++ .../marathon/apple/xctestrun/TestRootFactory.kt | 1 + .../marathon/apple/xctestrun/v2/TestTarget.kt | 10 ++++++++++ 4 files changed, 37 insertions(+) diff --git a/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt b/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt index b79809d96..f889e0e21 100644 --- a/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt +++ b/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt @@ -7,6 +7,7 @@ data class XcresultConfiguration( @JsonProperty("pullingPolicy") val pullingPolicy: PullingPolicy = PullingPolicy.ALWAYS, @JsonProperty("remoteClean") val remoteClean: Boolean = true, @JsonProperty("attachments") val attachments: AttachmentsConfiguration = AttachmentsConfiguration(), + @JsonProperty("preferredScreenCaptureFormat") val preferredScreenCaptureFormat: ScreenCaptureFormat? = null, ) data class AttachmentsConfiguration( @@ -36,3 +37,13 @@ enum class PullingPolicy { @JsonProperty("ALWAYS") ALWAYS, @JsonProperty("ON_FAILURE") ON_FAILURE, } + +enum class ScreenCaptureFormat { + @JsonProperty("screenshots") SCREENSHOTS, + @JsonProperty("screenRecording") SCREEN_RECORDING; + + fun xcodevalue() = when(this) { + SCREENSHOTS -> "screenshots" + SCREEN_RECORDING -> "screenRecording" + } +} diff --git a/docs/runner/apple/configure/ios.md b/docs/runner/apple/configure/ios.md index 9a4b79446..99a8abbbf 100644 --- a/docs/runner/apple/configure/ios.md +++ b/docs/runner/apple/configure/ios.md @@ -248,6 +248,21 @@ deleted on success and user attachments will always be kept in the xcresult, but Possible values for the lifetime are `KEEP_ALWAYS`, `DELETE_ON_SUCCESS` and `KEEP_NEVER`. +#### xcresult screen recorder configuration +Since Xcode 15 test execution defaults to recording test video and attaching it to xcresults. This can be configured as follows: +```yaml + xcresult: + preferredScreenCaptureFormat: SCREENSHOTS +``` + +Possible values for the screen capture format are `SCREENSHOTS` and `SCREEN_RECORDING`. + +:::warning + +This setting doesn't influence marathon's screen recorder which is configured separately. + +::: + ### Screen recorder configuration By default, marathon will record a h264-encoded video of the internal display with black mask if it is supported. diff --git a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt index cd084e516..7e2976294 100644 --- a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt +++ b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt @@ -221,6 +221,7 @@ class TestRootFactory( testBundlePath = remoteXctest, testHostPath = testRunnerApp, uiTargetAppPath = remoteTestApp, + preferredScreenCaptureFormat = xcresultConfiguration.preferredScreenCaptureFormat?.xcodevalue(), ) ) ) diff --git a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/v2/TestTarget.kt b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/v2/TestTarget.kt index 57ecec4af..f9ab258e1 100644 --- a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/v2/TestTarget.kt +++ b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/v2/TestTarget.kt @@ -38,6 +38,7 @@ class TestTarget : TestTarget { testRegion: String? = null, isUITestBundle: Boolean? = null, isAppHostedTestBundle: Boolean? = null, + preferredScreenCaptureFormat: String? = null, ): V2TestTarget { return V2TestTarget( name = name, @@ -65,6 +66,7 @@ class TestTarget : TestTarget { testRegion = testRegion, isUITestBundle = isUITestBundle, isAppHostedTestBundle = isAppHostedTestBundle, + preferredScreenCaptureFormat = preferredScreenCaptureFormat, ) } @@ -161,6 +163,7 @@ class TestTarget : TestTarget { testRegion: String? = null, isUITestBundle: Boolean? = null, isAppHostedTestBundle: Boolean? = null, + preferredScreenCaptureFormat: String? = null, ) : super( testBundlePath, testHostPath, @@ -192,6 +195,7 @@ class TestTarget : TestTarget { testRegion?.let { this.testRegion = it } isUITestBundle?.let { this.isUITestBundle = it } isAppHostedTestBundle?.let { this.isAppHostedTestBundle = it } + preferredScreenCaptureFormat?.let { this.preferredScreenCaptureFormat = it } } /** @@ -270,4 +274,10 @@ class TestTarget : TestTarget { */ var isUITestBundle: Boolean? by delegate.optionalDelegateFor("IsUITestBundle") var isAppHostedTestBundle: Boolean? by delegate.optionalDelegateFor("IsAppHostedTestBundle") + + /** + * Added in xcode 15, possible values are [screenshots, screenRecording]. Defaults to screenRecording + * Ignored by previous versions of xcode + */ + var preferredScreenCaptureFormat: String? by delegate.optionalDelegateFor("preferredScreenCaptureFormat") } From ecb4b0546ca22f3f90873cd1b82aa5d24ffb16e8 Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Wed, 7 Aug 2024 16:10:21 +1000 Subject: [PATCH 2/3] feat(apple): update docs for macos --- docs/runner/apple/configure/macos.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/runner/apple/configure/macos.md b/docs/runner/apple/configure/macos.md index 9f43c9072..54f7cbdd8 100644 --- a/docs/runner/apple/configure/macos.md +++ b/docs/runner/apple/configure/macos.md @@ -186,6 +186,21 @@ deleted on success and user attachments will always be kept in the xcresult, but Possible values for the lifetime are `KEEP_ALWAYS`, `DELETE_ON_SUCCESS` and `KEEP_NEVER`. +#### xcresult screen recorder configuration +Since Xcode 15 test execution defaults to recording test video and attaching it to xcresults. This can be configured as follows: +```yaml + xcresult: + preferredScreenCaptureFormat: SCREENSHOTS +``` + +Possible values for the screen capture format are `SCREENSHOTS` and `SCREEN_RECORDING`. + +:::warning + +This setting doesn't influence marathon's screen recorder which is configured separately. + +::: + ### xctestrun Environment and TestingEnvironment variables You can specify additional Environment and TestingEnvironment variables for your test run: From 0060fff26087004c2350de61ef3b52fe34128b5d Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Wed, 7 Aug 2024 18:22:41 +1000 Subject: [PATCH 3/3] feat(apple): update sample to support xcode 15 --- .../config/vendor/apple/ios/XcresultConfiguration.kt | 4 ++-- sample/ios-app/Marathonfile-uiTests | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt b/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt index f889e0e21..a3dc756b3 100644 --- a/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt +++ b/configuration/src/main/kotlin/com/malinskiy/marathon/config/vendor/apple/ios/XcresultConfiguration.kt @@ -39,8 +39,8 @@ enum class PullingPolicy { } enum class ScreenCaptureFormat { - @JsonProperty("screenshots") SCREENSHOTS, - @JsonProperty("screenRecording") SCREEN_RECORDING; + @JsonProperty("SCREENSHOTS") SCREENSHOTS, + @JsonProperty("SCREEN_RECORDING") SCREEN_RECORDING; fun xcodevalue() = when(this) { SCREENSHOTS -> "screenshots" diff --git a/sample/ios-app/Marathonfile-uiTests b/sample/ios-app/Marathonfile-uiTests index fa1828365..7f9ecff9e 100644 --- a/sample/ios-app/Marathonfile-uiTests +++ b/sample/ios-app/Marathonfile-uiTests @@ -26,8 +26,11 @@ vendorConfiguration: username: malinskiy key: ${HOME}/.ssh/marathon knownHostsPath: ${HOME}/.ssh/known_hosts + # Temporary fix for https://github.com/hierynomus/sshj/pull/934 + keepAliveInterval: "PT0H0M0S" xcresult: - pullingStrategy: ALWAYS + pullingPolicy: ALWAYS remoteClean: true + preferredScreenCaptureFormat: SCREENSHOTS lifecycle: onPrepare: []