mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-08-17 08:40:28 +03:00
simplify target reference
This commit is contained in:
parent
487d25c699
commit
c4d85923eb
@ -824,7 +824,7 @@ A multiline script can be written using the various YAML multiline methods, for
|
|||||||
### Test Action
|
### Test Action
|
||||||
|
|
||||||
- [ ] **gatherCoverageData**: **Bool** - a boolean that indicates if this scheme should gather coverage data. This defaults to false
|
- [ ] **gatherCoverageData**: **Bool** - a boolean that indicates if this scheme should gather coverage data. This defaults to false
|
||||||
- [ ] **coverageTargets**: **[[Testable Target Reference](#testable-target-reference)]** - a list of targets to gather code coverage. Each entry can also either be a simple string, a string using [Project Reference](#project-reference) or [Testable Target Reference](#testable-target-reference)
|
- [ ] **coverageTargets**: **[[Testable Target Reference](#testable-target-reference)]** - a list of targets to gather code coverage. Each entry can also either be a simple string, or a [Test Target](#test-target)
|
||||||
- [ ] **targets**: **[[Test Target](#test-target)]** - a list of targets to test. Each entry can either be a simple string, or a [Test Target](#test-target)
|
- [ ] **targets**: **[[Test Target](#test-target)]** - a list of targets to test. Each entry can either be a simple string, or a [Test Target](#test-target)
|
||||||
- [ ] **customLLDBInit**: **String** - the absolute path to the custom `.lldbinit` file
|
- [ ] **customLLDBInit**: **String** - the absolute path to the custom `.lldbinit` file
|
||||||
- [ ] **captureScreenshotsAutomatically**: **Bool** - indicates whether screenshots should be captured automatically while UI Testing. This defaults to true.
|
- [ ] **captureScreenshotsAutomatically**: **Bool** - indicates whether screenshots should be captured automatically while UI Testing. This defaults to true.
|
||||||
|
@ -462,16 +462,7 @@ extension Scheme.Test: JSONObjectConvertible {
|
|||||||
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? Scheme.Test.gatherCoverageDataDefault
|
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? Scheme.Test.gatherCoverageDataDefault
|
||||||
|
|
||||||
if let coverages = jsonDictionary["coverageTargets"] as? [Any] {
|
if let coverages = jsonDictionary["coverageTargets"] as? [Any] {
|
||||||
coverageTargets = try coverages.compactMap { target in
|
coverageTargets = try coverages.compactMap(TestableTargetReference.init)
|
||||||
if let string = target as? String {
|
|
||||||
return try TestableTargetReference(string)
|
|
||||||
} else if let dictionary = target as? JSONDictionary,
|
|
||||||
let target: TestableTargetReference = try? .init(jsonDictionary: dictionary) {
|
|
||||||
return target
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
coverageTargets = []
|
coverageTargets = []
|
||||||
}
|
}
|
||||||
@ -548,11 +539,7 @@ extension Scheme.Test: JSONEncodable {
|
|||||||
extension Scheme.Test.TestTarget: JSONObjectConvertible {
|
extension Scheme.Test.TestTarget: JSONObjectConvertible {
|
||||||
|
|
||||||
public init(jsonDictionary: JSONDictionary) throws {
|
public init(jsonDictionary: JSONDictionary) throws {
|
||||||
if let name: String = jsonDictionary.json(atKeyPath: "name") {
|
targetReference = try TestableTargetReference(jsonDictionary: jsonDictionary)
|
||||||
targetReference = try TestableTargetReference(name)
|
|
||||||
} else {
|
|
||||||
self.targetReference = try jsonDictionary.json(atKeyPath: "target")
|
|
||||||
}
|
|
||||||
randomExecutionOrder = jsonDictionary.json(atKeyPath: "randomExecutionOrder") ?? Scheme.Test.TestTarget.randomExecutionOrderDefault
|
randomExecutionOrder = jsonDictionary.json(atKeyPath: "randomExecutionOrder") ?? Scheme.Test.TestTarget.randomExecutionOrderDefault
|
||||||
parallelizable = jsonDictionary.json(atKeyPath: "parallelizable") ?? Scheme.Test.TestTarget.parallelizableDefault
|
parallelizable = jsonDictionary.json(atKeyPath: "parallelizable") ?? Scheme.Test.TestTarget.parallelizableDefault
|
||||||
skipped = jsonDictionary.json(atKeyPath: "skipped") ?? false
|
skipped = jsonDictionary.json(atKeyPath: "skipped") ?? false
|
||||||
|
@ -43,6 +43,17 @@ extension TestableTargetReference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public init?(value: Any) throws {
|
||||||
|
if let string = value as? String {
|
||||||
|
try self.init(string)
|
||||||
|
} else if let dictionary = value as? JSONDictionary,
|
||||||
|
let reference = try? TestableTargetReference(jsonDictionary: dictionary) {
|
||||||
|
self = reference
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static func local(_ name: String) -> TestableTargetReference {
|
public static func local(_ name: String) -> TestableTargetReference {
|
||||||
TestableTargetReference(name: name, location: .local)
|
TestableTargetReference(name: name, location: .local)
|
||||||
}
|
}
|
||||||
@ -79,6 +90,8 @@ extension TestableTargetReference: JSONObjectConvertible {
|
|||||||
let paths = project.split(separator: "/")
|
let paths = project.split(separator: "/")
|
||||||
name = String(paths[1])
|
name = String(paths[1])
|
||||||
location = .package(String(paths[0]))
|
location = .package(String(paths[0]))
|
||||||
|
} else if let name: String = jsonDictionary.json(atKeyPath: "name") {
|
||||||
|
self = try TestableTargetReference(name)
|
||||||
} else {
|
} else {
|
||||||
name = try jsonDictionary.json(atKeyPath: "local")
|
name = try jsonDictionary.json(atKeyPath: "local")
|
||||||
location = .local
|
location = .local
|
||||||
|
@ -15,8 +15,7 @@ targets:
|
|||||||
sources: [SPM]
|
sources: [SPM]
|
||||||
scheme:
|
scheme:
|
||||||
testTargets:
|
testTargets:
|
||||||
- target:
|
- package: XcodeGen/XcodeGenKitTests
|
||||||
package: XcodeGen/XcodeGenKitTests
|
|
||||||
- Tests
|
- Tests
|
||||||
dependencies:
|
dependencies:
|
||||||
- package: Codability
|
- package: Codability
|
||||||
|
Loading…
Reference in New Issue
Block a user