Skip to content

Commit

Permalink
swiftformat .
Browse files Browse the repository at this point in the history
  • Loading branch information
ollieatkinson committed Mar 23, 2019
1 parent 0934064 commit 9e14948
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
6 changes: 2 additions & 4 deletions Sources/TuistKit/Generator/ConfigGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,16 @@ final class ConfigGenerator: ConfigGenerating {
if target.product == .staticFramework {
settings["MACH_O_TYPE"] = "staticlib"
}

if target.product.isTest {

let appDependencies = graph.targetDependencies(path: sourceRootPath, name: target.name).filter { targetNode in
targetNode.target.product == .app
}

if let app = appDependencies.first {
settings["TEST_HOST"] = "$(BUILT_PRODUCTS_DIR)/\(app.target.productName)/\(app.target.name)"
settings["BUNDLE_LOADER"] = "$(TEST_HOST)"
}

}

variantBuildConfiguration.buildSettings = settings
Expand Down
4 changes: 1 addition & 3 deletions Sources/TuistKit/Models/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,11 @@ extension Product {
}

extension Product {

var isStatic: Bool {
return [.staticLibrary, .staticFramework].contains(self)
}

var isTest: Bool {
return [.unitTests, .uiTests].contains(self)
}

}
31 changes: 14 additions & 17 deletions Tests/TuistKitTests/Generator/ConfigGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class ConfigGeneratorTests: XCTestCase {
let releaseSettings = [
"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule",
]

assert(config: debugConfig, contains: commonSettings)
assert(config: debugConfig, contains: debugSettings)
assert(config: debugConfig, hasXcconfig: "debug.xcconfig")
Expand All @@ -78,24 +78,22 @@ final class ConfigGeneratorTests: XCTestCase {
assert(config: releaseConfig, contains: releaseSettings)
assert(config: releaseConfig, hasXcconfig: "release.xcconfig")
}

func test_generateTestTargetConfiguration() throws {

// Given / When
try generateTestTargetConfig()

let configurationList = pbxTarget.buildConfigurationList
let debugConfig = configurationList?.configuration(name: "Debug")
let releaseConfig = configurationList?.configuration(name: "Release")

let testHostSettings = [
"TEST_HOST": "$(BUILT_PRODUCTS_DIR)/App.app/App",
"BUNDLE_LOADER": "$(TEST_HOST)"
"BUNDLE_LOADER": "$(TEST_HOST)",
]

assert(config: debugConfig, contains: testHostSettings)
assert(config: releaseConfig, contains: testHostSettings)

}

private func generateProjectConfig(config _: BuildConfiguration) throws {
Expand Down Expand Up @@ -153,20 +151,19 @@ final class ConfigGeneratorTests: XCTestCase {
options: options,
sourceRootPath: AbsolutePath("/"))
}

private func generateTestTargetConfig() throws {

let dir = try TemporaryDirectory(removeTreeOnDeinit: true)

let appTarget = Target.test(name: "App", platform: .iOS, product: .app)

let target = Target.test(name: "Test", product: .unitTests)
let project = Project.test(path: dir.path, name: "Project", targets: [target])
let appTargetNode = TargetNode(project: project, target: appTarget, dependencies: [ ])
let testTargetNode = TargetNode(project: project, target: target, dependencies: [ appTargetNode ])
let graph = Graph.test(entryNodes: [ appTargetNode, testTargetNode ])

let appTargetNode = TargetNode(project: project, target: appTarget, dependencies: [])
let testTargetNode = TargetNode(project: project, target: target, dependencies: [appTargetNode])

let graph = Graph.test(entryNodes: [appTargetNode, testTargetNode])

_ = try subject.generateTargetConfig(target,
pbxTarget: pbxTarget,
Expand Down

0 comments on commit 9e14948

Please sign in to comment.