Skip to content

Commit

Permalink
Add preferredScreenCaptureFormat to XCScheme.TestAcion (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
tatagrigory authored Sep 8, 2023
1 parent 30df77b commit 3797181
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
preferredScreenCaptureFormat = "screenshots"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<PreActions>
Expand Down
1 change: 1 addition & 0 deletions Sources/XcodeProj/Extensions/AEXML+XcodeFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let attributesOrder: [String: [String]] = [
"shouldUseLaunchSchemeArgsEnv",
"disableMainThreadChecker",
"region",
"preferredScreenCaptureFormat",
"codeCoverageEnabled",
"onlyGenerateCoverageForSpecifiedTargets",
],
Expand Down
18 changes: 18 additions & 0 deletions Sources/XcodeProj/Scheme/XCScheme+TestAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ extension XCScheme {
public enum AttachmentLifetime: String {
case keepAlways, keepNever
}

public enum ScreenCaptureFormat: String {
case screenshots, screenRecording
}

// MARK: - Static

Expand Down Expand Up @@ -35,6 +39,7 @@ extension XCScheme {
public var language: String?
public var region: String?
public var systemAttachmentLifetime: AttachmentLifetime?
public var preferredScreenCaptureFormat: ScreenCaptureFormat?
public var userAttachmentLifetime: AttachmentLifetime?
public var customLLDBInitFile: String?

Expand Down Expand Up @@ -63,6 +68,7 @@ extension XCScheme {
language: String? = nil,
region: String? = nil,
systemAttachmentLifetime: AttachmentLifetime? = nil,
preferredScreenCaptureFormat: ScreenCaptureFormat? = nil,
userAttachmentLifetime: AttachmentLifetime? = nil,
customLLDBInitFile: String? = nil) {
self.buildConfiguration = buildConfiguration
Expand All @@ -86,6 +92,7 @@ extension XCScheme {
self.language = language
self.region = region
self.systemAttachmentLifetime = systemAttachmentLifetime
self.preferredScreenCaptureFormat = preferredScreenCaptureFormat
self.userAttachmentLifetime = userAttachmentLifetime
self.customLLDBInitFile = customLLDBInitFile
super.init(preActions, postActions)
Expand Down Expand Up @@ -137,6 +144,8 @@ extension XCScheme {

systemAttachmentLifetime = element.attributes["systemAttachmentLifetime"]
.flatMap(AttachmentLifetime.init(rawValue:))
preferredScreenCaptureFormat = element.attributes["preferredScreenCaptureFormat"]
.flatMap(ScreenCaptureFormat.init(rawValue:))
userAttachmentLifetime = element.attributes["userAttachmentLifetime"]
.flatMap(AttachmentLifetime.init(rawValue:))
customLLDBInitFile = element.attributes["customLLDBInitFile"]
Expand Down Expand Up @@ -177,6 +186,14 @@ extension XCScheme {
attributes["disableMainThreadChecker"] = disableMainThreadChecker.xmlString
}
attributes["systemAttachmentLifetime"] = systemAttachmentLifetime?.rawValue

switch preferredScreenCaptureFormat {
case .screenshots:
attributes["preferredScreenCaptureFormat"] = preferredScreenCaptureFormat?.rawValue
case .none, .screenRecording:
break
}

if case .keepAlways? = userAttachmentLifetime {
attributes["userAttachmentLifetime"] = userAttachmentLifetime?.rawValue
}
Expand Down Expand Up @@ -253,6 +270,7 @@ extension XCScheme {
language == rhs.language &&
region == rhs.region &&
systemAttachmentLifetime == rhs.systemAttachmentLifetime &&
preferredScreenCaptureFormat == rhs.preferredScreenCaptureFormat &&
userAttachmentLifetime == rhs.userAttachmentLifetime &&
codeCoverageTargets == rhs.codeCoverageTargets &&
customLLDBInitFile == rhs.customLLDBInitFile
Expand Down
1 change: 1 addition & 0 deletions Tests/XcodeProjTests/Scheme/XCSchemeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ final class XCSchemeIntegrationTests: XCTestCase {
XCTAssertEqual(scheme.testAction?.selectedDebuggerIdentifier, "Xcode.DebuggerFoundation.Debugger.LLDB")
XCTAssertEqual(scheme.testAction?.selectedDebuggerIdentifier, "Xcode.DebuggerFoundation.Debugger.LLDB")
XCTAssertEqual(scheme.testAction?.shouldUseLaunchSchemeArgsEnv, true)
XCTAssertEqual(scheme.testAction?.preferredScreenCaptureFormat, .screenshots)
XCTAssertEqual(scheme.testAction?.codeCoverageEnabled, true)
XCTAssertEqual(scheme.testAction?.onlyGenerateCoverageForSpecifiedTargets, true)
XCTAssertEqual(scheme.testAction?.testables.first?.skipped, false)
Expand Down

0 comments on commit 3797181

Please sign in to comment.