mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-11 12:56:03 +03:00
Compare commits
1 Commits
70d021a897
...
ac20354bf4
Author | SHA1 | Date | |
---|---|---|---|
|
ac20354bf4 |
@ -233,6 +233,15 @@ public class SchemeGenerator {
|
||||
let buildableReference = buildActionEntries.first(where: { $0.buildableReference.blueprintName == schemeTarget?.name })?.buildableReference ?? buildActionEntries.first!.buildableReference
|
||||
let runnables = makeProductRunnables(for: schemeTarget, buildableReference: buildableReference)
|
||||
|
||||
let testMacroExpansion: XCScheme.BuildableReference = buildActionEntries.first(
|
||||
where: { value in
|
||||
if let macroExpansion = scheme.test?.macroExpansion {
|
||||
return value.buildableReference.blueprintName == macroExpansion
|
||||
}
|
||||
return false
|
||||
}
|
||||
)?.buildableReference ?? buildableReference
|
||||
|
||||
let buildAction = XCScheme.BuildAction(
|
||||
buildActionEntries: buildActionEntries,
|
||||
preActions: scheme.build.preActions.map(getExecutionAction),
|
||||
@ -286,17 +295,6 @@ public class SchemeGenerator {
|
||||
let testPlans = scheme.test?.testPlans.enumerated().map { index, testPlan in
|
||||
XCScheme.TestPlanReference(reference: "container:\(testPlan.path)", default: defaultTestPlanIndex == index)
|
||||
} ?? []
|
||||
let testBuildableEntries = buildActionEntries.filter({ $0.buildFor.contains(.testing) }) + testBuildTargetEntries
|
||||
let testMacroExpansionBuildableRef = testBuildableEntries.map(\.buildableReference).contains(buildableReference) ? buildableReference : testBuildableEntries.first?.buildableReference
|
||||
|
||||
let testMacroExpansion: XCScheme.BuildableReference = buildActionEntries.first(
|
||||
where: { value in
|
||||
if let macroExpansion = scheme.test?.macroExpansion {
|
||||
return value.buildableReference.blueprintName == macroExpansion
|
||||
}
|
||||
return false
|
||||
}
|
||||
)?.buildableReference ?? testMacroExpansionBuildableRef ?? buildableReference
|
||||
|
||||
let testAction = XCScheme.TestAction(
|
||||
buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name,
|
||||
|
@ -514,46 +514,6 @@ class SchemeGeneratorTests: XCTestCase {
|
||||
try expect(xcscheme.launchAction?.macroExpansion?.buildableName) == "MyApp.app"
|
||||
}
|
||||
|
||||
$0.it("generates scheme with macroExpansion from tests when the main target is not part of the scheme") {
|
||||
let app = Target(
|
||||
name: "MyApp",
|
||||
type: .application,
|
||||
platform: .iOS,
|
||||
dependencies: []
|
||||
)
|
||||
|
||||
let mockApp = Target(
|
||||
name: "MockApp",
|
||||
type: .application,
|
||||
platform: .iOS,
|
||||
dependencies: []
|
||||
)
|
||||
|
||||
let testBundle = Target(
|
||||
name: "TestBundle",
|
||||
type: .unitTestBundle,
|
||||
platform: .iOS
|
||||
)
|
||||
let appTarget = Scheme.BuildTarget(target: .local(app.name), buildTypes: [.running])
|
||||
let mockAppTarget = Scheme.BuildTarget(target: .local(mockApp.name), buildTypes: [.testing])
|
||||
let testBundleTarget = Scheme.BuildTarget(target: .local(testBundle.name), buildTypes: [.testing])
|
||||
|
||||
let scheme = Scheme(
|
||||
name: "TestScheme",
|
||||
build: Scheme.Build(targets: [appTarget, mockAppTarget, testBundleTarget]),
|
||||
run: Scheme.Run(config: "Debug", macroExpansion: "MyApp")
|
||||
)
|
||||
let project = Project(
|
||||
name: "test",
|
||||
targets: [app, mockApp, testBundle],
|
||||
schemes: [scheme]
|
||||
)
|
||||
let xcodeProject = try project.generateXcodeProject()
|
||||
|
||||
let xcscheme = try unwrap(xcodeProject.sharedData?.schemes.first)
|
||||
try expect(xcscheme.testAction?.macroExpansion?.buildableName) == "MockApp.app"
|
||||
}
|
||||
|
||||
$0.it("generates scheme with test target of local swift package") {
|
||||
let targetScheme = TargetScheme(
|
||||
testTargets: [Scheme.Test.TestTarget(targetReference: TestableTargetReference(name: "XcodeGenKitTests", location: .package("XcodeGen")))])
|
||||
|
Loading…
Reference in New Issue
Block a user