Run swift-format on TulsiGeneratorTests.
PiperOrigin-RevId: 269811709
diff --git a/src/TulsiGeneratorTests/BazelSettingsProviderTests.swift b/src/TulsiGeneratorTests/BazelSettingsProviderTests.swift
index 2f83ca0..9f7cf8e 100644
--- a/src/TulsiGeneratorTests/BazelSettingsProviderTests.swift
+++ b/src/TulsiGeneratorTests/BazelSettingsProviderTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
class BazelSettingsProviderTests: XCTestCase {
@@ -22,25 +23,27 @@
let buildRuleEntries = Set<RuleEntry>()
let bazelSettingsProvider = BazelSettingsProvider(universalFlags: BazelFlags())
-
func testBazelBuildSettingsProviderForWatchOS() {
let options = TulsiOptionSet()
- let settings = bazelSettingsProvider.buildSettings(bazel:bazel,
- bazelExecRoot: bazelExecRoot,
- options: options,
- features: features,
- buildRuleEntries: buildRuleEntries)
+ let settings = bazelSettingsProvider.buildSettings(
+ bazel: bazel,
+ bazelExecRoot: bazelExecRoot,
+ options: options,
+ features: features,
+ buildRuleEntries: buildRuleEntries)
let expectedFlag = "--watchos_cpus=armv7k,arm64_32"
let expectedIdentifiers = Set(["watchos_armv7k", "watchos_arm64_32", "ios_arm64", "ios_arm64e"])
// Check that both watchos flags are set for both architectures.
for (identifier, flags) in settings.platformConfigurationFlags {
- if (expectedIdentifiers.contains(identifier)) {
- XCTAssert(flags.contains(expectedFlag),
- "\(expectedFlag) flag was not set for \(identifier).")
+ if expectedIdentifiers.contains(identifier) {
+ XCTAssert(
+ flags.contains(expectedFlag),
+ "\(expectedFlag) flag was not set for \(identifier).")
} else {
- XCTAssert(!flags.contains(expectedFlag),
- "\(expectedFlag) flag was unexpectedly set for \(identifier).")
+ XCTAssert(
+ !flags.contains(expectedFlag),
+ "\(expectedFlag) flag was unexpectedly set for \(identifier).")
}
}
}
diff --git a/src/TulsiGeneratorTests/BuildLabelTests.swift b/src/TulsiGeneratorTests/BuildLabelTests.swift
index ba59fe9..b098eaa 100644
--- a/src/TulsiGeneratorTests/BuildLabelTests.swift
+++ b/src/TulsiGeneratorTests/BuildLabelTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
class BuildLabelTests: XCTestCase {
diff --git a/src/TulsiGeneratorTests/BuildSettingsTests.swift b/src/TulsiGeneratorTests/BuildSettingsTests.swift
index f1d2047..94e6af1 100644
--- a/src/TulsiGeneratorTests/BuildSettingsTests.swift
+++ b/src/TulsiGeneratorTests/BuildSettingsTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
class BuildSettingsTests: XCTestCase {
@@ -21,6 +22,7 @@
XCTAssert(BazelFlags().isEmpty)
XCTAssertEqual(BazelFlags().toPython(""), "BazelFlags()")
}
+
func testBazelFlagsOperators() {
let a = BazelFlags(startupStr: "a b", buildStr: "x y")
let b = BazelFlags(startupStr: "c d", buildStr: "z 1")
@@ -35,10 +37,13 @@
XCTAssertEqual(c.build, ["x", "y", "z", "1"])
XCTAssertNotEqual(c, b + a)
}
+
func testBazelFlagsPythonable() {
let startup = ["--startup-flag"]
let build = ["--build-flag"]
- XCTAssertEqual(BazelFlags(startup: startup, build: build).toPython(""), """
+ XCTAssertEqual(
+ BazelFlags(startup: startup, build: build).toPython(""),
+ """
BazelFlags(
startup = [
'--startup-flag',
@@ -47,13 +52,15 @@
'--build-flag',
],
)
-""")
+"""
+ )
}
func testBazelFlagsSetEmpty() {
XCTAssert(BazelFlagsSet().isEmpty)
XCTAssertEqual(BazelFlagsSet().toPython(""), "BazelFlagsSet()")
}
+
func testBazelFlagsSetInitializers() {
let basicFlagsSet = BazelFlagsSet(startupFlags: ["a"], buildFlags: ["b"])
let basicFlags = BazelFlags(startup: ["a"], build: ["b"])
@@ -62,15 +69,19 @@
XCTAssertEqual(basicFlagsSet.getFlags(forDebug: true), basicFlagsSet.debug)
XCTAssertEqual(basicFlagsSet.getFlags(forDebug: false), basicFlagsSet.release)
- let complexFlagSet = BazelFlagsSet(debug: BazelFlags(startup: ["a"], build: ["b"]),
- release: BazelFlags(startup: ["x"], build: ["y"]),
- common: BazelFlags(startup: ["1"], build: ["2"]))
+ let complexFlagSet = BazelFlagsSet(
+ debug: BazelFlags(startup: ["a"], build: ["b"]),
+ release: BazelFlags(startup: ["x"], build: ["y"]),
+ common: BazelFlags(startup: ["1"], build: ["2"]))
XCTAssertEqual(complexFlagSet.debug, BazelFlags(startup: ["a", "1"], build: ["b", "2"]))
XCTAssertEqual(complexFlagSet.release, BazelFlags(startup: ["x", "1"], build: ["y", "2"]))
}
+
func testBazelFlagsSetPythonable() {
let basicFlagsSet = BazelFlagsSet(startupFlags: ["a"], buildFlags: ["b"])
- XCTAssertEqual(basicFlagsSet.toPython(""), """
+ XCTAssertEqual(
+ basicFlagsSet.toPython(""),
+ """
BazelFlagsSet(
flags = BazelFlags(
startup = [
@@ -81,11 +92,15 @@
],
),
)
-""")
- let complexFlagSet = BazelFlagsSet(debug: BazelFlags(startup: ["a"], build: ["b"]),
- release: BazelFlags(startup: ["x"], build: ["y"]),
- common: BazelFlags(startup: ["1"], build: ["2"]))
- XCTAssertEqual(complexFlagSet.toPython(""), """
+"""
+ )
+ let complexFlagSet = BazelFlagsSet(
+ debug: BazelFlags(startup: ["a"], build: ["b"]),
+ release: BazelFlags(startup: ["x"], build: ["y"]),
+ common: BazelFlags(startup: ["1"], build: ["2"]))
+ XCTAssertEqual(
+ complexFlagSet.toPython(""),
+ """
BazelFlagsSet(
debug = BazelFlags(
startup = [
@@ -108,48 +123,54 @@
],
),
)
-""")
+"""
+ )
}
- func testBazelBuildSettingsPythonable() {
- let bazel = "/path/to/bazel"
- let bazelExecRoot = "__MOCK_EXEC_ROOT__"
- let defaultIdentifier = "fake_config"
- let platformConfigurationFlags = [
- "fake_config": ["a", "b"],
- "another_one": ["--x", "-c"],
- ]
+ func testBazelBuildSettingsPythonable() {
+ let bazel = "/path/to/bazel"
+ let bazelExecRoot = "__MOCK_EXEC_ROOT__"
+ let defaultIdentifier = "fake_config"
+ let platformConfigurationFlags = [
+ "fake_config": ["a", "b"],
+ "another_one": ["--x", "-c"],
+ ]
- let swiftTargets: Set<String> = [
- "//dir/swiftTarget:swiftTarget",
- "//dir/nested/depOnswift:depOnswift"
- ]
- let cacheAffecting = BazelFlagsSet(startupFlags: ["--nocacheStartup"],
- buildFlags: ["--nocacheBuild"])
- let cacheSafe = BazelFlagsSet(startupFlags: ["--cacheSafeStartup"],
- buildFlags: ["--cacheSafeBuild"])
- let swift = BazelFlagsSet(buildFlags: ["--swift-only"])
- let nonSwift = BazelFlagsSet(startupFlags: ["--non-swift-only"])
- let projDefaults = BazelFlagsSet()
- let projTargetFlags = [
- "//dir/some/customized:target": BazelFlagsSet(buildFlags: ["a", "b"]),
- ]
- let swiftFeatures = [BazelSettingFeature.DebugPathNormalization.stringValue]
- let nonSwiftFeatures = [BazelSettingFeature.DebugPathNormalization.stringValue]
- let settings = BazelBuildSettings(bazel: bazel,
- bazelExecRoot: bazelExecRoot,
- defaultPlatformConfigIdentifier: defaultIdentifier,
- platformConfigurationFlags: platformConfigurationFlags,
- swiftTargets: swiftTargets,
- tulsiCacheAffectingFlagsSet: cacheAffecting,
- tulsiCacheSafeFlagSet: cacheSafe,
- tulsiSwiftFlagSet: swift,
- tulsiNonSwiftFlagSet: nonSwift,
- swiftFeatures: swiftFeatures,
- nonSwiftFeatures: nonSwiftFeatures,
- projDefaultFlagSet: projDefaults,
- projTargetFlagSets: projTargetFlags)
- XCTAssertEqual(settings.toPython(""), """
+ let swiftTargets: Set<String> = [
+ "//dir/swiftTarget:swiftTarget",
+ "//dir/nested/depOnswift:depOnswift",
+ ]
+ let cacheAffecting = BazelFlagsSet(
+ startupFlags: ["--nocacheStartup"],
+ buildFlags: ["--nocacheBuild"])
+ let cacheSafe = BazelFlagsSet(
+ startupFlags: ["--cacheSafeStartup"],
+ buildFlags: ["--cacheSafeBuild"])
+ let swift = BazelFlagsSet(buildFlags: ["--swift-only"])
+ let nonSwift = BazelFlagsSet(startupFlags: ["--non-swift-only"])
+ let projDefaults = BazelFlagsSet()
+ let projTargetFlags = [
+ "//dir/some/customized:target": BazelFlagsSet(buildFlags: ["a", "b"]),
+ ]
+ let swiftFeatures = [BazelSettingFeature.DebugPathNormalization.stringValue]
+ let nonSwiftFeatures = [BazelSettingFeature.DebugPathNormalization.stringValue]
+ let settings = BazelBuildSettings(
+ bazel: bazel,
+ bazelExecRoot: bazelExecRoot,
+ defaultPlatformConfigIdentifier: defaultIdentifier,
+ platformConfigurationFlags: platformConfigurationFlags,
+ swiftTargets: swiftTargets,
+ tulsiCacheAffectingFlagsSet: cacheAffecting,
+ tulsiCacheSafeFlagSet: cacheSafe,
+ tulsiSwiftFlagSet: swift,
+ tulsiNonSwiftFlagSet: nonSwift,
+ swiftFeatures: swiftFeatures,
+ nonSwiftFeatures: nonSwiftFeatures,
+ projDefaultFlagSet: projDefaults,
+ projTargetFlagSets: projTargetFlags)
+ XCTAssertEqual(
+ settings.toPython(""),
+ """
BazelBuildSettings(
'\(bazel)',
'\(bazelExecRoot)',
@@ -165,6 +186,7 @@
\(projDefaults.toPython(" ")),
\(projTargetFlags.toPython(" ")),
)
-""")
+"""
+ )
}
}
diff --git a/src/TulsiGeneratorTests/CommandLineSplitterTests.swift b/src/TulsiGeneratorTests/CommandLineSplitterTests.swift
index bb28a47..e659670 100644
--- a/src/TulsiGeneratorTests/CommandLineSplitterTests.swift
+++ b/src/TulsiGeneratorTests/CommandLineSplitterTests.swift
@@ -13,8 +13,8 @@
// limitations under the License.
import XCTest
-@testable import TulsiGenerator
+@testable import TulsiGenerator
class CommandLineSplitterTests: XCTestCase {
var splitter: CommandLineSplitter! = nil
diff --git a/src/TulsiGeneratorTests/MockLocalizedMessageLogger.swift b/src/TulsiGeneratorTests/MockLocalizedMessageLogger.swift
index 9942661..c5f186a 100644
--- a/src/TulsiGeneratorTests/MockLocalizedMessageLogger.swift
+++ b/src/TulsiGeneratorTests/MockLocalizedMessageLogger.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
// Stub LocalizedMessageLogger that does nothing.
@@ -20,21 +21,27 @@
var syslogMessages = [String]()
var infoMessages = [String]()
var warningMessageKeys = [String]()
+
let nonFatalWarningKeys = Set([
"BootstrapLLDBInitFailed",
- "CleanCachedDsymsFailed"
+ "CleanCachedDsymsFailed",
])
+
var errorMessageKeys = [String]()
init() {
super.init(bundle: nil)
}
- override func error(_ key: String, comment: String, details: String?, context: String?, values: CVarArg...) {
+ override func error(
+ _ key: String, comment: String, details: String?, context: String?, values: CVarArg...
+ ) {
errorMessageKeys.append(key)
}
- override func warning(_ key: String, comment: String, details: String?, context: String?, values: CVarArg...) {
+ override func warning(
+ _ key: String, comment: String, details: String?, context: String?, values: CVarArg...
+ ) {
warningMessageKeys.append(key)
}
@@ -47,17 +54,19 @@
}
func assertNoErrors(_ file: StaticString = #file, line: UInt = #line) {
- XCTAssert(errorMessageKeys.isEmpty,
- "Unexpected error messages printed: \(errorMessageKeys)",
- file: file,
- line: line)
+ XCTAssert(
+ errorMessageKeys.isEmpty,
+ "Unexpected error messages printed: \(errorMessageKeys)",
+ file: file,
+ line: line)
}
func assertNoWarnings(_ file: StaticString = #file, line: UInt = #line) {
let hasOnlyNonFatalWarnings = Set(warningMessageKeys).isSubset(of: nonFatalWarningKeys)
- XCTAssert(warningMessageKeys.isEmpty || hasOnlyNonFatalWarnings,
- "Unexpected warning messages printed: \(warningMessageKeys)",
- file: file,
- line: line)
+ XCTAssert(
+ warningMessageKeys.isEmpty || hasOnlyNonFatalWarnings,
+ "Unexpected warning messages printed: \(warningMessageKeys)",
+ file: file,
+ line: line)
}
}
diff --git a/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift b/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift
index 1d80cfc..c0a0270 100644
--- a/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift
+++ b/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import Foundation
+
@testable import TulsiGenerator
class MockBazelSettingsProvider: BazelSettingsProviderProtocol {
@@ -21,30 +22,35 @@
return BazelFlags()
}
- func tulsiFlags(hasSwift: Bool,
- options: TulsiOptionSet?,
- features: Set<BazelSettingFeature>) -> BazelFlagsSet {
+ func tulsiFlags(
+ hasSwift: Bool,
+ options: TulsiOptionSet?,
+ features: Set<BazelSettingFeature>
+ ) -> BazelFlagsSet {
return BazelFlagsSet()
}
- func buildSettings(bazel: String,
- bazelExecRoot: String,
- options: TulsiOptionSet,
- features: Set<BazelSettingFeature>,
- buildRuleEntries: Set<RuleEntry>) -> BazelBuildSettings {
- return BazelBuildSettings(bazel: bazel,
- bazelExecRoot: bazelExecRoot,
- defaultPlatformConfigIdentifier: "",
- platformConfigurationFlags: nil,
- swiftTargets: [],
- tulsiCacheAffectingFlagsSet: BazelFlagsSet(),
- tulsiCacheSafeFlagSet: BazelFlagsSet(),
- tulsiSwiftFlagSet: BazelFlagsSet(),
- tulsiNonSwiftFlagSet: BazelFlagsSet(),
- swiftFeatures: [],
- nonSwiftFeatures: [],
- projDefaultFlagSet: BazelFlagsSet(),
- projTargetFlagSets: [:])
+ func buildSettings(
+ bazel: String,
+ bazelExecRoot: String,
+ options: TulsiOptionSet,
+ features: Set<BazelSettingFeature>,
+ buildRuleEntries: Set<RuleEntry>
+ ) -> BazelBuildSettings {
+ return BazelBuildSettings(
+ bazel: bazel,
+ bazelExecRoot: bazelExecRoot,
+ defaultPlatformConfigIdentifier: "",
+ platformConfigurationFlags: nil,
+ swiftTargets: [],
+ tulsiCacheAffectingFlagsSet: BazelFlagsSet(),
+ tulsiCacheSafeFlagSet: BazelFlagsSet(),
+ tulsiSwiftFlagSet: BazelFlagsSet(),
+ tulsiNonSwiftFlagSet: BazelFlagsSet(),
+ swiftFeatures: [],
+ nonSwiftFeatures: [],
+ projDefaultFlagSet: BazelFlagsSet(),
+ projTargetFlagSets: [:])
}
}
@@ -53,27 +59,31 @@
let bazelSettingsProvider: BazelSettingsProviderProtocol = MockBazelSettingsProvider()
var labelToRuleEntry = [BuildLabel: RuleEntry]()
+
/// The set of labels passed to ruleEntriesForLabels that could not be found in the
/// labelToRuleEntry dictionary.
var invalidLabels = Set<BuildLabel>()
var bazelURL = URL(fileURLWithPath: "")
var bazelBinPath = "bazel-bin"
- var bazelExecutionRoot = "/private/var/tmp/_bazel_localhost/1234567890abcdef1234567890abcdef/execroot/workspace_dir"
+ var bazelExecutionRoot
+ = "/private/var/tmp/_bazel_localhost/1234567890abcdef1234567890abcdef/execroot/workspace_dir"
var workspaceRootURL = URL(fileURLWithPath: "")
func extractRuleInfoFromProject(_ project: TulsiProject) -> [RuleInfo] {
return []
}
- func ruleEntriesForLabels(_ labels: [BuildLabel],
- startupOptions: TulsiOption,
- extraStartupOptions: TulsiOption,
- buildOptions: TulsiOption,
- compilationModeOption: TulsiOption,
- platformConfigOption: TulsiOption,
- prioritizeSwiftOption: TulsiOption,
- features: Set<BazelSettingFeature>) throws -> RuleEntryMap {
+ func ruleEntriesForLabels(
+ _ labels: [BuildLabel],
+ startupOptions: TulsiOption,
+ extraStartupOptions: TulsiOption,
+ buildOptions: TulsiOption,
+ compilationModeOption: TulsiOption,
+ platformConfigOption: TulsiOption,
+ prioritizeSwiftOption: TulsiOption,
+ features: Set<BazelSettingFeature>
+ ) throws -> RuleEntryMap {
invalidLabels.removeAll(keepingCapacity: true)
let ret = RuleEntryMap()
for label in labels {
@@ -86,7 +96,8 @@
return ret
}
- func extractBuildfiles<T:Collection>(_ forTargets: T) -> Set<BuildLabel> where T.Iterator.Element == BuildLabel {
+ func extractBuildfiles<T: Collection>(_ forTargets: T) -> Set<BuildLabel>
+ where T.Iterator.Element == BuildLabel {
return Set()
}
diff --git a/src/TulsiGeneratorTests/NSURLExtensionsTests.swift b/src/TulsiGeneratorTests/NSURLExtensionsTests.swift
index 6e5373f..899c2b7 100644
--- a/src/TulsiGeneratorTests/NSURLExtensionsTests.swift
+++ b/src/TulsiGeneratorTests/NSURLExtensionsTests.swift
@@ -13,8 +13,8 @@
// limitations under the License.
import XCTest
-@testable import TulsiGenerator
+@testable import TulsiGenerator
class NSURLExtensionsTests: XCTestCase {
func testRelativePathOfEqualPaths() {
diff --git a/src/TulsiGeneratorTests/PBXObjectsTests.swift b/src/TulsiGeneratorTests/PBXObjectsTests.swift
index bc15e4c..fc6fde6 100644
--- a/src/TulsiGeneratorTests/PBXObjectsTests.swift
+++ b/src/TulsiGeneratorTests/PBXObjectsTests.swift
@@ -13,8 +13,8 @@
// limitations under the License.
import XCTest
-@testable import TulsiGenerator
+@testable import TulsiGenerator
class PBXObjectsTests: XCTestCase {
enum ExpectedStructure {
@@ -37,28 +37,40 @@
func testProjectCreateGroupsAndFileReferencesForPaths() {
let paths = [
- "root",
- "test/file",
- "deeply/nested/files/1",
- "deeply/nested/files/2",
- "/empty/component",
+ "root",
+ "test/file",
+ "deeply/nested/files/1",
+ "deeply/nested/files/2",
+ "/empty/component",
]
let expectedStructure: [ExpectedStructure] = [
- .fileReference("root"),
- .group("test", contents: [
- .fileReference("test/file"),
+ .fileReference("root"),
+ .group(
+ "test",
+ contents: [
+ .fileReference("test/file"),
]),
- .group("deeply", contents: [
- .group("nested", contents: [
- .group("files", contents: [
- .fileReference("deeply/nested/files/1"),
- .fileReference("deeply/nested/files/2"),
+ .group(
+ "deeply",
+ contents: [
+ .group(
+ "nested",
+ contents: [
+ .group(
+ "files",
+ contents: [
+ .fileReference("deeply/nested/files/1"),
+ .fileReference("deeply/nested/files/2"),
]),
]),
]),
- .group("/", contents: [
- .group("empty", contents: [
- .fileReference("/empty/component"),
+ .group(
+ "/",
+ contents: [
+ .group(
+ "empty",
+ contents: [
+ .fileReference("/empty/component"),
]),
]),
]
@@ -76,26 +88,30 @@
func testProjectCreateGroupsAndFileReferencesForPathsMultiplePaths() {
let paths1 = [
- "1",
- "unique/1",
- "overlapping/file"
+ "1",
+ "unique/1",
+ "overlapping/file",
]
let paths2 = [
- "2",
- "unique/2",
- "overlapping/file",
- "overlapping/2"
+ "2",
+ "unique/2",
+ "overlapping/file",
+ "overlapping/2",
]
let expectedStructure: [ExpectedStructure] = [
- .fileReference("1"),
- .fileReference("2"),
- .group("unique", contents: [
- .fileReference("unique/1"),
- .fileReference("unique/2"),
+ .fileReference("1"),
+ .fileReference("2"),
+ .group(
+ "unique",
+ contents: [
+ .fileReference("unique/1"),
+ .fileReference("unique/2"),
]),
- .group("overlapping", contents: [
- .fileReference("overlapping/file"),
- .fileReference("overlapping/2"),
+ .group(
+ "overlapping",
+ contents: [
+ .fileReference("overlapping/file"),
+ .fileReference("overlapping/2"),
]),
]
@@ -106,17 +122,19 @@
func testProjectCreateGroupsAndFileReferencesForBundlePath() {
let paths = [
- "test",
- "bundle.xcassets/test_content",
- "subdir/test.app/file_inside",
- "subdir/test2.app/dir_inside/file_inside",
+ "test",
+ "bundle.xcassets/test_content",
+ "subdir/test.app/file_inside",
+ "subdir/test2.app/dir_inside/file_inside",
]
let expectedStructure: [ExpectedStructure] = [
- .fileReference("test"),
- .fileReference("bundle.xcassets"),
- .group("subdir", contents: [
- .fileReference("subdir/test.app"),
- .fileReference("subdir/test2.app"),
+ .fileReference("test"),
+ .fileReference("bundle.xcassets"),
+ .group(
+ "subdir",
+ contents: [
+ .fileReference("subdir/test.app"),
+ .fileReference("subdir/test2.app"),
]),
]
@@ -126,16 +144,16 @@
func testSourceRelativePathGeneration() {
let paths = [
- "1",
- "test/2",
- "deeply/nested/files/3",
- "deeply/nested/files/4"
+ "1",
+ "test/2",
+ "deeply/nested/files/3",
+ "deeply/nested/files/4",
]
let expectedSourceRelativePaths = [
- "1": "1",
- "test/2": "test/2",
- "deeply/nested/files/3": "deeply/nested/files/3",
- "deeply/nested/files/4": "deeply/nested/files/4"
+ "1": "1",
+ "test/2": "test/2",
+ "deeply/nested/files/3": "deeply/nested/files/3",
+ "deeply/nested/files/4": "deeply/nested/files/4",
]
project.getOrCreateGroupsAndFileReferencesForPaths(paths)
for fileRef in project.mainGroup.allSources {
@@ -145,11 +163,11 @@
}
func testPBXReferenceFileExtension() {
- let filenameToExt: Dictionary<String, String?> = [
- "test.file": "file",
- "test": nil,
- "test.something.ext": "ext",
- "/someplace/test.something.ext": "ext",
+ let filenameToExt: [String: String?] = [
+ "test.file": "file",
+ "test": nil,
+ "test.something.ext": "ext",
+ "/someplace/test.something.ext": "ext",
]
for (filename, ext) in filenameToExt {
@@ -163,10 +181,10 @@
func testPBXReferenceUTI() {
let fileExtensionsToTest = [
- "a",
- "dylib",
- "swift",
- "xib",
+ "a",
+ "dylib",
+ "swift",
+ "xib",
]
for ext in fileExtensionsToTest {
let filename = "filename.\(ext)"
@@ -179,10 +197,10 @@
}
let bundleExtensionsToTest = [
- "app",
- "bundle",
- "xcassets",
- "xcstickers",
+ "app",
+ "bundle",
+ "xcassets",
+ "xcstickers",
]
for ext in bundleExtensionsToTest {
let filename = "filename.\(ext)"
@@ -204,15 +222,21 @@
"external/project/src/file.ext",
]
let expectedStructure: [ExpectedStructure] = [
- .group("dir", contents: [
- .fileReference("dir/file"),
- ]),
- .groupWithName("@project", path: movedDir, contents: [
- .fileReference("README.md"),
- .group("src", contents: [
- .fileReference("src/file.ext"),
+ .group(
+ "dir",
+ contents: [
+ .fileReference("dir/file"),
]),
- ]),
+ .groupWithName(
+ "@project", path: movedDir,
+ contents: [
+ .fileReference("README.md"),
+ .group(
+ "src",
+ contents: [
+ .fileReference("src/file.ext"),
+ ]),
+ ]),
]
project.getOrCreateGroupsAndFileReferencesForPaths(paths)
@@ -227,14 +251,14 @@
continue
}
- let newChild = mainGroup.getOrCreateChildGroupByName("@\(child.name)",
- path: movedDir,
- sourceTree: .Absolute)
+ let newChild = mainGroup.getOrCreateChildGroupByName(
+ "@\(child.name)",
+ path: movedDir,
+ sourceTree: .Absolute)
newChild.migrateChildrenOfGroup(group)
}
mainGroup.removeChild(extGroup)
-
assertProjectStructure(expectedStructure, forGroup: project.mainGroup)
}
@@ -244,9 +268,11 @@
"en.lproj/Localizable.strings",
]
let expectedStructure: [ExpectedStructure] = [
- .variantGroup("Localizable.strings", contents: [
- .fileReferenceWithName("Base", path: "Base.lproj/Localizable.strings"),
- .fileReferenceWithName("en", path: "en.lproj/Localizable.strings"),
+ .variantGroup(
+ "Localizable.strings",
+ contents: [
+ .fileReferenceWithName("Base", path: "Base.lproj/Localizable.strings"),
+ .fileReferenceWithName("en", path: "en.lproj/Localizable.strings"),
]),
]
@@ -256,62 +282,71 @@
// MARK: - Helper methods
- func assertProjectStructure(_ expectedStructure: [ExpectedStructure],
- forGroup group: PBXGroup,
- line: UInt = #line) {
- XCTAssertEqual(group.children.count,
- expectedStructure.count,
- "Mismatch in child count for group '\(group.name)'",
- line: line)
+ func assertProjectStructure(
+ _ expectedStructure: [ExpectedStructure],
+ forGroup group: PBXGroup,
+ line: UInt = #line
+ ) {
+ XCTAssertEqual(
+ group.children.count,
+ expectedStructure.count,
+ "Mismatch in child count for group '\(group.name)'",
+ line: line)
for element in expectedStructure {
switch element {
- case .fileReference(let name):
- assertGroup(group, containsSourceTree: .Group, path: name, line: line)
+ case .fileReference(let name):
+ assertGroup(group, containsSourceTree: .Group, path: name, line: line)
- case .fileReferenceWithName(let name, let path):
- assertGroup(group, containsSourceTree: .Group, path: path, name: name, line: line)
+ case .fileReferenceWithName(let name, let path):
+ assertGroup(group, containsSourceTree: .Group, path: path, name: name, line: line)
- case .group(let name, let grandChildren):
- let childGroup = assertGroup(group, containsGroupWithName: name, line: line)
- assertProjectStructure(grandChildren, forGroup: childGroup, line: line)
+ case .group(let name, let grandChildren):
+ let childGroup = assertGroup(group, containsGroupWithName: name, line: line)
+ assertProjectStructure(grandChildren, forGroup: childGroup, line: line)
- case .groupWithName(let name, let path, let grandChildren):
- let childGroup = assertGroup(group, containsGroupWithName: name, path: path, line: line)
- assertProjectStructure(grandChildren, forGroup: childGroup, line: line)
+ case .groupWithName(let name, let path, let grandChildren):
+ let childGroup = assertGroup(group, containsGroupWithName: name, path: path, line: line)
+ assertProjectStructure(grandChildren, forGroup: childGroup, line: line)
- case .variantGroup(let name, let grandChildren):
- let childVariantGroup = assertGroup(group, containsVariantGroupWithName: name, line: line)
- assertProjectStructure(grandChildren, forGroup: childVariantGroup, line: line)
+ case .variantGroup(let name, let grandChildren):
+ let childVariantGroup = assertGroup(group, containsVariantGroupWithName: name, line: line)
+ assertProjectStructure(grandChildren, forGroup: childVariantGroup, line: line)
}
}
}
@discardableResult
- func assertGroup(_ group: PBXGroup,
- containsSourceTree sourceTree: SourceTree,
- path: String,
- name: String? = nil,
- line: UInt = #line) -> PBXFileReference {
+ func assertGroup(
+ _ group: PBXGroup,
+ containsSourceTree sourceTree: SourceTree,
+ path: String,
+ name: String? = nil,
+ line: UInt = #line
+ ) -> PBXFileReference {
let sourceTreePath = SourceTreePath(sourceTree: sourceTree, path: path)
let fileRef = group.fileReferencesBySourceTreePath[sourceTreePath]
- XCTAssertNotNil(fileRef,
- "Failed to find expected PBXFileReference '\(path)' in group '\(group.name)",
- line: line)
+ XCTAssertNotNil(
+ fileRef,
+ "Failed to find expected PBXFileReference '\(path)' in group '\(group.name)",
+ line: line)
if let name = name {
XCTAssertEqual(name, fileRef!.name)
}
return fileRef!
}
- func assertGroup(_ group: PBXGroup,
- containsGroupWithName name: String,
- path: String? = nil,
- line: UInt = #line) -> PBXGroup {
+ func assertGroup(
+ _ group: PBXGroup,
+ containsGroupWithName name: String,
+ path: String? = nil,
+ line: UInt = #line
+ ) -> PBXGroup {
let child = group.childGroupsByName[name]
- XCTAssertNotNil(child,
- "Failed to find child group '\(name)' in group '\(group.name)'",
- line: line)
+ XCTAssertNotNil(
+ child,
+ "Failed to find child group '\(name)' in group '\(group.name)'",
+ line: line)
if let path = path {
XCTAssertNotNil(child!.path, "Expected child \(child!) to have a non-nil path")
XCTAssertEqual(child!.path, path, "Child path \(child!.path!) != expected path \(path)")
@@ -321,13 +356,16 @@
return child!
}
- func assertGroup(_ group: PBXGroup,
- containsVariantGroupWithName name: String,
- line: UInt = #line) -> PBXGroup {
+ func assertGroup(
+ _ group: PBXGroup,
+ containsVariantGroupWithName name: String,
+ line: UInt = #line
+ ) -> PBXGroup {
let child = group.childVariantGroupsByName[name]
- XCTAssertNotNil(child,
- "Failed to find child variant group '\(name)' in group '\(group.name)'",
- line: line)
+ XCTAssertNotNil(
+ child,
+ "Failed to find child variant group '\(name)' in group '\(group.name)'",
+ line: line)
return child!
}
}
diff --git a/src/TulsiGeneratorTests/PBXProjSerializerTests.swift b/src/TulsiGeneratorTests/PBXProjSerializerTests.swift
index 9cb034e..3fde2f7 100644
--- a/src/TulsiGeneratorTests/PBXProjSerializerTests.swift
+++ b/src/TulsiGeneratorTests/PBXProjSerializerTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
typealias StringToObjectDict = [String: NSObject]
@@ -34,7 +35,7 @@
func testOpenStepSerializesEmptyDictionaries() {
let config = project.buildConfigurationList.getOrCreateBuildConfiguration("Empty")
- config.buildSettings = Dictionary<String, String>()
+ config.buildSettings = [String: String]()
config.globalID = gidGenerator.generateReservedID()
guard let openStepData = serializer.serialize() else {
@@ -43,18 +44,22 @@
}
let root: StringToObjectDict
do {
- root = try PropertyListSerialization.propertyList(from: openStepData,
- options: [], format: nil) as! StringToObjectDict
+ root = try PropertyListSerialization.propertyList(
+ from: openStepData,
+ options: [], format: nil) as! StringToObjectDict
} catch let error as NSError {
let serializedData = String(data: openStepData, encoding: String.Encoding.utf8)!
- XCTFail("Failed to parse OpenStep serialized data " + error.localizedDescription + "\n" + serializedData)
+ XCTFail(
+ "Failed to parse OpenStep serialized data " + error.localizedDescription + "\n"
+ + serializedData)
return
}
let objects = root["objects"] as! StringToObjectDict
- let buildConfigDict: StringToObjectDict! = getObjectByID(config.globalID,
- withPBXClass: "XCBuildConfiguration",
- fromObjects: objects)
+ let buildConfigDict: StringToObjectDict! = getObjectByID(
+ config.globalID,
+ withPBXClass: "XCBuildConfiguration",
+ fromObjects: objects)
XCTAssertNotNil(buildConfigDict["buildSettings"])
}
@@ -92,7 +97,8 @@
let gid: String
let isInputFile: Bool
- init(sourceTree: SourceTree, path: String, uti: String?, gid: String, isInputFile: Bool = true) {
+ init(sourceTree: SourceTree, path: String, uti: String?, gid: String, isInputFile: Bool = true)
+ {
self.sourceTree = sourceTree
self.path = path
self.uti = uti
@@ -102,11 +108,12 @@
init(sourceTree: SourceTree, path: String, gid: String, isInputFile: Bool = true) {
let uti = FileExtensionToUTI[(path as NSString).pathExtension]
- self.init(sourceTree: sourceTree,
- path: path,
- uti: uti,
- gid: gid,
- isInputFile: isInputFile)
+ self.init(
+ sourceTree: sourceTree,
+ path: path,
+ uti: uti,
+ gid: gid,
+ isInputFile: isInputFile)
}
}
@@ -120,13 +127,15 @@
let groups: [GroupDefinition]
let expectedPBXClass: String
- init(name: String,
- sourceTree: SourceTree,
- path: String?,
- gid: String,
- files: [FileDefinition],
- groups: [GroupDefinition],
- expectedPBXClass: String = "PBXGroup") {
+ init(
+ name: String,
+ sourceTree: SourceTree,
+ path: String?,
+ gid: String,
+ files: [FileDefinition],
+ groups: [GroupDefinition],
+ expectedPBXClass: String = "PBXGroup"
+ ) {
self.name = name
self.sourceTree = sourceTree
self.path = path
@@ -139,13 +148,14 @@
func groupByAddingGroup(_ group: GroupDefinition) -> GroupDefinition {
var newGroups = groups
newGroups.append(group)
- return GroupDefinition(name: name,
- sourceTree: sourceTree,
- path: path,
- gid: gid,
- files: files,
- groups: newGroups,
- expectedPBXClass: expectedPBXClass)
+ return GroupDefinition(
+ name: name,
+ sourceTree: sourceTree,
+ path: path,
+ gid: gid,
+ files: files,
+ groups: newGroups,
+ expectedPBXClass: expectedPBXClass)
}
}
@@ -153,27 +163,30 @@
let currentVersion: FileDefinition
let versionGroupType: String
- init(name: String,
- sourceTree: SourceTree,
- path: String?,
- gid: String,
- files: [FileDefinition],
- groups: [GroupDefinition],
- currentVersion: FileDefinition,
- versionGroupType: String? = nil) {
+ init(
+ name: String,
+ sourceTree: SourceTree,
+ path: String?,
+ gid: String,
+ files: [FileDefinition],
+ groups: [GroupDefinition],
+ currentVersion: FileDefinition,
+ versionGroupType: String? = nil
+ ) {
self.currentVersion = currentVersion
if let versionGroupType = versionGroupType {
self.versionGroupType = versionGroupType
} else {
self.versionGroupType = FileExtensionToUTI[(name as NSString).pathExtension] ?? ""
}
- super.init(name: name,
- sourceTree: sourceTree,
- path: path,
- gid: gid,
- files: files,
- groups: groups,
- expectedPBXClass: "XCVersionGroup")
+ super.init(
+ name: name,
+ sourceTree: sourceTree,
+ path: path,
+ gid: gid,
+ files: files,
+ groups: groups,
+ expectedPBXClass: "XCVersionGroup")
}
}
@@ -181,7 +194,7 @@
struct SimpleProjectDefinition {
struct NativeTargetDefinition {
let name: String
- let settings: Dictionary<String, String>
+ let settings: [String: String]
let config: String
let targetType: PBXTarget.ProductType
}
@@ -194,7 +207,7 @@
}
let projectLevelBuildConfigName: String
- let projectLevelBuildConfigSettings: Dictionary<String, String>
+ let projectLevelBuildConfigSettings: [String: String]
let nativeTarget: NativeTargetDefinition
let legacyTarget: LegacyTargetDefinition
let mainGroupGID: String
@@ -206,19 +219,25 @@
}
@discardableResult
- private func populateProject(_ targetProject: PBXProject, withGIDGenerator generator: MockGIDGenerator) -> SimpleProjectDefinition {
+ private func populateProject(
+ _ targetProject: PBXProject, withGIDGenerator generator: MockGIDGenerator
+ ) -> SimpleProjectDefinition {
let projectLevelBuildConfigName = "ProjectConfig"
- let projectLevelBuildConfigSettings = ["TEST_SETTING": "test_setting",
- "QuotedSetting": "Quoted string value"]
- let nativeTarget = SimpleProjectDefinition.NativeTargetDefinition(name: "NativeApplicationTarget",
- settings: ["PRODUCT_NAME": "ProductName", "QuotedValue": "A quoted value"],
- config: "Config1",
- targetType: PBXTarget.ProductType.Application
+ let projectLevelBuildConfigSettings = [
+ "TEST_SETTING": "test_setting",
+ "QuotedSetting": "Quoted string value"
+ ]
+ let nativeTarget = SimpleProjectDefinition.NativeTargetDefinition(
+ name: "NativeApplicationTarget",
+ settings: ["PRODUCT_NAME": "ProductName", "QuotedValue": "A quoted value"],
+ config: "Config1",
+ targetType: PBXTarget.ProductType.Application
)
- let legacyTarget = SimpleProjectDefinition.LegacyTargetDefinition(name: "LegacyTarget",
- buildToolPath: "buildToolPath",
- buildArguments: "buildArguments",
- buildWorkingDirectory: "buildWorkingDirectory")
+ let legacyTarget = SimpleProjectDefinition.LegacyTargetDefinition(
+ name: "LegacyTarget",
+ buildToolPath: "buildToolPath",
+ buildArguments: "buildArguments",
+ buildWorkingDirectory: "buildWorkingDirectory")
// Note: This test relies on the fact that the current serializer implementation preserves the
// GIDs of any objects it attempts to serialize.
@@ -226,93 +245,120 @@
let mainGroupDefinition: GroupDefinition
do {
let mainGroupFiles = [
- FileDefinition(sourceTree: .Group, path: "GroupFile.swift", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Absolute, path: "/fake/path/AbsoluteFile.swift", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "GroupFile.swift", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Absolute, path: "/fake/path/AbsoluteFile.swift",
+ gid: generator.generateReservedID()),
]
- let activeDatamodelVersion = FileDefinition(sourceTree: .Group,
- path: "v2.xcdatamodel",
- uti: DirExtensionToUTI["xcdatamodel"],
- gid: generator.generateReservedID(),
- isInputFile: true)
+ let activeDatamodelVersion = FileDefinition(
+ sourceTree: .Group,
+ path: "v2.xcdatamodel",
+ uti: DirExtensionToUTI["xcdatamodel"],
+ gid: generator.generateReservedID(),
+ isInputFile: true)
let mainGroupGroups = [
- GroupDefinition(name: "Products",
- sourceTree: .Group,
- path: nil,
- gid: generator.generateReservedID(),
- files: [],
- groups: []
- ),
- GroupDefinition(name: "ChildGroup",
- sourceTree: .Group,
- path: "child_group_path",
- gid: generator.generateReservedID(),
- files: [
- FileDefinition(sourceTree: .Group, path: "ChildRelativeFile.swift", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.a", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.dylib", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.framework", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.jpg", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.m", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.mm", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.pch", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.plist", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.png", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.rtf", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.storyboard", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.xcassets", uti: DirExtensionToUTI["xcassets"], gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.xcstickers", uti: DirExtensionToUTI["xcstickers"], gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "t.xib", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "Test", uti: "text", gid: generator.generateReservedID()),
- FileDefinition(sourceTree: .Group, path: "Output.app", gid: generator.generateReservedID(), isInputFile: false),
- ],
- groups: []
- ),
- VersionGroupDefinition(name: "DataModel.xcdatamodeld",
- sourceTree: .Group,
- path: "DataModel.xcdatamodeld",
- gid: generator.generateReservedID(),
- files: [
- FileDefinition(sourceTree: .Group,
- path: "v1.xcdatamodel",
- uti: DirExtensionToUTI["xcdatamodel"],
- gid: generator.generateReservedID(),
- isInputFile: true),
- activeDatamodelVersion,
- ],
- groups: [],
- currentVersion: activeDatamodelVersion,
- versionGroupType: DirExtensionToUTI["xcdatamodeld"]
- )
- ]
- mainGroupDefinition = GroupDefinition(name: "mainGroup",
- sourceTree: .SourceRoot,
+ GroupDefinition(
+ name: "Products",
+ sourceTree: .Group,
path: nil,
- gid: mainGroupGID,
- files: mainGroupFiles,
- groups: mainGroupGroups)
+ gid: generator.generateReservedID(),
+ files: [],
+ groups: []
+ ),
+ GroupDefinition(
+ name: "ChildGroup",
+ sourceTree: .Group,
+ path: "child_group_path",
+ gid: generator.generateReservedID(),
+ files: [
+ FileDefinition(
+ sourceTree: .Group, path: "ChildRelativeFile.swift",
+ gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.a", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "t.dylib", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "t.framework", gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.jpg", gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.m", gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.mm", gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.pch", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "t.plist", gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.png", gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.rtf", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "t.storyboard", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "t.xcassets", uti: DirExtensionToUTI["xcassets"],
+ gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "t.xcstickers", uti: DirExtensionToUTI["xcstickers"],
+ gid: generator.generateReservedID()),
+ FileDefinition(sourceTree: .Group, path: "t.xib", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "Test", uti: "text", gid: generator.generateReservedID()),
+ FileDefinition(
+ sourceTree: .Group, path: "Output.app", gid: generator.generateReservedID(),
+ isInputFile: false),
+ ],
+ groups: []
+ ),
+ VersionGroupDefinition(
+ name: "DataModel.xcdatamodeld",
+ sourceTree: .Group,
+ path: "DataModel.xcdatamodeld",
+ gid: generator.generateReservedID(),
+ files: [
+ FileDefinition(
+ sourceTree: .Group,
+ path: "v1.xcdatamodel",
+ uti: DirExtensionToUTI["xcdatamodel"],
+ gid: generator.generateReservedID(),
+ isInputFile: true),
+ activeDatamodelVersion,
+ ],
+ groups: [],
+ currentVersion: activeDatamodelVersion,
+ versionGroupType: DirExtensionToUTI["xcdatamodeld"]
+ ),
+ ]
+ mainGroupDefinition = GroupDefinition(
+ name: "mainGroup",
+ sourceTree: .SourceRoot,
+ path: nil,
+ gid: mainGroupGID,
+ files: mainGroupFiles,
+ groups: mainGroupGroups)
}
- let definition = SimpleProjectDefinition(projectLevelBuildConfigName: projectLevelBuildConfigName,
- projectLevelBuildConfigSettings: projectLevelBuildConfigSettings,
- nativeTarget: nativeTarget,
- legacyTarget: legacyTarget,
- mainGroupGID: mainGroupGID,
- mainGroupDefinition: mainGroupDefinition
+ let definition = SimpleProjectDefinition(
+ projectLevelBuildConfigName: projectLevelBuildConfigName,
+ projectLevelBuildConfigSettings: projectLevelBuildConfigSettings,
+ nativeTarget: nativeTarget,
+ legacyTarget: legacyTarget,
+ mainGroupGID: mainGroupGID,
+ mainGroupDefinition: mainGroupDefinition
)
do {
- let config = targetProject.buildConfigurationList.getOrCreateBuildConfiguration(projectLevelBuildConfigName)
+ let config = targetProject.buildConfigurationList.getOrCreateBuildConfiguration(
+ projectLevelBuildConfigName)
config.buildSettings = projectLevelBuildConfigSettings
}
- let nativePBXTarget = targetProject.createNativeTarget(nativeTarget.name,
- deploymentTarget: nil,
- targetType: nativeTarget.targetType)
- let config = nativePBXTarget.buildConfigurationList.getOrCreateBuildConfiguration(nativeTarget.config)
+ let nativePBXTarget = targetProject.createNativeTarget(
+ nativeTarget.name,
+ deploymentTarget: nil,
+ targetType: nativeTarget.targetType)
+ let config = nativePBXTarget.buildConfigurationList.getOrCreateBuildConfiguration(
+ nativeTarget.config)
config.buildSettings = nativeTarget.settings
- let legacyPBXTarget = targetProject.createLegacyTarget(legacyTarget.name,
- deploymentTarget: nil,
- buildToolPath: legacyTarget.buildToolPath,
- buildArguments: legacyTarget.buildArguments,
- buildWorkingDirectory: legacyTarget.buildWorkingDirectory)
+ let legacyPBXTarget = targetProject.createLegacyTarget(
+ legacyTarget.name,
+ deploymentTarget: nil,
+ buildToolPath: legacyTarget.buildToolPath,
+ buildArguments: legacyTarget.buildArguments,
+ buildWorkingDirectory: legacyTarget.buildWorkingDirectory)
targetProject.linkTestTarget(legacyPBXTarget, toHostTarget: nativePBXTarget)
do {
@@ -326,12 +372,14 @@
for childDef in groupDefinition.groups {
let childGroup: PBXGroup
if let versionedChildDef = childDef as? VersionGroupDefinition {
- let versionGroup = group.getOrCreateChildVersionGroupByName(versionedChildDef.name,
- path: versionedChildDef.path)
+ let versionGroup = group.getOrCreateChildVersionGroupByName(
+ versionedChildDef.name,
+ path: versionedChildDef.path)
versionGroup.versionGroupType = versionedChildDef.versionGroupType
let currentVersionDef = versionedChildDef.currentVersion
- let currentFileRef = versionGroup.getOrCreateFileReferenceBySourceTree(currentVersionDef.sourceTree,
- path: currentVersionDef.path)
+ let currentFileRef = versionGroup.getOrCreateFileReferenceBySourceTree(
+ currentVersionDef.sourceTree,
+ path: currentVersionDef.path)
currentFileRef.globalID = currentVersionDef.gid
currentFileRef.isInputFile = currentVersionDef.isInputFile
versionGroup.currentVersion = currentFileRef
@@ -350,18 +398,23 @@
return definition
}
- private func assertDict(_ dict: StringToObjectDict, isPBXObjectClass pbxClass: String, line: UInt = #line) {
+ private func assertDict(
+ _ dict: StringToObjectDict, isPBXObjectClass pbxClass: String, line: UInt = #line
+ ) {
guard let isa = dict["isa"] as? String else {
XCTFail("dictionary is not a PBXObject (missing 'isa' member)", line: line)
return
}
- XCTAssertEqual(isa, pbxClass, "Serialized dict is not of the expected PBXObject type", line: line)
+ XCTAssertEqual(
+ isa, pbxClass, "Serialized dict is not of the expected PBXObject type", line: line)
}
- private func getObjectByID(_ gid: String,
- withPBXClass pbxClass: String,
- fromObjects objects: StringToObjectDict,
- line: UInt = #line) -> StringToObjectDict? {
+ private func getObjectByID(
+ _ gid: String,
+ withPBXClass pbxClass: String,
+ fromObjects objects: StringToObjectDict,
+ line: UInt = #line
+ ) -> StringToObjectDict? {
guard let dict = objects[gid] as? StringToObjectDict else {
XCTFail("Missing \(pbxClass) with globalID '\(gid)'", line: line)
return nil
@@ -370,7 +423,6 @@
return dict
}
-
/// Generates predictable GlobalID's for use in tests.
// Note, this implementation is only suitable for projects with less than 4 billion objects.
class MockGIDGenerator: GIDGeneratorProtocol {
@@ -385,13 +437,13 @@
// MARK: - Methods for testing.
func generateReservedID() -> String {
- let reservedID = gidForCounter(nextID, prefix: 0xBAADF00D)
+ let reservedID = gidForCounter(nextID, prefix: 0xBAAD_F00D)
nextID += 1
return reservedID
}
- private func gidForCounter(_ counter : Int, prefix: Int = 0) -> String {
- return String(format: "%08X%08X%08X", prefix, 0, counter & 0xFFFFFFFF)
+ private func gidForCounter(_ counter: Int, prefix: Int = 0) -> String {
+ return String(format: "%08X%08X%08X", prefix, 0, counter & 0xFFFF_FFFF)
}
}
}
diff --git a/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift b/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift
index 9ecb372..e7abdce 100644
--- a/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift
+++ b/src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
// Note: Rather than test the serializer's output, we make use of the knowledge that
@@ -20,10 +21,13 @@
class PBXTargetGeneratorTests: XCTestCase {
let bazelPath = "__BAZEL_BINARY_"
let workspaceRootURL = URL(fileURLWithPath: "/workspaceRootURL", isDirectory: true)
- let stubPlistPaths = StubInfoPlistPaths(resourcesDirectory: "${PROJECT_FILE_PATH}/.tulsi/Resources",
- defaultStub: "TestInfo.plist",
- watchOSStub: "TestWatchOS2Info.plist",
- watchOSAppExStub: "TestWatchOS2AppExInfo.plist")
+
+ let stubPlistPaths = StubInfoPlistPaths(
+ resourcesDirectory: "${PROJECT_FILE_PATH}/.tulsi/Resources",
+ defaultStub: "TestInfo.plist",
+ watchOSStub: "TestWatchOS2Info.plist",
+ watchOSAppExStub: "TestWatchOS2AppExInfo.plist")
+
let testTulsiVersion = "9.99.999.9999"
var project: PBXProject! = nil
var targetGenerator: PBXTargetGenerator! = nil
@@ -31,15 +35,16 @@
override func setUp() {
super.setUp()
project = PBXProject(name: "TestProject")
- targetGenerator = PBXTargetGenerator(bazelPath: bazelPath,
- bazelBinPath: "bazel-bin",
- project: project,
- buildScriptPath: "",
- stubInfoPlistPaths: stubPlistPaths,
- tulsiVersion: testTulsiVersion,
- options: TulsiOptionSet(),
- localizedMessageLogger: MockLocalizedMessageLogger(),
- workspaceRootURL: workspaceRootURL)
+ targetGenerator = PBXTargetGenerator(
+ bazelPath: bazelPath,
+ bazelBinPath: "bazel-bin",
+ project: project,
+ buildScriptPath: "",
+ stubInfoPlistPaths: stubPlistPaths,
+ tulsiVersion: testTulsiVersion,
+ options: TulsiOptionSet(),
+ localizedMessageLogger: MockLocalizedMessageLogger(),
+ workspaceRootURL: workspaceRootURL)
}
@@ -53,7 +58,9 @@
let fileRef = project.mainGroup.allSources.first!
let sourceRelativePath = fileRef.sourceRootRelativePath
XCTAssertEqual(sourceRelativePath, buildFilePath)
- XCTAssertEqual(fileRef.sourceTree, SourceTree.Group, "SourceTree mismatch for generated BUILD file \(buildFilePath)")
+ XCTAssertEqual(
+ fileRef.sourceTree, SourceTree.Group,
+ "SourceTree mismatch for generated BUILD file \(buildFilePath)")
}
func testGenerateFileReferenceForBUILDFilePaths() {
@@ -62,51 +69,76 @@
XCTAssertEqual(project.mainGroup.children.count, buildFilePaths.count)
for fileRef in project.mainGroup.allSources {
- XCTAssert(buildFilePaths.contains(fileRef.sourceRootRelativePath), "Path mismatch for generated BUILD file \(String(describing: fileRef.path))")
- XCTAssertEqual(fileRef.sourceTree, SourceTree.Group, "SourceTree mismatch for generated BUILD file \(String(describing: fileRef.path))")
+ XCTAssert(
+ buildFilePaths.contains(fileRef.sourceRootRelativePath),
+ "Path mismatch for generated BUILD file \(String(describing: fileRef.path))")
+ XCTAssertEqual(
+ fileRef.sourceTree, SourceTree.Group,
+ "SourceTree mismatch for generated BUILD file \(String(describing: fileRef.path))")
}
}
func testMainGroupForOutputFolder() {
- func assertOutputFolder(_ output: String,
- workspace: String,
- generatesSourceTree sourceTree: SourceTree,
- path: String?,
- line: UInt = #line) {
+ func assertOutputFolder(
+ _ output: String,
+ workspace: String,
+ generatesSourceTree sourceTree: SourceTree,
+ path: String?,
+ line: UInt = #line
+ ) {
let outputURL = URL(fileURLWithPath: output, isDirectory: true)
let workspaceURL = URL(fileURLWithPath: workspace, isDirectory: true)
- let group = PBXTargetGenerator.mainGroupForOutputFolder(outputURL,
- workspaceRootURL: workspaceURL)
+ let group = PBXTargetGenerator.mainGroupForOutputFolder(
+ outputURL,
+ workspaceRootURL: workspaceURL)
XCTAssertEqual(group.sourceTree, sourceTree, line: line)
XCTAssertEqual(group.path, path, line: line)
}
assertOutputFolder("/", workspace: "/", generatesSourceTree: .SourceRoot, path: nil)
assertOutputFolder("/output", workspace: "/output", generatesSourceTree: .SourceRoot, path: nil)
- assertOutputFolder("/output/", workspace: "/output", generatesSourceTree: .SourceRoot, path: nil)
- assertOutputFolder("/output", workspace: "/output/", generatesSourceTree: .SourceRoot, path: nil)
+ assertOutputFolder(
+ "/output/", workspace: "/output", generatesSourceTree: .SourceRoot, path: nil)
+ assertOutputFolder(
+ "/output", workspace: "/output/", generatesSourceTree: .SourceRoot, path: nil)
assertOutputFolder("/", workspace: "/output", generatesSourceTree: .SourceRoot, path: "output")
- assertOutputFolder("/output", workspace: "/output/workspace", generatesSourceTree: .SourceRoot, path: "workspace")
- assertOutputFolder("/output/", workspace: "/output/workspace", generatesSourceTree: .SourceRoot, path: "workspace")
- assertOutputFolder("/output", workspace: "/output/workspace/", generatesSourceTree: .SourceRoot, path: "workspace")
- assertOutputFolder("/output", workspace: "/output/deep/path/workspace", generatesSourceTree: .SourceRoot, path: "deep/path/workspace")
- assertOutputFolder("/path/to/workspace/output", workspace: "/path/to/workspace", generatesSourceTree: .SourceRoot, path: "..")
+ assertOutputFolder(
+ "/output", workspace: "/output/workspace", generatesSourceTree: .SourceRoot, path: "workspace"
+ )
+ assertOutputFolder(
+ "/output/", workspace: "/output/workspace", generatesSourceTree: .SourceRoot,
+ path: "workspace")
+ assertOutputFolder(
+ "/output", workspace: "/output/workspace/", generatesSourceTree: .SourceRoot,
+ path: "workspace")
+ assertOutputFolder(
+ "/output", workspace: "/output/deep/path/workspace", generatesSourceTree: .SourceRoot,
+ path: "deep/path/workspace")
+ assertOutputFolder(
+ "/path/to/workspace/output", workspace: "/path/to/workspace",
+ generatesSourceTree: .SourceRoot, path: "..")
assertOutputFolder("/output", workspace: "/", generatesSourceTree: .SourceRoot, path: "..")
assertOutputFolder("/output/", workspace: "/", generatesSourceTree: .SourceRoot, path: "..")
- assertOutputFolder("/path/to/workspace/three/deep/output", workspace: "/path/to/workspace", generatesSourceTree: .SourceRoot, path: "../../..")
- assertOutputFolder("/path/to/output", workspace: "/elsewhere/workspace", generatesSourceTree: .Absolute, path: "/elsewhere/workspace")
+ assertOutputFolder(
+ "/path/to/workspace/three/deep/output", workspace: "/path/to/workspace",
+ generatesSourceTree: .SourceRoot, path: "../../..")
+ assertOutputFolder(
+ "/path/to/output", workspace: "/elsewhere/workspace", generatesSourceTree: .Absolute,
+ path: "/elsewhere/workspace")
}
}
-
class PBXTargetGeneratorTestsWithFiles: XCTestCase {
let bazelPath = "__BAZEL_BINARY_"
let workspaceRootURL = URL(fileURLWithPath: "/workspaceRootURL", isDirectory: true)
let sdkRoot = "sdkRoot"
- let stubPlistPaths = StubInfoPlistPaths(resourcesDirectory:"${PROJECT_ROOT}/asd",
- defaultStub: "TestInfo.plist",
- watchOSStub: "TestWatchOS2Info.plist",
- watchOSAppExStub: "TestWatchOS2AppExInfo.plist")
+
+ let stubPlistPaths = StubInfoPlistPaths(
+ resourcesDirectory: "${PROJECT_ROOT}/asd",
+ defaultStub: "TestInfo.plist",
+ watchOSStub: "TestWatchOS2Info.plist",
+ watchOSAppExStub: "TestWatchOS2AppExInfo.plist")
+
let testTulsiVersion = "9.99.999.9999"
var project: PBXProject! = nil
@@ -128,15 +160,16 @@
pchFile = project.mainGroup.getOrCreateFileReferenceBySourceTree(.Group, path: "pch.pch")
let options = TulsiOptionSet()
messageLogger = MockLocalizedMessageLogger()
- targetGenerator = PBXTargetGenerator(bazelPath: bazelPath,
- bazelBinPath: "bazel-bin",
- project: project,
- buildScriptPath: "",
- stubInfoPlistPaths: stubPlistPaths,
- tulsiVersion: testTulsiVersion,
- options: options,
- localizedMessageLogger: messageLogger,
- workspaceRootURL: workspaceRootURL)
+ targetGenerator = PBXTargetGenerator(
+ bazelPath: bazelPath,
+ bazelBinPath: "bazel-bin",
+ project: project,
+ buildScriptPath: "",
+ stubInfoPlistPaths: stubPlistPaths,
+ tulsiVersion: testTulsiVersion,
+ options: options,
+ localizedMessageLogger: messageLogger,
+ workspaceRootURL: workspaceRootURL)
}
// MARK: - Tests
@@ -160,7 +193,9 @@
func testGenerateBazelCleanTargetAppliesToRulesAddedBeforeAndAfter() {
do {
- try targetGenerator.generateBuildTargetsForRuleEntries([makeTestRuleEntry("before", type: "ios_application", productType: .Application)], ruleEntryMap: RuleEntryMap())
+ try targetGenerator.generateBuildTargetsForRuleEntries(
+ [makeTestRuleEntry("before", type: "ios_application", productType: .Application)],
+ ruleEntryMap: RuleEntryMap())
} catch let e as NSError {
XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
}
@@ -168,7 +203,9 @@
targetGenerator.generateBazelCleanTarget("scriptPath")
do {
- try targetGenerator.generateBuildTargetsForRuleEntries([makeTestRuleEntry("after", type: "ios_application", productType: .Application)], ruleEntryMap: RuleEntryMap())
+ try targetGenerator.generateBuildTargetsForRuleEntries(
+ [makeTestRuleEntry("after", type: "ios_application", productType: .Application)],
+ ruleEntryMap: RuleEntryMap())
} catch let e as NSError {
XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
}
@@ -181,13 +218,20 @@
for target in project.allTargets {
if target === integrationTarget { continue }
- XCTAssertEqual(target.dependencies.count, 1, "Mismatch in dependency count for target added \(target.name)")
+ XCTAssertEqual(
+ target.dependencies.count, 1, "Mismatch in dependency count for target added \(target.name)"
+ )
let targetProxy = target.dependencies[0].targetProxy
- XCTAssert(targetProxy.containerPortal === project, "Mismatch in container for dependency in target added \(target.name)")
- XCTAssert(targetProxy.target === integrationTarget, "Mismatch in target dependency for target added \(target.name)")
- XCTAssertEqual(targetProxy.proxyType,
- PBXContainerItemProxy.ProxyType.targetReference,
- "Mismatch in target dependency type for target added \(target.name)")
+ XCTAssert(
+ targetProxy.containerPortal === project,
+ "Mismatch in container for dependency in target added \(target.name)")
+ XCTAssert(
+ targetProxy.target === integrationTarget,
+ "Mismatch in target dependency for target added \(target.name)")
+ XCTAssertEqual(
+ targetProxy.proxyType,
+ PBXContainerItemProxy.ProxyType.targetReference,
+ "Mismatch in target dependency type for target added \(target.name)")
}
}
@@ -198,48 +242,52 @@
XCTAssertEqual(topLevelConfigs.count, 4)
let topLevelBuildSettings = [
- "ALWAYS_SEARCH_USER_PATHS": "NO",
- "CLANG_CXX_LANGUAGE_STANDARD": "c++11",
- "CLANG_ENABLE_OBJC_ARC": "YES",
- "CLANG_WARN_BOOL_CONVERSION": "YES",
- "CLANG_WARN_CONSTANT_CONVERSION": "YES",
- "CLANG_WARN_EMPTY_BODY": "YES",
- "CLANG_WARN_ENUM_CONVERSION": "YES",
- "CLANG_WARN_INT_CONVERSION": "YES",
- "CLANG_WARN_UNREACHABLE_CODE": "YES",
- "CLANG_WARN__DUPLICATE_METHOD_MATCH": "YES",
- "CODE_SIGNING_REQUIRED": "NO",
- "CODE_SIGN_IDENTITY": "",
- "DONT_RUN_SWIFT_STDLIB_TOOL": "YES",
- "ENABLE_TESTABILITY": "YES",
- "FRAMEWORK_SEARCH_PATHS": "$(PLATFORM_DIR)/Developer/Library/Frameworks",
- "GCC_WARN_64_TO_32_BIT_CONVERSION": "YES",
- "GCC_WARN_ABOUT_RETURN_TYPE": "YES",
- "GCC_WARN_UNDECLARED_SELECTOR": "YES",
- "GCC_WARN_UNINITIALIZED_AUTOS": "YES",
- "GCC_WARN_UNUSED_FUNCTION": "YES",
- "GCC_WARN_UNUSED_VARIABLE": "YES",
- "HEADER_SEARCH_PATHS": "$(TULSI_BWRS) $(TULSI_WR)/bazel-bin $(TULSI_WR)/bazel-genfiles "
- + "$(TULSI_BWRS)/\(PBXTargetGenerator.tulsiIncludesPath)",
- "ONLY_ACTIVE_ARCH": "YES",
- "PYTHONIOENCODING": "utf8",
- "TULSI_VERSION": testTulsiVersion,
- "TULSI_WR": "$(SRCROOT)",
- "TULSI_BWRS": "$(PROJECT_FILE_PATH)/.tulsi/tulsi-workspace",
+ "ALWAYS_SEARCH_USER_PATHS": "NO",
+ "CLANG_CXX_LANGUAGE_STANDARD": "c++11",
+ "CLANG_ENABLE_OBJC_ARC": "YES",
+ "CLANG_WARN_BOOL_CONVERSION": "YES",
+ "CLANG_WARN_CONSTANT_CONVERSION": "YES",
+ "CLANG_WARN_EMPTY_BODY": "YES",
+ "CLANG_WARN_ENUM_CONVERSION": "YES",
+ "CLANG_WARN_INT_CONVERSION": "YES",
+ "CLANG_WARN_UNREACHABLE_CODE": "YES",
+ "CLANG_WARN__DUPLICATE_METHOD_MATCH": "YES",
+ "CODE_SIGNING_REQUIRED": "NO",
+ "CODE_SIGN_IDENTITY": "",
+ "DONT_RUN_SWIFT_STDLIB_TOOL": "YES",
+ "ENABLE_TESTABILITY": "YES",
+ "FRAMEWORK_SEARCH_PATHS": "$(PLATFORM_DIR)/Developer/Library/Frameworks",
+ "GCC_WARN_64_TO_32_BIT_CONVERSION": "YES",
+ "GCC_WARN_ABOUT_RETURN_TYPE": "YES",
+ "GCC_WARN_UNDECLARED_SELECTOR": "YES",
+ "GCC_WARN_UNINITIALIZED_AUTOS": "YES",
+ "GCC_WARN_UNUSED_FUNCTION": "YES",
+ "GCC_WARN_UNUSED_VARIABLE": "YES",
+ "HEADER_SEARCH_PATHS": "$(TULSI_BWRS) $(TULSI_WR)/bazel-bin $(TULSI_WR)/bazel-genfiles "
+ + "$(TULSI_BWRS)/\(PBXTargetGenerator.tulsiIncludesPath)",
+ "ONLY_ACTIVE_ARCH": "YES",
+ "PYTHONIOENCODING": "utf8",
+ "TULSI_VERSION": testTulsiVersion,
+ "TULSI_WR": "$(SRCROOT)",
+ "TULSI_BWRS": "$(PROJECT_FILE_PATH)/.tulsi/tulsi-workspace",
]
XCTAssertNotNil(topLevelConfigs["Debug"])
- XCTAssertEqual(topLevelConfigs["Debug"]!.buildSettings,
- debugBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["Debug"]!.buildSettings,
+ debugBuildSettingsFromSettings(topLevelBuildSettings))
XCTAssertNotNil(topLevelConfigs["Release"])
- XCTAssertEqual(topLevelConfigs["Release"]!.buildSettings,
- releaseBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["Release"]!.buildSettings,
+ releaseBuildSettingsFromSettings(topLevelBuildSettings))
XCTAssertNotNil(topLevelConfigs["__TulsiTestRunner_Debug"])
- XCTAssertEqual(topLevelConfigs["__TulsiTestRunner_Debug"]!.buildSettings,
- debugTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["__TulsiTestRunner_Debug"]!.buildSettings,
+ debugTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
XCTAssertNotNil(topLevelConfigs["__TulsiTestRunner_Release"])
- XCTAssertEqual(topLevelConfigs["__TulsiTestRunner_Release"]!.buildSettings,
- releaseTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["__TulsiTestRunner_Release"]!.buildSettings,
+ releaseTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
}
func testGenerateTopLevelBuildConfigurationsWithAnSDKROOT() {
@@ -250,49 +298,53 @@
XCTAssertEqual(topLevelConfigs.count, 4)
let topLevelBuildSettings = [
- "ALWAYS_SEARCH_USER_PATHS": "NO",
- "CLANG_CXX_LANGUAGE_STANDARD": "c++11",
- "CLANG_ENABLE_OBJC_ARC": "YES",
- "CLANG_WARN_BOOL_CONVERSION": "YES",
- "CLANG_WARN_CONSTANT_CONVERSION": "YES",
- "CLANG_WARN_EMPTY_BODY": "YES",
- "CLANG_WARN_ENUM_CONVERSION": "YES",
- "CLANG_WARN_INT_CONVERSION": "YES",
- "CLANG_WARN_UNREACHABLE_CODE": "YES",
- "CLANG_WARN__DUPLICATE_METHOD_MATCH": "YES",
- "CODE_SIGNING_REQUIRED": "NO",
- "CODE_SIGN_IDENTITY": "",
- "DONT_RUN_SWIFT_STDLIB_TOOL": "YES",
- "ENABLE_TESTABILITY": "YES",
- "FRAMEWORK_SEARCH_PATHS": "$(PLATFORM_DIR)/Developer/Library/Frameworks",
- "GCC_WARN_64_TO_32_BIT_CONVERSION": "YES",
- "GCC_WARN_ABOUT_RETURN_TYPE": "YES",
- "GCC_WARN_UNDECLARED_SELECTOR": "YES",
- "GCC_WARN_UNINITIALIZED_AUTOS": "YES",
- "GCC_WARN_UNUSED_FUNCTION": "YES",
- "GCC_WARN_UNUSED_VARIABLE": "YES",
- "HEADER_SEARCH_PATHS": "$(TULSI_BWRS) $(TULSI_WR)/bazel-bin $(TULSI_WR)/bazel-genfiles "
- + "$(TULSI_BWRS)/\(PBXTargetGenerator.tulsiIncludesPath)",
- "SDKROOT": projectSDKROOT,
- "ONLY_ACTIVE_ARCH": "YES",
- "PYTHONIOENCODING": "utf8",
- "TULSI_VERSION": testTulsiVersion,
- "TULSI_WR": "$(SRCROOT)",
- "TULSI_BWRS": "$(PROJECT_FILE_PATH)/.tulsi/tulsi-workspace",
+ "ALWAYS_SEARCH_USER_PATHS": "NO",
+ "CLANG_CXX_LANGUAGE_STANDARD": "c++11",
+ "CLANG_ENABLE_OBJC_ARC": "YES",
+ "CLANG_WARN_BOOL_CONVERSION": "YES",
+ "CLANG_WARN_CONSTANT_CONVERSION": "YES",
+ "CLANG_WARN_EMPTY_BODY": "YES",
+ "CLANG_WARN_ENUM_CONVERSION": "YES",
+ "CLANG_WARN_INT_CONVERSION": "YES",
+ "CLANG_WARN_UNREACHABLE_CODE": "YES",
+ "CLANG_WARN__DUPLICATE_METHOD_MATCH": "YES",
+ "CODE_SIGNING_REQUIRED": "NO",
+ "CODE_SIGN_IDENTITY": "",
+ "DONT_RUN_SWIFT_STDLIB_TOOL": "YES",
+ "ENABLE_TESTABILITY": "YES",
+ "FRAMEWORK_SEARCH_PATHS": "$(PLATFORM_DIR)/Developer/Library/Frameworks",
+ "GCC_WARN_64_TO_32_BIT_CONVERSION": "YES",
+ "GCC_WARN_ABOUT_RETURN_TYPE": "YES",
+ "GCC_WARN_UNDECLARED_SELECTOR": "YES",
+ "GCC_WARN_UNINITIALIZED_AUTOS": "YES",
+ "GCC_WARN_UNUSED_FUNCTION": "YES",
+ "GCC_WARN_UNUSED_VARIABLE": "YES",
+ "HEADER_SEARCH_PATHS": "$(TULSI_BWRS) $(TULSI_WR)/bazel-bin $(TULSI_WR)/bazel-genfiles "
+ + "$(TULSI_BWRS)/\(PBXTargetGenerator.tulsiIncludesPath)",
+ "SDKROOT": projectSDKROOT,
+ "ONLY_ACTIVE_ARCH": "YES",
+ "PYTHONIOENCODING": "utf8",
+ "TULSI_VERSION": testTulsiVersion,
+ "TULSI_WR": "$(SRCROOT)",
+ "TULSI_BWRS": "$(PROJECT_FILE_PATH)/.tulsi/tulsi-workspace",
]
XCTAssertNotNil(topLevelConfigs["Debug"])
- XCTAssertEqual(topLevelConfigs["Debug"]!.buildSettings,
- debugBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["Debug"]!.buildSettings,
+ debugBuildSettingsFromSettings(topLevelBuildSettings))
XCTAssertNotNil(topLevelConfigs["Release"])
- XCTAssertEqual(topLevelConfigs["Release"]!.buildSettings,
- releaseBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["Release"]!.buildSettings,
+ releaseBuildSettingsFromSettings(topLevelBuildSettings))
XCTAssertNotNil(topLevelConfigs["__TulsiTestRunner_Debug"])
- XCTAssertEqual(topLevelConfigs["__TulsiTestRunner_Debug"]!.buildSettings,
- debugTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["__TulsiTestRunner_Debug"]!.buildSettings,
+ debugTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
XCTAssertNotNil(topLevelConfigs["__TulsiTestRunner_Release"])
- XCTAssertEqual(topLevelConfigs["__TulsiTestRunner_Release"]!.buildSettings,
- releaseTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
+ XCTAssertEqual(
+ topLevelConfigs["__TulsiTestRunner_Release"]!.buildSettings,
+ releaseTestRunnerBuildSettingsFromSettings(topLevelBuildSettings))
}
func testGenerateTargetsForRuleEntriesWithNoEntries() {
@@ -332,87 +384,90 @@
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/app:TestApplication",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_NAME": rule1TargetName,
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": rule1BuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/app:TestApplication",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_NAME": rule1TargetName,
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": rule1BuildPath,
]
let expectedTarget = TargetDefinition(
- name: rule1TargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget)
- ]
+ name: rule1TargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/objclib:ObjectiveCLibrary",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_NAME": rule2TargetName,
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": rule2BuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/objclib:ObjectiveCLibrary",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_NAME": rule2TargetName,
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": rule2BuildPath,
]
let expectedTarget = TargetDefinition(
- name: rule2TargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget)
- ]
+ name: rule2TargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
}
func testGenerateTargetsForLinkedRuleEntriesWithNoSourcesAndSkylarkUnitTest() {
- checkGenerateTargetsForLinkedRuleEntriesWithNoSources("ios_unit_test",
- testProductType: .UnitTest,
- testHostAttributeName: "test_host")
+ checkGenerateTargetsForLinkedRuleEntriesWithNoSources(
+ "ios_unit_test",
+ testProductType: .UnitTest,
+ testHostAttributeName: "test_host")
}
- func checkGenerateTargetsForLinkedRuleEntriesWithNoSources(_ testRuleType: String,
- testProductType: PBXTarget.ProductType,
- testHostAttributeName: String) {
+ func checkGenerateTargetsForLinkedRuleEntriesWithNoSources(
+ _ testRuleType: String,
+ testProductType: PBXTarget.ProductType,
+ testHostAttributeName: String
+ ) {
let rule1BuildPath = "test/app"
let rule1TargetName = "TestApplication"
let rule1BuildTarget = "\(rule1BuildPath):\(rule1TargetName)"
@@ -422,12 +477,13 @@
let rule2Attributes = [testHostAttributeName: rule1BuildTarget]
let rules = Set([
makeTestRuleEntry(rule1BuildTarget, type: "ios_application", productType: .Application),
- makeTestRuleEntry(rule2BuildTarget,
- type: testRuleType,
- attributes: rule2Attributes as [String: AnyObject],
- productType: testProductType,
- platformType: "ios",
- osDeploymentTarget: "8.0"),
+ makeTestRuleEntry(
+ rule2BuildTarget,
+ type: testRuleType,
+ attributes: rule2Attributes as [String: AnyObject],
+ productType: testProductType,
+ platformType: "ios",
+ osDeploymentTarget: "8.0"),
])
do {
@@ -445,77 +501,77 @@
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/app:TestApplication",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_NAME": rule1TargetName,
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": rule1BuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/app:TestApplication",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_NAME": rule1TargetName,
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": rule1BuildPath,
]
let expectedTarget = TargetDefinition(
- name: rule1TargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget)
- ]
+ name: rule1TargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/testbundle:TestBundle",
- "BUNDLE_LOADER": "$(TEST_HOST)",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "IPHONEOS_DEPLOYMENT_TARGET": "8.0",
- "PRODUCT_NAME": rule2TargetName,
- "SDKROOT": "iphoneos",
- "TEST_HOST": "$(BUILT_PRODUCTS_DIR)/\(rule1TargetName).app/\(rule1TargetName)",
- "TULSI_BUILD_PATH": rule2BuildPath,
- "TULSI_TEST_RUNNER_ONLY": "YES",
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/testbundle:TestBundle",
+ "BUNDLE_LOADER": "$(TEST_HOST)",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "IPHONEOS_DEPLOYMENT_TARGET": "8.0",
+ "PRODUCT_NAME": rule2TargetName,
+ "SDKROOT": "iphoneos",
+ "TEST_HOST": "$(BUILT_PRODUCTS_DIR)/\(rule1TargetName).app/\(rule1TargetName)",
+ "TULSI_BUILD_PATH": rule2BuildPath,
+ "TULSI_TEST_RUNNER_ONLY": "YES",
]
let expectedTarget = TargetDefinition(
- name: rule2TargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget)
- ]
+ name: rule2TargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -533,13 +589,14 @@
let rule2Attributes = [testHostAttributeName: rule1BuildTarget]
let rules = Set([
makeTestRuleEntry(rule1BuildTarget, type: "ios_application", productType: .Application),
- makeTestRuleEntry(rule2BuildTarget,
- type: testRuleType,
- attributes: rule2Attributes as [String: AnyObject],
- productType: .UIUnitTest,
- platformType: "ios",
- osDeploymentTarget: "8.0"),
- ])
+ makeTestRuleEntry(
+ rule2BuildTarget,
+ type: testRuleType,
+ attributes: rule2Attributes as [String: AnyObject],
+ productType: .UIUnitTest,
+ platformType: "ios",
+ osDeploymentTarget: "8.0"),
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
@@ -563,7 +620,7 @@
"PRODUCT_NAME": rule1TargetName,
"SDKROOT": "iphoneos",
"TULSI_BUILD_PATH": rule1BuildPath,
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule1TargetName,
buildConfigurations: [
@@ -583,9 +640,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -602,7 +659,7 @@
"TEST_TARGET_NAME": rule1TargetName,
"TULSI_BUILD_PATH": rule2BuildPath,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule2TargetName,
buildConfigurations: [
@@ -622,9 +679,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -642,18 +699,20 @@
let rule2BuildTarget = "\(rule2BuildPath):\(rule2TargetName)"
let rule2Attributes = [testHostAttributeName: rule1BuildTarget]
let rules = Set([
- makeTestRuleEntry(rule1BuildTarget,
- type: "macos_application",
- productType: .Application,
- platformType: "macos",
- osDeploymentTarget: "10.11"),
- makeTestRuleEntry(rule2BuildTarget,
- type: testRuleType,
- attributes: rule2Attributes as [String: AnyObject],
- productType: .UnitTest,
- platformType: "macos",
- osDeploymentTarget: "10.11"),
- ])
+ makeTestRuleEntry(
+ rule1BuildTarget,
+ type: "macos_application",
+ productType: .Application,
+ platformType: "macos",
+ osDeploymentTarget: "10.11"),
+ makeTestRuleEntry(
+ rule2BuildTarget,
+ type: testRuleType,
+ attributes: rule2Attributes as [String: AnyObject],
+ productType: .UnitTest,
+ platformType: "macos",
+ osDeploymentTarget: "10.11"),
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
@@ -678,7 +737,7 @@
"PRODUCT_NAME": rule1TargetName,
"SDKROOT": "macosx",
"TULSI_BUILD_PATH": rule1BuildPath,
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule1TargetName,
buildConfigurations: [
@@ -698,9 +757,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -715,10 +774,11 @@
"MACOSX_DEPLOYMENT_TARGET": "10.11",
"PRODUCT_NAME": rule2TargetName,
"SDKROOT": "macosx",
- "TEST_HOST": "$(BUILT_PRODUCTS_DIR)/\(rule1TargetName).app/Contents/MacOS/\(rule1TargetName)",
+ "TEST_HOST":
+ "$(BUILT_PRODUCTS_DIR)/\(rule1TargetName).app/Contents/MacOS/\(rule1TargetName)",
"TULSI_BUILD_PATH": rule2BuildPath,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule2TargetName,
buildConfigurations: [
@@ -738,9 +798,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -758,18 +818,20 @@
let rule2BuildTarget = "\(rule2BuildPath):\(rule2TargetName)"
let rule2Attributes = [testHostAttributeName: rule1BuildTarget]
let rules = Set([
- makeTestRuleEntry(rule1BuildTarget,
- type: "macos_application",
- productType: .Application,
- platformType: "macos",
- osDeploymentTarget: "10.11"),
- makeTestRuleEntry(rule2BuildTarget,
- type: testRuleType,
- attributes: rule2Attributes as [String: AnyObject],
- productType: .UIUnitTest,
- platformType: "macos",
- osDeploymentTarget: "10.11"),
- ])
+ makeTestRuleEntry(
+ rule1BuildTarget,
+ type: "macos_application",
+ productType: .Application,
+ platformType: "macos",
+ osDeploymentTarget: "10.11"),
+ makeTestRuleEntry(
+ rule2BuildTarget,
+ type: testRuleType,
+ attributes: rule2Attributes as [String: AnyObject],
+ productType: .UIUnitTest,
+ platformType: "macos",
+ osDeploymentTarget: "10.11"),
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
@@ -794,7 +856,7 @@
"PRODUCT_NAME": rule1TargetName,
"SDKROOT": "macosx",
"TULSI_BUILD_PATH": rule1BuildPath,
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule1TargetName,
buildConfigurations: [
@@ -814,9 +876,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -833,7 +895,7 @@
"TEST_TARGET_NAME": rule1TargetName,
"TULSI_BUILD_PATH": rule2BuildPath,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule2TargetName,
buildConfigurations: [
@@ -853,9 +915,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -868,12 +930,13 @@
let rule1TargetName = "TestBundle"
let rule1BuildTarget = "\(rule1BuildPath):\(rule1TargetName)"
let rules = Set([
- makeTestRuleEntry(rule1BuildTarget,
- type: testRuleType,
- productType: .UnitTest,
- platformType: "macos",
- osDeploymentTarget: "10.11"),
- ])
+ makeTestRuleEntry(
+ rule1BuildTarget,
+ type: testRuleType,
+ productType: .UnitTest,
+ platformType: "macos",
+ osDeploymentTarget: "10.11"),
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
@@ -899,7 +962,7 @@
"SDKROOT": "macosx",
"TULSI_BUILD_PATH": rule1BuildPath,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule1TargetName,
buildConfigurations: [
@@ -919,9 +982,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -935,13 +998,14 @@
let rule1BuildTarget = "\(rule1BuildPath):\(rule1TargetName)"
let testSources = ["test/src1.m", "test/src2.m"]
let rules = Set([
- makeTestRuleEntry(rule1BuildTarget,
- type: testRuleType,
- sourceFiles: testSources,
- productType: .UnitTest,
- platformType: "macos",
- osDeploymentTarget: "10.11"),
- ])
+ makeTestRuleEntry(
+ rule1BuildTarget,
+ type: testRuleType,
+ sourceFiles: testSources,
+ productType: .UnitTest,
+ platformType: "macos",
+ osDeploymentTarget: "10.11"),
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
@@ -967,7 +1031,7 @@
"SDKROOT": "macosx",
"TULSI_BUILD_PATH": rule1BuildPath,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule1TargetName,
buildConfigurations: [
@@ -987,7 +1051,7 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
SourcesBuildPhaseDefinition(files: testSources, mainGroup: project.mainGroup),
@@ -999,14 +1063,17 @@
}
func testGenerateTargetsForLinkedRuleEntriesWithSourcesWithSkylarkUnitTest() {
- checkGenerateTargetsForLinkedRuleEntriesWithSources("ios_unit_test",
- testProductType: .UnitTest,
- testHostAttributeName: "test_host")
+ checkGenerateTargetsForLinkedRuleEntriesWithSources(
+ "ios_unit_test",
+ testProductType: .UnitTest,
+ testHostAttributeName: "test_host")
}
- func checkGenerateTargetsForLinkedRuleEntriesWithSources(_ testRuleType: String,
- testProductType: PBXTarget.ProductType,
- testHostAttributeName: String) {
+ func checkGenerateTargetsForLinkedRuleEntriesWithSources(
+ _ testRuleType: String,
+ testProductType: PBXTarget.ProductType,
+ testHostAttributeName: String
+ ) {
let rule1BuildPath = "test/app"
let rule1TargetName = "TestHost"
let rule1BuildTarget = "\(rule1BuildPath):\(rule1TargetName)"
@@ -1015,13 +1082,14 @@
let testRuleBuildTarget = "\(testRuleBuildPath):\(testRuleTargetName)"
let testRuleAttributes = [testHostAttributeName: rule1BuildTarget]
let testSources = ["sourceFile1.m", "sourceFile2.mm"]
- let testRule = makeTestRuleEntry(testRuleBuildTarget,
- type: testRuleType,
- attributes: testRuleAttributes as [String: AnyObject],
- sourceFiles: testSources,
- productType: testProductType,
- platformType: "ios",
- osDeploymentTarget: "8.0")
+ let testRule = makeTestRuleEntry(
+ testRuleBuildTarget,
+ type: testRuleType,
+ attributes: testRuleAttributes as [String: AnyObject],
+ sourceFiles: testSources,
+ productType: testProductType,
+ platformType: "ios",
+ osDeploymentTarget: "8.0")
let rules = Set([
makeTestRuleEntry(rule1BuildTarget, type: "ios_application", productType: .Application),
testRule,
@@ -1037,81 +1105,83 @@
XCTAssertEqual(targets.count, 2)
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/app:TestHost",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_NAME": rule1TargetName,
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": rule1BuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/app:TestHost",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_NAME": rule1TargetName,
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": rule1BuildPath,
]
let expectedTarget = TargetDefinition(
- name: rule1TargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath,
- buildTarget: rule1BuildTarget),
- ]
+ name: rule1TargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath,
+ buildTarget: rule1BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/testbundle:Tests",
- "BUNDLE_LOADER": "$(TEST_HOST)",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "IPHONEOS_DEPLOYMENT_TARGET": "8.0",
- "PRODUCT_NAME": testRuleTargetName,
- "SDKROOT": "iphoneos",
- "TEST_HOST": "$(BUILT_PRODUCTS_DIR)/\(rule1TargetName).app/\(rule1TargetName)",
- "TULSI_BUILD_PATH": testRuleBuildPath,
- "TULSI_TEST_RUNNER_ONLY": "YES",
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/testbundle:Tests",
+ "BUNDLE_LOADER": "$(TEST_HOST)",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "IPHONEOS_DEPLOYMENT_TARGET": "8.0",
+ "PRODUCT_NAME": testRuleTargetName,
+ "SDKROOT": "iphoneos",
+ "TEST_HOST": "$(BUILT_PRODUCTS_DIR)/\(rule1TargetName).app/\(rule1TargetName)",
+ "TULSI_BUILD_PATH": testRuleBuildPath,
+ "TULSI_TEST_RUNNER_ONLY": "YES",
]
let expectedTarget = TargetDefinition(
- name: testRuleTargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- SourcesBuildPhaseDefinition(files: testSources, mainGroup: project.mainGroup),
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath,
- buildTarget: testRuleBuildTarget),
- ObjcDummyShellScriptBuildPhaseDefinition(),
- ]
+ name: testRuleTargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ SourcesBuildPhaseDefinition(files: testSources, mainGroup: project.mainGroup),
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath,
+ buildTarget: testRuleBuildTarget),
+ ObjcDummyShellScriptBuildPhaseDefinition(),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -1123,12 +1193,15 @@
let testHostTargetName = "App"
let testRulePackage = "test/app"
let testSources = ["test/app/Tests.m"]
- let objcLibraryRuleEntry = makeTestRuleEntry("\(testRulePackage):ObjcLib",
+ let objcLibraryRuleEntry = makeTestRuleEntry(
+ "\(testRulePackage):ObjcLib",
type: "objc_library",
sourceFiles: testSources)
- let testHostRuleEntry = makeTestRuleEntry("\(testRulePackage):\(testHostTargetName)",
+ let testHostRuleEntry = makeTestRuleEntry(
+ "\(testRulePackage):\(testHostTargetName)",
type: "ios_application", productType: .Application)
- let testRuleEntry = makeTestRuleEntry("\(testRulePackage):\(testRuleTargetName)",
+ let testRuleEntry = makeTestRuleEntry(
+ "\(testRulePackage):\(testRuleTargetName)",
type: "\(testRuleType)",
attributes: ["test_host": testHostRuleEntry.label.value as AnyObject],
sourceFiles: testSources,
@@ -1136,13 +1209,16 @@
platformType: "ios",
osDeploymentTarget: "8.0")
- let ruleEntryMap = makeRuleEntryMap(withRuleEntries: [objcLibraryRuleEntry,
- testHostRuleEntry,
- testRuleEntry])
+ let ruleEntryMap = makeRuleEntryMap(withRuleEntries: [
+ objcLibraryRuleEntry,
+ testHostRuleEntry,
+ testRuleEntry
+ ])
do {
- try targetGenerator.generateBuildTargetsForRuleEntries([testRuleEntry, testHostRuleEntry],
- ruleEntryMap: ruleEntryMap)
+ try targetGenerator.generateBuildTargetsForRuleEntries(
+ [testRuleEntry, testHostRuleEntry],
+ ruleEntryMap: ruleEntryMap)
} catch let e as NSError {
XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
}
@@ -1163,7 +1239,7 @@
"TEST_HOST": "$(BUILT_PRODUCTS_DIR)/\(testHostTargetName).app/\(testHostTargetName)",
"TULSI_BUILD_PATH": testRulePackage,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: testRuleTargetName,
buildConfigurations: [
@@ -1183,11 +1259,12 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
SourcesBuildPhaseDefinition(files: testSources, mainGroup: project.mainGroup),
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath,
- buildTarget: "\(testRulePackage):\(testRuleTargetName)"),
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath,
+ buildTarget: "\(testRulePackage):\(testRuleTargetName)"),
ObjcDummyShellScriptBuildPhaseDefinition(),
]
)
@@ -1200,27 +1277,35 @@
let testHostTargetName = "App"
let testRulePackage = "test/app"
let testSources = ["test/app/Tests.swift"]
- let swiftLibraryRuleEntry = makeTestRuleEntry("\(testRulePackage):SwiftLib",
- type: "swift_library",
- sourceFiles: testSources)
- let testHostRuleEntry = makeTestRuleEntry("\(testRulePackage):\(testHostTargetName)",
- type: "ios_application", productType: .Application)
- let testRuleEntry = makeTestRuleEntry("\(testRulePackage):\(testRuleTargetName)",
- type: "\(testRuleType)",
- attributes: ["has_swift_dependency": true as AnyObject,
- "test_host": testHostRuleEntry.label.value as AnyObject],
- sourceFiles: testSources,
- productType: .UnitTest,
- platformType: "ios",
- osDeploymentTarget: "8.0")
+ let swiftLibraryRuleEntry = makeTestRuleEntry(
+ "\(testRulePackage):SwiftLib",
+ type: "swift_library",
+ sourceFiles: testSources)
+ let testHostRuleEntry = makeTestRuleEntry(
+ "\(testRulePackage):\(testHostTargetName)",
+ type: "ios_application", productType: .Application)
+ let testRuleEntry = makeTestRuleEntry(
+ "\(testRulePackage):\(testRuleTargetName)",
+ type: "\(testRuleType)",
+ attributes: [
+ "has_swift_dependency": true as AnyObject,
+ "test_host": testHostRuleEntry.label.value as AnyObject
+ ],
+ sourceFiles: testSources,
+ productType: .UnitTest,
+ platformType: "ios",
+ osDeploymentTarget: "8.0")
- let ruleEntryMap = makeRuleEntryMap(withRuleEntries: [swiftLibraryRuleEntry,
- testHostRuleEntry,
- testRuleEntry])
+ let ruleEntryMap = makeRuleEntryMap(withRuleEntries: [
+ swiftLibraryRuleEntry,
+ testHostRuleEntry,
+ testRuleEntry
+ ])
do {
- try targetGenerator.generateBuildTargetsForRuleEntries([testRuleEntry, testHostRuleEntry],
- ruleEntryMap: ruleEntryMap)
+ try targetGenerator.generateBuildTargetsForRuleEntries(
+ [testRuleEntry, testHostRuleEntry],
+ ruleEntryMap: ruleEntryMap)
} catch let e as NSError {
XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
}
@@ -1241,7 +1326,7 @@
"TEST_HOST": "$(BUILT_PRODUCTS_DIR)/\(testHostTargetName).app/\(testHostTargetName)",
"TULSI_BUILD_PATH": testRulePackage,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: testRuleTargetName,
buildConfigurations: [
@@ -1261,12 +1346,13 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
SourcesBuildPhaseDefinition(files: testSources, mainGroup: project.mainGroup),
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath,
- buildTarget: "\(testRulePackage):\(testRuleTargetName)"),
- SwiftDummyShellScriptBuildPhaseDefinition()
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath,
+ buildTarget: "\(testRulePackage):\(testRuleTargetName)"),
+ SwiftDummyShellScriptBuildPhaseDefinition(),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -1292,17 +1378,18 @@
let testRuleBuildTarget = "\(testRuleBuildPath):\(testRuleTargetName)"
let testRuleAttributes = [testHostAttributeName: rule1BuildTarget]
let testSources = ["sourceFile1.m", "sourceFile2.mm"]
- let testRule = makeTestRuleEntry(testRuleBuildTarget,
- type: testRuleType,
- attributes: testRuleAttributes as [String: AnyObject],
- sourceFiles: testSources,
- productType: testProductType,
- platformType: "ios",
- osDeploymentTarget: "8.0")
+ let testRule = makeTestRuleEntry(
+ testRuleBuildTarget,
+ type: testRuleType,
+ attributes: testRuleAttributes as [String: AnyObject],
+ sourceFiles: testSources,
+ productType: testProductType,
+ platformType: "ios",
+ osDeploymentTarget: "8.0")
let rules = Set([
makeTestRuleEntry(rule1BuildTarget, type: "ios_application", productType: .Application),
testRule,
- ])
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
} catch let e as NSError {
@@ -1321,7 +1408,7 @@
"PRODUCT_NAME": rule1TargetName,
"SDKROOT": "iphoneos",
"TULSI_BUILD_PATH": rule1BuildPath,
- ]
+ ]
let expectedTarget = TargetDefinition(
name: rule1TargetName,
buildConfigurations: [
@@ -1341,11 +1428,12 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath,
- buildTarget: rule1BuildTarget),
- ]
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath,
+ buildTarget: rule1BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -1361,7 +1449,7 @@
"TEST_TARGET_NAME": rule1TargetName,
"TULSI_BUILD_PATH": testRuleBuildPath,
"TULSI_TEST_RUNNER_ONLY": "YES",
- ]
+ ]
let expectedTarget = TargetDefinition(
name: testRuleTargetName,
buildConfigurations: [
@@ -1381,11 +1469,12 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
SourcesBuildPhaseDefinition(files: testSources, mainGroup: project.mainGroup),
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath,
- buildTarget: testRuleBuildTarget),
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath,
+ buildTarget: testRuleBuildTarget),
ObjcDummyShellScriptBuildPhaseDefinition(),
]
)
@@ -1393,18 +1482,25 @@
}
}
- func testGenerateTargetsForLinkedRuleEntriesWithSameTestHostNameInDifferentPackagesWithSkylarkUnitTest() {
+ func
+ testGenerateTargetsForLinkedRuleEntriesWithSameTestHostNameInDifferentPackagesWithSkylarkUnitTest(
+ )
+ {
checkGenerateTargetsForLinkedRuleEntriesWithSameTestHostNameInDifferentPackages(
"ios_unit_test", testProductType: .UnitTest, testHostAttributeName: "test_host")
}
- func testGenerateTargetsForLinkedRuleEntriesWithSameTestHostNameInDifferentPackagesWithSkylarkUITest() {
+ func
+ testGenerateTargetsForLinkedRuleEntriesWithSameTestHostNameInDifferentPackagesWithSkylarkUITest(
+ )
+ {
checkGenerateTargetsForLinkedRuleEntriesWithSameTestHostNameInDifferentPackages(
"ios_ui_test", testProductType: .UIUnitTest, testHostAttributeName: "test_host")
}
func checkGenerateTargetsForLinkedRuleEntriesWithSameTestHostNameInDifferentPackages(
- _ testRuleType: String, testProductType: PBXTarget.ProductType, testHostAttributeName: String) {
+ _ testRuleType: String, testProductType: PBXTarget.ProductType, testHostAttributeName: String
+ ) {
let hostTargetName = "TestHost"
let host1Package = "test/package/1"
let host2Package = "test/package/2"
@@ -1417,16 +1513,18 @@
let test1Target = "\(host1Package):\(test1TargetName)"
let test2Target = "\(host2Package):\(test2TargetName)"
- let test1Rule = makeTestRuleEntry(test1Target,
- type: testRuleType,
- attributes: [testHostAttributeName: host1Target as AnyObject],
- sourceFiles: testSources,
- productType: testProductType)
- let test2Rule = makeTestRuleEntry(test2Target,
- type: testRuleType,
- attributes: [testHostAttributeName: host2Target as AnyObject],
- sourceFiles: testSources,
- productType: testProductType)
+ let test1Rule = makeTestRuleEntry(
+ test1Target,
+ type: testRuleType,
+ attributes: [testHostAttributeName: host1Target as AnyObject],
+ sourceFiles: testSources,
+ productType: testProductType)
+ let test2Rule = makeTestRuleEntry(
+ test2Target,
+ type: testRuleType,
+ attributes: [testHostAttributeName: host2Target as AnyObject],
+ sourceFiles: testSources,
+ productType: testProductType)
let rules = Set([
makeTestRuleEntry(host1Target, type: "ios_application", productType: .Application),
makeTestRuleEntry(host2Target, type: "ios_application", productType: .Application),
@@ -1443,16 +1541,17 @@
func testGenerateTargetsForLinkedRuleEntriesWithoutIncludingTheHostWarnsWithSkylarkUnitTest() {
checkGenerateTargetsForLinkedRuleEntriesWithoutIncludingTheHostWarns(
- "ios_unit_test", testHostAttributeName: "test_host")
+ "ios_unit_test", testHostAttributeName: "test_host")
}
func testGenerateTargetsForLinkedRuleEntriesWithoutIncludingTheHostWarnsWithSkylarkUITest() {
checkGenerateTargetsForLinkedRuleEntriesWithoutIncludingTheHostWarns(
- "ios_ui_test", testHostAttributeName: "test_host")
+ "ios_ui_test", testHostAttributeName: "test_host")
}
func checkGenerateTargetsForLinkedRuleEntriesWithoutIncludingTheHostWarns(
- _ testRuleType: String, testHostAttributeName: String) {
+ _ testRuleType: String, testHostAttributeName: String
+ ) {
let rule1BuildPath = "test/app"
let rule1TargetName = "TestApplication"
let rule1BuildTarget = "\(rule1BuildPath):\(rule1TargetName)"
@@ -1461,13 +1560,15 @@
let testRuleBuildTarget = "\(testRuleBuildPath):\(testRuleTargetName)"
let testRuleAttributes = [testHostAttributeName: rule1BuildTarget]
let testSources = ["sourceFile1.m", "sourceFile2.mm"]
- let testRule = makeTestRuleEntry(testRuleBuildTarget,
- type: testRuleType,
- attributes: testRuleAttributes as [String: AnyObject],
- sourceFiles: testSources,
- productType: .Application)
+ let testRule = makeTestRuleEntry(
+ testRuleBuildTarget,
+ type: testRuleType,
+ attributes: testRuleAttributes as [String: AnyObject],
+ sourceFiles: testSources,
+ productType: .Application)
do {
- try targetGenerator.generateBuildTargetsForRuleEntries([testRule], ruleEntryMap: RuleEntryMap())
+ try targetGenerator.generateBuildTargetsForRuleEntries(
+ [testRule], ruleEntryMap: RuleEntryMap())
} catch let e as NSError {
XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
return
@@ -1478,13 +1579,13 @@
XCTAssertEqual(targets.count, 1)
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/testbundle:TestBundle",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_NAME": testRuleTargetName,
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": testRuleBuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/testbundle:TestBundle",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_NAME": testRuleTargetName,
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": testRuleBuildPath,
]
var testRunnerExpectedBuildSettings = expectedBuildSettings
testRunnerExpectedBuildSettings["DEBUG_INFORMATION_FORMAT"] = "dwarf"
@@ -1492,29 +1593,30 @@
testRunnerExpectedBuildSettings["OTHER_CFLAGS"] = "--version"
testRunnerExpectedBuildSettings["OTHER_LDFLAGS"] = "--version"
let expectedTarget = TargetDefinition(
- name: testRuleTargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath,
- buildTarget: testRuleBuildTarget),
- ]
+ name: testRuleTargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath,
+ buildTarget: testRuleBuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -1545,73 +1647,73 @@
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/test1:\(targetName)",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_NAME": "test-test1-SameName",
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": rule1BuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/test1:\(targetName)",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_NAME": "test-test1-SameName",
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": rule1BuildPath,
]
let expectedTarget = TargetDefinition(
- name: "test-test1-SameName",
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget)
- ]
+ name: "test-test1-SameName",
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule1BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": "test/test2:\(targetName)",
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_NAME": "test-test2-SameName",
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": rule2BuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": "test/test2:\(targetName)",
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_NAME": "test-test2-SameName",
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": rule2BuildPath,
]
let expectedTarget = TargetDefinition(
- name: "test-test2-SameName",
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget)
- ]
+ name: "test-test2-SameName",
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: rule2BuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -1623,10 +1725,11 @@
let buildTarget = "\(buildPath):\(targetName)"
let bundleID = "bundleID"
let rules = Set([
- makeTestRuleEntry(buildTarget,
- type: "ios_application",
- bundleID: bundleID,
- productType: .Application),
+ makeTestRuleEntry(
+ buildTarget,
+ type: "ios_application",
+ bundleID: bundleID,
+ productType: .Application),
])
do {
@@ -1643,38 +1746,38 @@
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": buildTarget,
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_BUNDLE_IDENTIFIER": bundleID,
- "PRODUCT_NAME": targetName,
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": buildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": buildTarget,
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_BUNDLE_IDENTIFIER": bundleID,
+ "PRODUCT_NAME": targetName,
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": buildPath,
]
let expectedTarget = TargetDefinition(
- name: targetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: buildTarget)
- ]
+ name: targetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: buildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -1686,11 +1789,12 @@
let buildTarget = "\(buildPath):\(targetName)"
let bundleName = "bundleName"
let rules = Set([
- makeTestRuleEntry(buildTarget,
- type: "ios_application",
- bundleName: bundleName,
- productType: .Application),
- ])
+ makeTestRuleEntry(
+ buildTarget,
+ type: "ios_application",
+ bundleName: bundleName,
+ productType: .Application),
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
@@ -1733,9 +1837,9 @@
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
- ],
+ ],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: buildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: buildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -1758,27 +1862,30 @@
let watchAppBundleID = "watchAppBundleID"
let watchExtBundleID = "watchAppExtBundleID"
let rules = Set([
- makeTestRuleEntry(appBuildTarget,
- type: "ios_application",
- extensions: Set([BuildLabel(watchAppBuildTarget)]),
- bundleID: appBundleID,
- productType: .Application,
- platformType: "ios",
- osDeploymentTarget: "9.0"),
- makeTestRuleEntry(watchAppBuildTarget,
- type: "watchos_application",
- extensions: Set([BuildLabel(watchExtBuildTarget)]),
- bundleID: watchAppBundleID,
- productType: .Watch2App,
- extensionBundleID: watchExtBundleID,
- platformType: "watchos",
- osDeploymentTarget: "2.0"),
- makeTestRuleEntry(watchExtBuildTarget,
- type: "watchos_extension",
- bundleID: watchExtBundleID,
- productType: .Watch2Extension,
- platformType: "watchos",
- osDeploymentTarget: "2.0")
+ makeTestRuleEntry(
+ appBuildTarget,
+ type: "ios_application",
+ extensions: Set([BuildLabel(watchAppBuildTarget)]),
+ bundleID: appBundleID,
+ productType: .Application,
+ platformType: "ios",
+ osDeploymentTarget: "9.0"),
+ makeTestRuleEntry(
+ watchAppBuildTarget,
+ type: "watchos_application",
+ extensions: Set([BuildLabel(watchExtBuildTarget)]),
+ bundleID: watchAppBundleID,
+ productType: .Watch2App,
+ extensionBundleID: watchExtBundleID,
+ platformType: "watchos",
+ osDeploymentTarget: "2.0"),
+ makeTestRuleEntry(
+ watchExtBuildTarget,
+ type: "watchos_extension",
+ bundleID: watchExtBundleID,
+ productType: .Watch2Extension,
+ platformType: "watchos",
+ osDeploymentTarget: "2.0"),
])
do {
@@ -1795,115 +1902,117 @@
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": appBuildTarget,
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.defaultStub,
- "PRODUCT_BUNDLE_IDENTIFIER": appBundleID,
- "PRODUCT_NAME": appTargetName,
- "SDKROOT": "iphoneos",
- "IPHONEOS_DEPLOYMENT_TARGET": "9.0",
- "TULSI_BUILD_PATH": appBuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": appBuildTarget,
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.defaultStub,
+ "PRODUCT_BUNDLE_IDENTIFIER": appBundleID,
+ "PRODUCT_NAME": appTargetName,
+ "SDKROOT": "iphoneos",
+ "IPHONEOS_DEPLOYMENT_TARGET": "9.0",
+ "TULSI_BUILD_PATH": appBuildPath,
]
let expectedTarget = TargetDefinition(
- name: appTargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: appBuildTarget)
- ]
+ name: appTargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: appBuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": watchAppBuildTarget,
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.watchOSStub,
- "PRODUCT_BUNDLE_IDENTIFIER": watchAppBundleID,
- "PRODUCT_NAME": watchAppTargetName,
- "SDKROOT": "watchos",
- "WATCHOS_DEPLOYMENT_TARGET": "2.0",
- "TULSI_BUILD_PATH": watchAppBuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": watchAppBuildTarget,
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.watchOSStub,
+ "PRODUCT_BUNDLE_IDENTIFIER": watchAppBundleID,
+ "PRODUCT_NAME": watchAppTargetName,
+ "SDKROOT": "watchos",
+ "WATCHOS_DEPLOYMENT_TARGET": "2.0",
+ "TULSI_BUILD_PATH": watchAppBuildPath,
]
let expectedTarget = TargetDefinition(
- name: watchAppTargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: watchAppBuildTarget)
- ]
+ name: watchAppTargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath, buildTarget: watchAppBuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": watchExtBuildTarget,
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": stubPlistPaths.watchOSAppExStub,
- "PRODUCT_BUNDLE_IDENTIFIER": watchExtBundleID,
- "PRODUCT_NAME": watchExtTargetName,
- "SDKROOT": "watchos",
- "WATCHOS_DEPLOYMENT_TARGET": "2.0",
- "TULSI_BUILD_PATH": watchExtBuildPath,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": watchExtBuildTarget,
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": stubPlistPaths.watchOSAppExStub,
+ "PRODUCT_BUNDLE_IDENTIFIER": watchExtBundleID,
+ "PRODUCT_NAME": watchExtTargetName,
+ "SDKROOT": "watchos",
+ "WATCHOS_DEPLOYMENT_TARGET": "2.0",
+ "TULSI_BUILD_PATH": watchExtBuildPath,
]
let expectedTarget = TargetDefinition(
- name: watchExtTargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: watchExtBuildTarget)
- ]
+ name: watchExtTargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath, buildTarget: watchExtBuildTarget),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -1924,26 +2033,29 @@
let macCLIAppBundleID = "macCLIAppBundleID"
let macAppExtBundleID = "macAppExtBundleID"
let rules = Set([
- makeTestRuleEntry(appBuildTarget,
- type: "macos_application",
- extensions: Set([BuildLabel(macAppExtBuildTarget)]),
- bundleID: appBundleID,
- productType: .Application,
- platformType: "macos",
- osDeploymentTarget: "10.13"),
- makeTestRuleEntry(macAppExtBuildTarget,
- type: "macos_extension",
- bundleID: macAppExtBundleID,
- productType: .AppExtension,
- platformType: "macos",
- osDeploymentTarget: "10.13"),
- makeTestRuleEntry(macCLIAppBuildTarget,
- type: "macos_command_line_application",
- bundleID: macCLIAppBundleID,
- productType: .Tool,
- platformType: "macos",
- osDeploymentTarget: "10.13")
- ])
+ makeTestRuleEntry(
+ appBuildTarget,
+ type: "macos_application",
+ extensions: Set([BuildLabel(macAppExtBuildTarget)]),
+ bundleID: appBundleID,
+ productType: .Application,
+ platformType: "macos",
+ osDeploymentTarget: "10.13"),
+ makeTestRuleEntry(
+ macAppExtBuildTarget,
+ type: "macos_extension",
+ bundleID: macAppExtBundleID,
+ productType: .AppExtension,
+ platformType: "macos",
+ osDeploymentTarget: "10.13"),
+ makeTestRuleEntry(
+ macCLIAppBuildTarget,
+ type: "macos_command_line_application",
+ bundleID: macCLIAppBundleID,
+ productType: .Tool,
+ platformType: "macos",
+ osDeploymentTarget: "10.13"),
+ ])
do {
try targetGenerator.generateBuildTargetsForRuleEntries(rules, ruleEntryMap: RuleEntryMap())
@@ -1990,7 +2102,7 @@
),
],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: appBuildTarget)
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: appBuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -2028,7 +2140,8 @@
),
],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: macAppExtBuildTarget)
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath, buildTarget: macAppExtBuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -2066,7 +2179,8 @@
),
],
expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: macCLIAppBuildTarget)
+ BazelShellScriptBuildPhaseDefinition(
+ bazelPath: bazelPath, buildTarget: macCLIAppBuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
@@ -2076,10 +2190,11 @@
func testGenerateIndexerWithNoSources() {
let ruleEntry = makeTestRuleEntry("test/app:TestApp", type: "ios_application")
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssert(targets.isEmpty)
@@ -2087,16 +2202,18 @@
func testGenerateIndexerWithNoPCHFile() {
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_application",
- sourceFiles: sourceFileNames)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_application",
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
let indexerTargetName = String(format: "_idx_TestApp_%08X_ios_min9.0", buildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
@@ -2106,22 +2223,25 @@
func testGenerateIndexer() {
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry("test/app:TestApp",
- type: "ios_application",
- attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
- sourceFiles: sourceFileNames)
+ let ruleEntry = makeTestRuleEntry(
+ "test/app:TestApp",
+ type: "ios_application",
+ attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
let indexerTargetName = String(format: "_idx_TestApp_%08X_ios_min9.0", buildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- validateIndexerTarget(indexerTargetName, sourceFileNames: sourceFileNames, pchFile: pchFile, inTargets: targets)
+ validateIndexerTarget(
+ indexerTargetName, sourceFileNames: sourceFileNames, pchFile: pchFile, inTargets: targets)
}
func testGenerateIndexerWithBridgingHeader() {
@@ -2129,82 +2249,97 @@
let ruleAttributes = ["bridging_header": ["path": bridgingHeaderFilePath, "src": true]]
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_binary",
- attributes: ruleAttributes as [String : AnyObject],
- sourceFiles: sourceFileNames)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_binary",
+ attributes: ruleAttributes as [String: AnyObject],
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
let indexerTargetName = String(format: "_idx_TestApp_%08X_ios_min9.0", buildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- validateIndexerTarget(indexerTargetName,
- sourceFileNames: sourceFileNames,
- bridgingHeader: "$(TULSI_BWRS)/\(bridgingHeaderFilePath)",
- inTargets: targets)
+ validateIndexerTarget(
+ indexerTargetName,
+ sourceFileNames: sourceFileNames,
+ bridgingHeader: "$(TULSI_BWRS)/\(bridgingHeaderFilePath)",
+ inTargets: targets)
}
func testGenerateIndexerWithGeneratedBridgingHeader() {
let bridgingHeaderFilePath = "some/place/bridging-header.h"
- let bridgingHeaderInfo = ["path": bridgingHeaderFilePath,
- "root": "bazel-genfiles",
- "src": false] as [String : Any]
+ let bridgingHeaderInfo = [
+ "path": bridgingHeaderFilePath,
+ "root": "bazel-genfiles",
+ "src": false
+ ] as [String: Any]
let ruleAttributes = ["bridging_header": bridgingHeaderInfo]
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_binary",
- attributes: ruleAttributes as [String : AnyObject],
- sourceFiles: sourceFileNames)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_binary",
+ attributes: ruleAttributes as [String: AnyObject],
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
let indexerTargetName = String(format: "_idx_TestApp_%08X_ios_min9.0", buildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- validateIndexerTarget(indexerTargetName,
- sourceFileNames: sourceFileNames,
- bridgingHeader: "$(TULSI_WR)/bazel-genfiles/\(bridgingHeaderFilePath)",
- inTargets: targets)
+ validateIndexerTarget(
+ indexerTargetName,
+ sourceFileNames: sourceFileNames,
+ bridgingHeader: "$(TULSI_WR)/bazel-genfiles/\(bridgingHeaderFilePath)",
+ inTargets: targets)
}
func testGenerateIndexerWithXCDataModel() {
let dataModel = "test.xcdatamodeld"
- let ruleAttributes = ["datamodels": [["path": "\(dataModel)/v1.xcdatamodel", "src": true],
- ["path": "\(dataModel)/v2.xcdatamodel", "src": true]]]
+ let ruleAttributes = [
+ "datamodels": [
+ ["path": "\(dataModel)/v1.xcdatamodel", "src": true],
+ ["path": "\(dataModel)/v2.xcdatamodel", "src": true]
+ ]
+ ]
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_binary",
- attributes: ruleAttributes as [String : AnyObject],
- sourceFiles: sourceFileNames)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_binary",
+ attributes: ruleAttributes as [String: AnyObject],
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
let indexerTargetName = String(format: "_idx_TestApp_%08X_ios_min9.0", buildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters.union(Set([dataModel])),
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters.union(Set([dataModel])),
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
var allSourceFiles = sourceFileNames
allSourceFiles.append(dataModel)
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- validateIndexerTarget(indexerTargetName,
- sourceFileNames: allSourceFiles,
- inTargets: targets)
+ validateIndexerTarget(
+ indexerTargetName,
+ sourceFileNames: allSourceFiles,
+ inTargets: targets)
}
func testGenerateIndexerWithSourceFilter() {
@@ -2217,16 +2352,18 @@
allSourceFiles.append("this/file/should/not/appear.m")
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_application",
- sourceFiles: allSourceFiles)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_application",
+ sourceFiles: allSourceFiles)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
let indexerTargetName = String(format: "_idx_TestApp_%08X_ios_min9.0", buildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
@@ -2244,16 +2381,18 @@
allSourceFiles.append("filtered/file.m")
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_application",
- sourceFiles: allSourceFiles)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_application",
+ sourceFiles: allSourceFiles)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
let indexerTargetName = String(format: "_idx_TestApp_%08X_ios_min9.0", buildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
@@ -2265,15 +2404,17 @@
let buildFilePath = "this/file/should/not/BUILD"
pathFilters.insert("this/file/should")
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_application",
- sourceFiles: sourceFileNames,
- buildFilePath: buildFilePath)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_application",
+ sourceFiles: sourceFileNames,
+ buildFilePath: buildFilePath)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
XCTAssertNil(fileRefForPath(buildFilePath))
}
@@ -2282,15 +2423,17 @@
let buildFilePath = "this/file/should/BUILD"
pathFilters.insert("this/file/should")
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_application",
- sourceFiles: sourceFileNames,
- buildFilePath: buildFilePath)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_application",
+ sourceFiles: sourceFileNames,
+ buildFilePath: buildFilePath)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
XCTAssertNotNil(fileRefForPath(buildFilePath))
}
@@ -2299,15 +2442,17 @@
let buildFilePath = "this/file/should/BUILD"
pathFilters.insert("this/file/...")
let buildLabel = BuildLabel("test/app:TestApp")
- let ruleEntry = makeTestRuleEntry(buildLabel,
- type: "ios_application",
- sourceFiles: sourceFileNames,
- buildFilePath: buildFilePath)
+ let ruleEntry = makeTestRuleEntry(
+ buildLabel,
+ type: "ios_application",
+ sourceFiles: sourceFileNames,
+ buildFilePath: buildFilePath)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- targetGenerator.registerRuleEntryForIndexer(ruleEntry,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
XCTAssertNotNil(fileRefForPath(buildFilePath))
}
@@ -2316,52 +2461,60 @@
let sourceFiles1 = ["1.swift", "1.cc"]
let buildLabel1 = BuildLabel("test/app:TestBinary")
- let ruleEntry1 = makeTestRuleEntry(buildLabel1,
- type: "ios_binary",
- attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
- sourceFiles: sourceFiles1)
+ let ruleEntry1 = makeTestRuleEntry(
+ buildLabel1,
+ type: "ios_binary",
+ attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
+ sourceFiles: sourceFiles1)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- targetGenerator.registerRuleEntryForIndexer(ruleEntry1,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry1,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
let sourceFiles2 = ["2.swift"]
let buildLabel2 = BuildLabel("test/app:TestLibrary")
- let ruleEntry2 = makeTestRuleEntry(buildLabel2,
- type: "objc_library",
- attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
- sourceFiles: sourceFiles2)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry2,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ let ruleEntry2 = makeTestRuleEntry(
+ buildLabel2,
+ type: "objc_library",
+ attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
+ sourceFiles: sourceFiles2)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry2,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- let indexerTargetName = String(format: "_idx_TestLibrary_TestBinary_%08X_ios_min9.0",
- buildLabel1.hashValue &+ buildLabel2.hashValue)
- validateIndexerTarget(indexerTargetName,
- sourceFileNames: sourceFiles1 + sourceFiles2,
- pchFile: pchFile,
- inTargets: targets)
+ let indexerTargetName = String(
+ format: "_idx_TestLibrary_TestBinary_%08X_ios_min9.0",
+ buildLabel1.hashValue &+ buildLabel2.hashValue)
+ validateIndexerTarget(
+ indexerTargetName,
+ sourceFileNames: sourceFiles1 + sourceFiles2,
+ pchFile: pchFile,
+ inTargets: targets)
}
func testIndexerCharacterLimit() {
let sourceFiles1 = ["1.swift", "1.cc"]
let buildTargetName1 = String(repeating: "A", count: 300)
let buildLabel1 = BuildLabel("test/app:" + buildTargetName1)
- let ruleEntry1 = makeTestRuleEntry(buildLabel1,
- type: "ios_binary",
- attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
- sourceFiles: sourceFiles1)
+ let ruleEntry1 = makeTestRuleEntry(
+ buildLabel1,
+ type: "ios_binary",
+ attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
+ sourceFiles: sourceFiles1)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- targetGenerator.registerRuleEntryForIndexer(ruleEntry1,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry1,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
@@ -2370,37 +2523,42 @@
let resultingTarget = targets.values.first!
XCTAssertLessThan(resultingTarget.name.count, 255)
- validateIndexerTarget(resultingTarget.name,
- sourceFileNames: sourceFiles1,
- pchFile: pchFile,
- inTargets: targets)
+ validateIndexerTarget(
+ resultingTarget.name,
+ sourceFileNames: sourceFiles1,
+ pchFile: pchFile,
+ inTargets: targets)
}
func testCompatibleIndexersMergeCharacterLimit() {
let sourceFiles1 = ["1.swift", "1.cc"]
let buildTargetName1 = String(repeating: "A", count: 200)
let buildLabel1 = BuildLabel("test/app:" + buildTargetName1)
- let ruleEntry1 = makeTestRuleEntry(buildLabel1,
- type: "ios_binary",
- attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
- sourceFiles: sourceFiles1)
+ let ruleEntry1 = makeTestRuleEntry(
+ buildLabel1,
+ type: "ios_binary",
+ attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
+ sourceFiles: sourceFiles1)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- targetGenerator.registerRuleEntryForIndexer(ruleEntry1,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry1,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
let sourceFiles2 = ["2.swift"]
let buildTargetName2 = String(repeating: "B", count: 255)
let buildLabel2 = BuildLabel("test/app:" + buildTargetName2)
- let ruleEntry2 = makeTestRuleEntry(buildLabel2,
- type: "objc_library",
- attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
- sourceFiles: sourceFiles2)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry2,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ let ruleEntry2 = makeTestRuleEntry(
+ buildLabel2,
+ type: "objc_library",
+ attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
+ sourceFiles: sourceFiles2)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry2,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
@@ -2409,88 +2567,107 @@
let resultingTarget = targets.values.first!
XCTAssertLessThan(resultingTarget.name.count, 255)
- validateIndexerTarget(resultingTarget.name,
- sourceFileNames: sourceFiles1 + sourceFiles2,
- pchFile: pchFile,
- inTargets: targets)
+ validateIndexerTarget(
+ resultingTarget.name,
+ sourceFileNames: sourceFiles1 + sourceFiles2,
+ pchFile: pchFile,
+ inTargets: targets)
}
func testDoesNotMergeIndexerWithPCHMismatch() {
let buildLabel1 = BuildLabel("test/app:TestBinary")
- let ruleEntry1 = makeTestRuleEntry(buildLabel1,
- type: "ios_binary",
- attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
- sourceFiles: sourceFileNames)
+ let ruleEntry1 = makeTestRuleEntry(
+ buildLabel1,
+ type: "ios_binary",
+ attributes: ["pch": ["path": pchFile.path!, "src": true] as AnyObject],
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- let indexer1TargetName = String(format: "_idx_TestBinary_%08X_ios_min9.0", buildLabel1.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry1,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ let indexer1TargetName = String(
+ format: "_idx_TestBinary_%08X_ios_min9.0", buildLabel1.hashValue)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry1,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
let buildLabel2 = BuildLabel("test/app:TestLibrary")
- let ruleEntry2 = makeTestRuleEntry(buildLabel2,
- type: "objc_library",
- attributes: [:],
- sourceFiles: sourceFileNames)
- let indexer2TargetName = String(format: "_idx_TestLibrary_%08X_ios_min9.0", buildLabel2.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry2,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ let ruleEntry2 = makeTestRuleEntry(
+ buildLabel2,
+ type: "objc_library",
+ attributes: [:],
+ sourceFiles: sourceFileNames)
+ let indexer2TargetName = String(
+ format: "_idx_TestLibrary_%08X_ios_min9.0", buildLabel2.hashValue)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry2,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 2)
- validateIndexerTarget(indexer1TargetName,
- sourceFileNames: sourceFileNames,
- pchFile: pchFile,
- inTargets: targets)
- validateIndexerTarget(indexer2TargetName,
- sourceFileNames: sourceFileNames,
- inTargets: targets)
+ validateIndexerTarget(
+ indexer1TargetName,
+ sourceFileNames: sourceFileNames,
+ pchFile: pchFile,
+ inTargets: targets)
+ validateIndexerTarget(
+ indexer2TargetName,
+ sourceFileNames: sourceFileNames,
+ inTargets: targets)
}
func testDoesNotMergeIndexerWithGeneratedBridgingHeaderMismatch() {
let bridgingHeaderFilePath = "some/place/bridging-header.h"
- let bridgingHeaderInfo = ["path": bridgingHeaderFilePath,
- "root": "bazel-genfiles",
- "src": false] as [String : Any]
+ let bridgingHeaderInfo = [
+ "path": bridgingHeaderFilePath,
+ "root": "bazel-genfiles",
+ "src": false
+ ] as [String: Any]
let ruleAttributes1 = ["bridging_header": bridgingHeaderInfo]
let buildLabel1 = BuildLabel("test/app:TestBinary")
- let ruleEntry1 = makeTestRuleEntry(buildLabel1,
- type: "ios_binary",
- attributes: ruleAttributes1 as [String : AnyObject],
- sourceFiles: sourceFileNames)
+ let ruleEntry1 = makeTestRuleEntry(
+ buildLabel1,
+ type: "ios_binary",
+ attributes: ruleAttributes1 as [String: AnyObject],
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- let indexer1TargetName = String(format: "_idx_TestBinary_%08X_ios_min9.0", buildLabel1.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry1,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ let indexer1TargetName = String(
+ format: "_idx_TestBinary_%08X_ios_min9.0", buildLabel1.hashValue)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry1,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
let buildLabel2 = BuildLabel("test/app:TestLibrary")
- let ruleEntry2 = makeTestRuleEntry(buildLabel2,
- type: "objc_library",
- attributes: [:],
- sourceFiles: sourceFileNames)
- let indexer2TargetName = String(format: "_idx_TestLibrary_%08X_ios_min9.0", buildLabel2.hashValue)
- targetGenerator.registerRuleEntryForIndexer(ruleEntry2,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ let ruleEntry2 = makeTestRuleEntry(
+ buildLabel2,
+ type: "objc_library",
+ attributes: [:],
+ sourceFiles: sourceFileNames)
+ let indexer2TargetName = String(
+ format: "_idx_TestLibrary_%08X_ios_min9.0", buildLabel2.hashValue)
+ targetGenerator.registerRuleEntryForIndexer(
+ ruleEntry2,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 2)
- validateIndexerTarget(indexer1TargetName,
- sourceFileNames: sourceFileNames,
- bridgingHeader: "$(TULSI_WR)/bazel-genfiles/\(bridgingHeaderFilePath)",
- inTargets: targets)
- validateIndexerTarget(indexer2TargetName,
- sourceFileNames: sourceFileNames,
- inTargets: targets)
+ validateIndexerTarget(
+ indexer1TargetName,
+ sourceFileNames: sourceFileNames,
+ bridgingHeader: "$(TULSI_WR)/bazel-genfiles/\(bridgingHeaderFilePath)",
+ inTargets: targets)
+ validateIndexerTarget(
+ indexer2TargetName,
+ sourceFileNames: sourceFileNames,
+ inTargets: targets)
}
func testSwiftTargetsGeneratedSYMBundles() {
@@ -2502,17 +2679,19 @@
let swiftTargetName = "SwiftTarget"
let swiftTarget = "\(package):\(swiftTargetName)"
- let testRule = makeTestRuleEntry(target,
- type: targetType,
- attributes: ["has_swift_dependency": true as AnyObject],
- dependencies: Set([BuildLabel(swiftTarget)]),
- productType: .Application)
+ let testRule = makeTestRuleEntry(
+ target,
+ type: targetType,
+ attributes: ["has_swift_dependency": true as AnyObject],
+ dependencies: Set([BuildLabel(swiftTarget)]),
+ productType: .Application)
let swiftLibraryRule = makeTestRuleEntry(swiftTarget, type: "swift_library")
let ruleEntryMap = makeRuleEntryMap(withRuleEntries: [swiftLibraryRule])
do {
- try targetGenerator.generateBuildTargetsForRuleEntries([testRule],
- ruleEntryMap: ruleEntryMap)
+ try targetGenerator.generateBuildTargetsForRuleEntries(
+ [testRule],
+ ruleEntryMap: ruleEntryMap)
} catch let e as NSError {
XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
}
@@ -2522,37 +2701,37 @@
XCTAssertEqual(targets.count, 1)
let expectedBuildSettings = [
- "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
- "BAZEL_TARGET": target,
- "DEBUG_INFORMATION_FORMAT": "dwarf",
- "INFOPLIST_FILE": "TestInfo.plist",
- "PRODUCT_NAME": targetName,
- "SDKROOT": "iphoneos",
- "TULSI_BUILD_PATH": package,
+ "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
+ "BAZEL_TARGET": target,
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
+ "INFOPLIST_FILE": "TestInfo.plist",
+ "PRODUCT_NAME": targetName,
+ "SDKROOT": "iphoneos",
+ "TULSI_BUILD_PATH": package,
]
let expectedTarget = TargetDefinition(
- name: "TestTarget",
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Debug",
- expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "__TulsiTestRunner_Release",
- expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: [
- BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: target)
- ]
+ name: "TestTarget",
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Debug",
+ expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "__TulsiTestRunner_Release",
+ expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: [
+ BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: target),
+ ]
)
assertTarget(expectedTarget, inTargets: targets)
}
@@ -2562,30 +2741,36 @@
let swiftTargetName = "SwiftTarget"
let swiftTargetBuildLabel = BuildLabel("\(package):\(swiftTargetName)")
- let swiftTargetOpts = ["-I/include/foobar", "-DCOMPILER_DEFINE"] as AnyObject
+ let swiftTargetOpts = ["-I/include/foobar", "-DCOMPILER_DEFINE"] as AnyObject
- let swiftLibraryRule = makeTestRuleEntry(swiftTargetBuildLabel,
- type: "swift_library",
- attributes: ["swiftc_opts": swiftTargetOpts,
- "has_swift_info": true as AnyObject],
- sourceFiles: sourceFileNames)
+ let swiftLibraryRule = makeTestRuleEntry(
+ swiftTargetBuildLabel,
+ type: "swift_library",
+ attributes: [
+ "swiftc_opts": swiftTargetOpts,
+ "has_swift_info": true as AnyObject
+ ],
+ sourceFiles: sourceFileNames)
var proccessedEntries = [RuleEntry: (NSOrderedSet)]()
- let indexerTargetName = String(format: "_idx_\(swiftTargetName)_%08X_ios_min9.0", swiftTargetBuildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(swiftLibraryRule,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &proccessedEntries)
+ let indexerTargetName = String(
+ format: "_idx_\(swiftTargetName)_%08X_ios_min9.0", swiftTargetBuildLabel.hashValue)
+ targetGenerator.registerRuleEntryForIndexer(
+ swiftLibraryRule,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &proccessedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- validateIndexerTarget(indexerTargetName,
- sourceFileNames: sourceFileNames,
- swiftIncludePaths: "$(inherited) /include/foobar",
- otherSwiftFlags: "$(inherited) -DCOMPILER_DEFINE",
- isSwift: true,
- inTargets: targets)
+ validateIndexerTarget(
+ indexerTargetName,
+ sourceFileNames: sourceFileNames,
+ swiftIncludePaths: "$(inherited) /include/foobar",
+ otherSwiftFlags: "$(inherited) -DCOMPILER_DEFINE",
+ isSwift: true,
+ inTargets: targets)
}
func testIndexerCFlags() {
@@ -2595,27 +2780,33 @@
let swiftTargetBuildLabel = BuildLabel("\(package):\(swiftTargetName)")
let swiftTargetCOpts = ["-iquote", "foo/bar", "-iquote", "."] as AnyObject
- let swiftLibraryRule = makeTestRuleEntry(swiftTargetBuildLabel,
- type: "swift_library",
- attributes: ["copts": swiftTargetCOpts,
- "has_swift_info": true as AnyObject],
- sourceFiles: sourceFileNames)
+ let swiftLibraryRule = makeTestRuleEntry(
+ swiftTargetBuildLabel,
+ type: "swift_library",
+ attributes: [
+ "copts": swiftTargetCOpts,
+ "has_swift_info": true as AnyObject
+ ],
+ sourceFiles: sourceFileNames)
var processedEntries = [RuleEntry: (NSOrderedSet)]()
- let indexerTargetName = String(format: "_idx_\(swiftTargetName)_%08X_ios_min9.0", swiftTargetBuildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(swiftLibraryRule,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &processedEntries)
+ let indexerTargetName = String(
+ format: "_idx_\(swiftTargetName)_%08X_ios_min9.0", swiftTargetBuildLabel.hashValue)
+ targetGenerator.registerRuleEntryForIndexer(
+ swiftLibraryRule,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &processedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- validateIndexerTarget(indexerTargetName,
- sourceFileNames: sourceFileNames,
- otherCFlags: "-iquote foo/bar -iquote .",
- isSwift: true,
- inTargets: targets)
+ validateIndexerTarget(
+ indexerTargetName,
+ sourceFileNames: sourceFileNames,
+ otherCFlags: "-iquote foo/bar -iquote .",
+ isSwift: true,
+ inTargets: targets)
}
func testIndexerCFlagsDefinesEscaping() {
@@ -2624,32 +2815,37 @@
let objcTargetName = "ObjcTarget"
let objcTargetBuildLabel = BuildLabel("\(package):\(objcTargetName)")
let objcTargetDefines = [
- "A=value with space",
- "'B=preescaped value'",
- "\"C=preescaped value\"",
- "D=nospaces"
+ "A=value with space",
+ "'B=preescaped value'",
+ "\"C=preescaped value\"",
+ "D=nospaces",
] as AnyObject
- let objcLibraryRule = makeTestRuleEntry(objcTargetBuildLabel,
- type: "objc_library",
- attributes: ["compiler_defines": objcTargetDefines],
- sourceFiles: sourceFileNames)
+ let objcLibraryRule = makeTestRuleEntry(
+ objcTargetBuildLabel,
+ type: "objc_library",
+ attributes: ["compiler_defines": objcTargetDefines],
+ sourceFiles: sourceFileNames)
var processedEntries = [RuleEntry: (NSOrderedSet)]()
- let indexerTargetName = String(format: "_idx_\(objcTargetName)_%08X_ios_min9.0", objcTargetBuildLabel.hashValue)
- targetGenerator.registerRuleEntryForIndexer(objcLibraryRule,
- ruleEntryMap: RuleEntryMap(),
- pathFilters: pathFilters,
- processedEntries: &processedEntries)
+ let indexerTargetName = String(
+ format: "_idx_\(objcTargetName)_%08X_ios_min9.0", objcTargetBuildLabel.hashValue)
+ targetGenerator.registerRuleEntryForIndexer(
+ objcLibraryRule,
+ ruleEntryMap: RuleEntryMap(),
+ pathFilters: pathFilters,
+ processedEntries: &processedEntries)
targetGenerator.generateIndexerTargets()
let targets = project.targetByName
XCTAssertEqual(targets.count, 1)
- validateIndexerTarget(indexerTargetName,
- sourceFileNames: sourceFileNames,
- otherCFlags: "-D\"C=preescaped value\" -D'B=preescaped value' -D\"A=value with space\" -DD=nospaces",
- isSwift: false,
- inTargets: targets)
+ validateIndexerTarget(
+ indexerTargetName,
+ sourceFileNames: sourceFileNames,
+ otherCFlags:
+ "-D\"C=preescaped value\" -D'B=preescaped value' -D\"A=value with space\" -DD=nospaces",
+ isSwift: false,
+ inTargets: targets)
}
// MARK: - Helper methods
@@ -2666,12 +2862,16 @@
return newSettings
}
- private func debugTestRunnerBuildSettingsFromSettings(_ settings: [String: String]) -> [String: String] {
+ private func debugTestRunnerBuildSettingsFromSettings(_ settings: [String: String]) -> [String:
+ String]
+ {
let testRunnerSettings = addTestRunnerSettings(settings)
return debugBuildSettingsFromSettings(testRunnerSettings)
}
- private func releaseTestRunnerBuildSettingsFromSettings(_ settings: [String: String]) -> [String: String] {
+ private func releaseTestRunnerBuildSettingsFromSettings(_ settings: [String: String]) -> [String:
+ String]
+ {
let testRunnerSettings = addTestRunnerSettings(settings)
return releaseBuildSettingsFromSettings(testRunnerSettings)
}
@@ -2696,80 +2896,87 @@
private func rebuildSourceFileReferences() {
sourceFileReferences = []
for file in sourceFileNames {
- sourceFileReferences.append(project.mainGroup.getOrCreateFileReferenceBySourceTree(.Group, path: file))
+ sourceFileReferences.append(
+ project.mainGroup.getOrCreateFileReferenceBySourceTree(.Group, path: file))
}
}
- private func makeTestRuleEntry(_ label: String,
- type: String,
- attributes: [String: AnyObject] = [:],
- artifacts: [String] = [],
- sourceFiles: [String] = [],
- dependencies: Set<BuildLabel> = Set(),
- extensions: Set<BuildLabel>? = nil,
- bundleID: String? = nil,
- bundleName: String? = nil,
- productType: PBXTarget.ProductType? = nil,
- extensionBundleID: String? = nil,
- platformType: String? = nil,
- osDeploymentTarget: String? = nil,
- buildFilePath: String? = nil,
- swiftLanguageVersion: String? = nil) -> RuleEntry {
- return makeTestRuleEntry(BuildLabel(label),
- type: type,
- attributes: attributes,
- artifacts: artifacts,
- sourceFiles: sourceFiles,
- dependencies: dependencies,
- extensions: extensions,
- bundleID: bundleID,
- bundleName: bundleName,
- productType: productType,
- extensionBundleID: extensionBundleID,
- platformType: platformType,
- osDeploymentTarget: osDeploymentTarget,
- buildFilePath: buildFilePath,
- swiftLanguageVersion: swiftLanguageVersion)
+ private func makeTestRuleEntry(
+ _ label: String,
+ type: String,
+ attributes: [String: AnyObject] = [:],
+ artifacts: [String] = [],
+ sourceFiles: [String] = [],
+ dependencies: Set<BuildLabel> = Set(),
+ extensions: Set<BuildLabel>? = nil,
+ bundleID: String? = nil,
+ bundleName: String? = nil,
+ productType: PBXTarget.ProductType? = nil,
+ extensionBundleID: String? = nil,
+ platformType: String? = nil,
+ osDeploymentTarget: String? = nil,
+ buildFilePath: String? = nil,
+ swiftLanguageVersion: String? = nil
+ ) -> RuleEntry {
+ return makeTestRuleEntry(
+ BuildLabel(label),
+ type: type,
+ attributes: attributes,
+ artifacts: artifacts,
+ sourceFiles: sourceFiles,
+ dependencies: dependencies,
+ extensions: extensions,
+ bundleID: bundleID,
+ bundleName: bundleName,
+ productType: productType,
+ extensionBundleID: extensionBundleID,
+ platformType: platformType,
+ osDeploymentTarget: osDeploymentTarget,
+ buildFilePath: buildFilePath,
+ swiftLanguageVersion: swiftLanguageVersion)
}
- private class TestBazelFileInfo : BazelFileInfo {
+ private class TestBazelFileInfo: BazelFileInfo {
init(fullPath: String) {
super.init(rootPath: "", subPath: fullPath, isDirectory: false, targetType: .sourceFile)
}
}
- private func makeTestRuleEntry(_ label: BuildLabel,
- type: String,
- attributes: [String: AnyObject] = [:],
- artifacts: [String] = [],
- sourceFiles: [String] = [],
- dependencies: Set<BuildLabel> = Set(),
- extensions: Set<BuildLabel>? = nil,
- bundleID: String? = nil,
- bundleName: String? = nil,
- productType: PBXTarget.ProductType? = nil,
- extensionBundleID: String? = nil,
- platformType: String? = nil,
- osDeploymentTarget: String? = nil,
- buildFilePath: String? = nil,
- swiftLanguageVersion: String? = nil) -> RuleEntry {
- let artifactInfos = artifacts.map() { TestBazelFileInfo(fullPath: $0) }
- let sourceInfos = sourceFiles.map() { TestBazelFileInfo(fullPath: $0) }
- return RuleEntry(label: label,
- type: type,
- attributes: attributes,
- artifacts: artifactInfos,
- sourceFiles: sourceInfos,
- dependencies: dependencies,
- extensions: extensions,
- bundleID: bundleID,
- bundleName: bundleName,
- productType: productType,
- extensionBundleID: extensionBundleID,
- platformType: platformType,
- osDeploymentTarget: osDeploymentTarget,
- buildFilePath: buildFilePath,
- swiftLanguageVersion: swiftLanguageVersion)
+ private func makeTestRuleEntry(
+ _ label: BuildLabel,
+ type: String,
+ attributes: [String: AnyObject] = [:],
+ artifacts: [String] = [],
+ sourceFiles: [String] = [],
+ dependencies: Set<BuildLabel> = Set(),
+ extensions: Set<BuildLabel>? = nil,
+ bundleID: String? = nil,
+ bundleName: String? = nil,
+ productType: PBXTarget.ProductType? = nil,
+ extensionBundleID: String? = nil,
+ platformType: String? = nil,
+ osDeploymentTarget: String? = nil,
+ buildFilePath: String? = nil,
+ swiftLanguageVersion: String? = nil
+ ) -> RuleEntry {
+ let artifactInfos = artifacts.map { TestBazelFileInfo(fullPath: $0) }
+ let sourceInfos = sourceFiles.map { TestBazelFileInfo(fullPath: $0) }
+ return RuleEntry(
+ label: label,
+ type: type,
+ attributes: attributes,
+ artifacts: artifactInfos,
+ sourceFiles: sourceInfos,
+ dependencies: dependencies,
+ extensions: extensions,
+ bundleID: bundleID,
+ bundleName: bundleName,
+ productType: productType,
+ extensionBundleID: extensionBundleID,
+ platformType: platformType,
+ osDeploymentTarget: osDeploymentTarget,
+ buildFilePath: buildFilePath,
+ swiftLanguageVersion: swiftLanguageVersion)
}
private struct TargetDefinition {
@@ -2780,7 +2987,7 @@
private struct BuildConfigurationDefinition {
let name: String
- let expectedBuildSettings: Dictionary<String, String>?
+ let expectedBuildSettings: [String: String]?
}
private class BuildPhaseDefinition {
@@ -2790,7 +2997,7 @@
let mainGroup: PBXReference?
let mnemonic: String
- init (isa: String, files: [String], mainGroup: PBXReference? = nil, mnemonic: String = "") {
+ init(isa: String, files: [String], mainGroup: PBXReference? = nil, mnemonic: String = "") {
self.isa = isa
self.files = files
self.fileSet = Set(files)
@@ -2800,18 +3007,20 @@
func validate(_ phase: PBXBuildPhase, line: UInt = #line) {
// Validate the file set.
- XCTAssertEqual(phase.files.count,
- fileSet.count,
- "Mismatch in file count in build phase:\n\(phase.files)\n\(fileSet)",
- line: line)
+ XCTAssertEqual(
+ phase.files.count,
+ fileSet.count,
+ "Mismatch in file count in build phase:\n\(phase.files)\n\(fileSet)",
+ line: line)
for buildFile in phase.files {
guard let fileRef = buildFile.fileRef as? PBXFileReference else {
continue
}
let path = fileRef.sourceRootRelativePath
- XCTAssert(fileSet.contains(path),
- "Found unexpected file '\(path)' in build phase",
- line: line)
+ XCTAssert(
+ fileSet.contains(path),
+ "Found unexpected file '\(path)' in build phase",
+ line: line)
}
XCTAssertEqual(phase.mnemonic, mnemonic, "Mismatch in mnemonics")
}
@@ -2822,10 +3031,11 @@
init(files: [String], mainGroup: PBXReference, settings: [String: String]? = nil) {
self.settings = settings
- super.init(isa: "PBXSourcesBuildPhase",
- files: files,
- mainGroup: mainGroup,
- mnemonic: "CompileSources")
+ super.init(
+ isa: "PBXSourcesBuildPhase",
+ files: files,
+ mainGroup: mainGroup,
+ mnemonic: "CompileSources")
}
override func validate(_ phase: PBXBuildPhase, line: UInt = #line) {
@@ -2833,14 +3043,17 @@
for buildFile in phase.files {
if settings != nil {
- XCTAssertNotNil(buildFile.settings, "Settings for file \(buildFile) must == \(String(describing: settings))",
- line: line)
+ XCTAssertNotNil(
+ buildFile.settings,
+ "Settings for file \(buildFile) must == \(String(describing: settings))",
+ line: line)
if buildFile.settings != nil {
XCTAssertEqual(buildFile.settings!, settings!, line: line)
}
} else {
- XCTAssertNil(buildFile.settings, "Settings for file \(buildFile) must be nil",
- line: line)
+ XCTAssertNil(
+ buildFile.settings, "Settings for file \(buildFile) must be nil",
+ line: line)
}
}
}
@@ -2865,12 +3078,14 @@
let script = scriptBuildPhase.shellScript
- XCTAssert(script.contains(bazelPath),
- "Build script does not contain \(bazelPath)",
- line: line)
- XCTAssert(script.contains(buildTarget),
- "Build script does not contain build target \(buildTarget)",
- line: line)
+ XCTAssert(
+ script.contains(bazelPath),
+ "Build script does not contain \(bazelPath)",
+ line: line)
+ XCTAssert(
+ script.contains(buildTarget),
+ "Build script does not contain build target \(buildTarget)",
+ line: line)
}
}
@@ -2887,8 +3102,9 @@
let scriptBuildPhase = phase as! PBXShellScriptBuildPhase
let script = scriptBuildPhase.shellScript
- XCTAssert(script.contains("touch"), "Build script does not contain 'touch'.",
- line: line)
+ XCTAssert(
+ script.contains("touch"), "Build script does not contain 'touch'.",
+ line: line)
}
}
@@ -2905,8 +3121,9 @@
let scriptBuildPhase = phase as! PBXShellScriptBuildPhase
let script = scriptBuildPhase.shellScript
- XCTAssert(script.contains("touch"), "Build script does not contain 'touch'.",
- line: line)
+ XCTAssert(
+ script.contains("touch"), "Build script does not contain 'touch'.",
+ line: line)
}
}
@@ -2930,21 +3147,23 @@
return nil
}
- private func validateIndexerTarget(_ indexerTargetName: String,
- sourceFileNames: [String]?,
- pchFile: PBXFileReference? = nil,
- bridgingHeader: String? = nil,
- swiftLanguageVersion: String? = nil,
- swiftIncludePaths: String? = nil,
- otherCFlags: String? = nil,
- otherSwiftFlags: String? = nil,
- isSwift: Bool = false,
- inTargets targets: Dictionary<String, PBXTarget> = Dictionary<String, PBXTarget>(),
- line: UInt = #line) {
+ private func validateIndexerTarget(
+ _ indexerTargetName: String,
+ sourceFileNames: [String]?,
+ pchFile: PBXFileReference? = nil,
+ bridgingHeader: String? = nil,
+ swiftLanguageVersion: String? = nil,
+ swiftIncludePaths: String? = nil,
+ otherCFlags: String? = nil,
+ otherSwiftFlags: String? = nil,
+ isSwift: Bool = false,
+ inTargets targets: [String: PBXTarget] = [String: PBXTarget](),
+ line: UInt = #line
+ ) {
var expectedBuildSettings = [
- "PRODUCT_NAME": indexerTargetName,
- "SDKROOT": "iphoneos",
- "IPHONEOS_DEPLOYMENT_TARGET": "9.0",
+ "PRODUCT_NAME": indexerTargetName,
+ "SDKROOT": "iphoneos",
+ "IPHONEOS_DEPLOYMENT_TARGET": "9.0",
]
if !isSwift {
expectedBuildSettings["USER_HEADER_SEARCH_PATHS"] = "$(TULSI_WR)"
@@ -2970,71 +3189,82 @@
var expectedBuildPhases = [BuildPhaseDefinition]()
if sourceFileNames != nil {
- expectedBuildPhases.append(SourcesBuildPhaseDefinition(files: sourceFileNames!,
- mainGroup: project.mainGroup))
+ expectedBuildPhases.append(
+ SourcesBuildPhaseDefinition(
+ files: sourceFileNames!,
+ mainGroup: project.mainGroup))
}
let expectedTarget = TargetDefinition(
- name: indexerTargetName,
- buildConfigurations: [
- BuildConfigurationDefinition(
- name: "Debug",
- expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
- ),
- BuildConfigurationDefinition(
- name: "Release",
- expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
- ),
- ],
- expectedBuildPhases: expectedBuildPhases
+ name: indexerTargetName,
+ buildConfigurations: [
+ BuildConfigurationDefinition(
+ name: "Debug",
+ expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ BuildConfigurationDefinition(
+ name: "Release",
+ expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
+ ),
+ ],
+ expectedBuildPhases: expectedBuildPhases
)
assertTarget(expectedTarget, inTargets: targets, line: line)
}
- private func assertTarget(_ targetDef: TargetDefinition,
- inTargets targets: Dictionary<String, PBXTarget>,
- line: UInt = #line) {
+ private func assertTarget(
+ _ targetDef: TargetDefinition,
+ inTargets targets: [String: PBXTarget],
+ line: UInt = #line
+ ) {
guard let target = targets[targetDef.name] else {
XCTFail("Missing expected target '\(targetDef.name)'", line: line)
return
}
let buildConfigs = target.buildConfigurationList.buildConfigurations
- XCTAssertEqual(buildConfigs.count,
- targetDef.buildConfigurations.count,
- "Build config mismatch in target '\(targetDef.name)'",
- line: line)
+ XCTAssertEqual(
+ buildConfigs.count,
+ targetDef.buildConfigurations.count,
+ "Build config mismatch in target '\(targetDef.name)'",
+ line: line)
for buildConfigDef in targetDef.buildConfigurations {
guard let config = buildConfigs[buildConfigDef.name] else {
- XCTFail("Missing expected build configuration '\(buildConfigDef.name)' in target '\(targetDef.name)'",
- line: line)
+ XCTFail(
+ "Missing expected build configuration '\(buildConfigDef.name)' in target '\(targetDef.name)'",
+ line: line)
continue
}
if buildConfigDef.expectedBuildSettings != nil {
- XCTAssertEqual(config.buildSettings,
- buildConfigDef.expectedBuildSettings!,
- "Build config mismatch for configuration '\(buildConfigDef.name)' in target '\(targetDef.name)'",
- line: line)
+ XCTAssertEqual(
+ config.buildSettings,
+ buildConfigDef.expectedBuildSettings!,
+ "Build config mismatch for configuration '\(buildConfigDef.name)' in target '\(targetDef.name)'",
+ line: line)
} else {
XCTAssert(config.buildSettings.isEmpty, line: line)
}
}
- validateExpectedBuildPhases(targetDef.expectedBuildPhases,
- inTarget: target,
- line: line)
+ validateExpectedBuildPhases(
+ targetDef.expectedBuildPhases,
+ inTarget: target,
+ line: line)
}
- private func validateExpectedBuildPhases(_ phaseDefs: [BuildPhaseDefinition],
- inTarget target: PBXTarget,
- line: UInt = #line) {
+ private func validateExpectedBuildPhases(
+ _ phaseDefs: [BuildPhaseDefinition],
+ inTarget target: PBXTarget,
+ line: UInt = #line
+ ) {
let buildPhases = target.buildPhases
- XCTAssertEqual(buildPhases.count,
- phaseDefs.count,
- "Build phase count mismatch in target '\(target.name)'",
- line: line)
+ XCTAssertEqual(
+ buildPhases.count,
+ phaseDefs.count,
+ "Build phase count mismatch in target '\(target.name)'",
+ line: line)
var validationCount = 0
for phaseDef in phaseDefs {
@@ -3046,8 +3276,9 @@
validationCount += 1
}
}
- XCTAssertEqual(validationCount,
- buildPhases.count,
- "Validation count mismatch in target '\(target.name)'")
+ XCTAssertEqual(
+ validationCount,
+ buildPhases.count,
+ "Validation count mismatch in target '\(target.name)'")
}
}
diff --git a/src/TulsiGeneratorTests/PythonableTests.swift b/src/TulsiGeneratorTests/PythonableTests.swift
index 02680d7..d719c93 100644
--- a/src/TulsiGeneratorTests/PythonableTests.swift
+++ b/src/TulsiGeneratorTests/PythonableTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
class PythonableTests: XCTestCase {
@@ -37,7 +38,7 @@
let arr = [
"Hello",
"Goodbye",
- "'Escape'"
+ "'Escape'",
]
XCTAssertEqual(arr.toPython(""), """
[
@@ -46,7 +47,8 @@
'\\'Escape\\'',
]
""")
- XCTAssertEqual(arr.toPython(" "), """
+ XCTAssertEqual(
+ arr.toPython(" "), """
[
'Hello',
'Goodbye',
@@ -91,4 +93,3 @@
""")
}
}
-
diff --git a/src/TulsiGeneratorTests/ShellEscapingTests.swift b/src/TulsiGeneratorTests/ShellEscapingTests.swift
index a07bb38..47f0a25 100644
--- a/src/TulsiGeneratorTests/ShellEscapingTests.swift
+++ b/src/TulsiGeneratorTests/ShellEscapingTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
class ShellEscapingTests: XCTestCase {
diff --git a/src/TulsiGeneratorTests/TulsiGeneratorConfigTests.swift b/src/TulsiGeneratorTests/TulsiGeneratorConfigTests.swift
index 5ee0557..8b42811 100644
--- a/src/TulsiGeneratorTests/TulsiGeneratorConfigTests.swift
+++ b/src/TulsiGeneratorTests/TulsiGeneratorConfigTests.swift
@@ -13,14 +13,15 @@
// limitations under the License.
import XCTest
-@testable import TulsiGenerator
+@testable import TulsiGenerator
class TulsiGeneratorConfigTests: XCTestCase {
let projectName = "TestProject"
let projectBundleURL = URL(fileURLWithPath: "/test/project/tulsiproject/")
let projectBazelURL = URL(fileURLWithPath: "/test/project/path/to/bazel")
let workspaceRootURL = URL(fileURLWithPath: "/test/project/root/")
+
let bazelPackages = [
"a/package",
"b/where/are/we",
@@ -28,35 +29,42 @@
]
let buildTargetLabels = ["build/target/label:1", "build/target/label:2"]
- let pathFilters = Set<String>(["build/target/path/1",
- "build/target/path/2",
- "source/target/path"])
- let additionalFilePaths = ["path/to/file", "path/to/another/file"]
+ let pathFilters = Set<String>([
+ "build/target/path/1",
+ "build/target/path/2",
+ "source/target/path"
+ ])
+
+ let additionalFilePaths = ["path/to/file", "path/to/another/file"]
var project: TulsiProject! = nil
override func setUp() {
super.setUp()
- project = TulsiProject(projectName: projectName,
- projectBundleURL: projectBundleURL,
- workspaceRootURL: workspaceRootURL,
- bazelPackages: bazelPackages)
+ project = TulsiProject(
+ projectName: projectName,
+ projectBundleURL: projectBundleURL,
+ workspaceRootURL: workspaceRootURL,
+ bazelPackages: bazelPackages)
project.bazelURL = projectBazelURL
}
func testSave() {
do {
- let bazelURL = TulsiParameter(value: URL(fileURLWithPath: ""),
- source: .explicitlyProvided)
- let config = TulsiGeneratorConfig(projectName: projectName,
- buildTargetLabels: buildTargetLabels.map({ BuildLabel($0) }),
- pathFilters: pathFilters,
- additionalFilePaths: additionalFilePaths,
- options: TulsiOptionSet(),
- bazelURL: bazelURL)
+ let bazelURL = TulsiParameter(
+ value: URL(fileURLWithPath: ""),
+ source: .explicitlyProvided)
+ let config = TulsiGeneratorConfig(
+ projectName: projectName,
+ buildTargetLabels: buildTargetLabels.map({ BuildLabel($0) }),
+ pathFilters: pathFilters,
+ additionalFilePaths: additionalFilePaths,
+ options: TulsiOptionSet(),
+ bazelURL: bazelURL)
let data = try config.save()
- let dict = try JSONSerialization.jsonObject(with: data as Data, options: JSONSerialization.ReadingOptions()) as! [String: Any]
+ let dict = try JSONSerialization.jsonObject(
+ with: data as Data, options: JSONSerialization.ReadingOptions()) as! [String: Any]
XCTAssertEqual(dict["additionalFilePaths"] as! [String], additionalFilePaths)
XCTAssertEqual(dict["buildTargets"] as! [String], buildTargetLabels)
XCTAssertEqual(dict["projectName"] as! String, projectName)
@@ -69,12 +77,13 @@
func testLoad() {
do {
let dict = [
- "additionalFilePaths": additionalFilePaths,
- "buildTargets": buildTargetLabels,
- "projectName": projectName,
- "sourceFilters": [String](pathFilters),
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ "additionalFilePaths": additionalFilePaths,
+ "buildTargets": buildTargetLabels,
+ "projectName": projectName,
+ "sourceFilters": [String](pathFilters),
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let bazelURL = URL(fileURLWithPath: "/path/to/bazel")
let config = try TulsiGeneratorConfig(data: data, bazelURL: bazelURL)
@@ -89,14 +98,15 @@
func testLoadWithBuildLabelSourceFilters() {
do {
- let sourceFilters = pathFilters.map() { "//\($0)" }
+ let sourceFilters = pathFilters.map { "//\($0)" }
let dict = [
- "additionalFilePaths": additionalFilePaths,
- "buildTargets": buildTargetLabels,
- "projectName": projectName,
- "sourceFilters": sourceFilters,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ "additionalFilePaths": additionalFilePaths,
+ "buildTargets": buildTargetLabels,
+ "projectName": projectName,
+ "sourceFilters": sourceFilters,
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let bazelURL = URL(fileURLWithPath: "/path/to/bazel")
let config = try TulsiGeneratorConfig(data: data, bazelURL: bazelURL)
@@ -115,8 +125,9 @@
"additionalFilePaths": ["//path/to/file"],
"buildTargets": buildTargetLabels,
"projectName": projectName,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
_ = try TulsiGeneratorConfig(data: data)
XCTFail("Unexpectedly succeeded with an invalid file path")
@@ -131,8 +142,9 @@
do {
let dict = [
"projectName": projectName,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let bazelURL = URL(fileURLWithPath: "/path/to/bazel")
let config = try TulsiGeneratorConfig(data: data, bazelURL: bazelURL)
@@ -146,18 +158,21 @@
do {
let dict = [
"projectName": projectName,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let bazelURL = URL(fileURLWithPath: "/path/to/bazel")
let optionsURL = URL(fileURLWithPath: "/options/path/to/bazel")
let options = [
- "optionSet": [ "BazelPath": [ "p": optionsURL.path ]],
- ] as [String: Any]
- let optionData = try JSONSerialization.data(withJSONObject: options, options: JSONSerialization.WritingOptions())
+ "optionSet": ["BazelPath": ["p": optionsURL.path]],
+ ] as [String: Any]
+ let optionData = try JSONSerialization.data(
+ withJSONObject: options, options: JSONSerialization.WritingOptions())
- var config = try TulsiGeneratorConfig(data: data,
- additionalOptionData: optionData,
- bazelURL: bazelURL)
+ var config = try TulsiGeneratorConfig(
+ data: data,
+ additionalOptionData: optionData,
+ bazelURL: bazelURL)
config = config.configByResolvingInheritedSettingsFromProject(project)
XCTAssertEqual(config.bazelURL, bazelURL)
@@ -170,17 +185,20 @@
do {
let dict = [
"projectName": projectName,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let optionsURL = URL(fileURLWithPath: "/options/path/to/bazel")
let options = [
- "optionSet": [ "BazelPath": [ "p": optionsURL.path ]],
+ "optionSet": ["BazelPath": ["p": optionsURL.path]],
] as [String: Any]
- let optionData = try JSONSerialization.data(withJSONObject: options, options: JSONSerialization.WritingOptions())
+ let optionData = try JSONSerialization.data(
+ withJSONObject: options, options: JSONSerialization.WritingOptions())
- let config = try TulsiGeneratorConfig(data: data,
- additionalOptionData: optionData)
+ let config = try TulsiGeneratorConfig(
+ data: data,
+ additionalOptionData: optionData)
XCTAssertEqual(config.bazelURL, optionsURL)
} catch {
XCTFail("Unexpected assertion")
@@ -191,17 +209,20 @@
do {
let dict = [
"projectName": projectName,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let optionsURL = URL(fileURLWithPath: "/options/path/to/bazel")
let options = [
- "optionSet": [ "BazelPath": [ "p": optionsURL.path ]],
+ "optionSet": ["BazelPath": ["p": optionsURL.path]],
] as [String: Any]
- let optionData = try JSONSerialization.data(withJSONObject: options, options: JSONSerialization.WritingOptions())
+ let optionData = try JSONSerialization.data(
+ withJSONObject: options, options: JSONSerialization.WritingOptions())
- var config = try TulsiGeneratorConfig(data: data,
- additionalOptionData: optionData)
+ var config = try TulsiGeneratorConfig(
+ data: data,
+ additionalOptionData: optionData)
config = config.configByResolvingInheritedSettingsFromProject(project)
XCTAssertEqual(config.bazelURL, optionsURL)
} catch {
diff --git a/src/TulsiGeneratorTests/TulsiOptionSetTests.swift b/src/TulsiGeneratorTests/TulsiOptionSetTests.swift
index bd3ef81..ba2166c 100644
--- a/src/TulsiGeneratorTests/TulsiOptionSetTests.swift
+++ b/src/TulsiGeneratorTests/TulsiOptionSetTests.swift
@@ -13,6 +13,7 @@
// limitations under the License.
import XCTest
+
@testable import TulsiGenerator
class TulsiOptionSetTests: XCTestCase {
@@ -32,12 +33,12 @@
let optionSet = TulsiOptionSet()
optionSet[.ALWAYS_SEARCH_USER_PATHS].projectValue = "YES"
optionSet[.BazelBuildOptionsDebug].targetValues = [
- target1: "Target-Value1",
- target2: "Target-Value2",
+ target1: "Target-Value1",
+ target2: "Target-Value2",
]
optionSet[.BazelBuildOptionsRelease].projectValue = "releaseProjectValue"
optionSet[.BazelBuildOptionsRelease].targetValues = [
- target1: "Target-Release-Value1",
+ target1: "Target-Release-Value1",
]
var dict = [String: AnyObject]()
optionSet.saveAllOptionsIntoDictionary(&dict)
@@ -99,7 +100,8 @@
optionSet.savePerUserOptionsIntoDictionary(&dict)
let perUserOptions = optionSet.options.filter({ $1.optionType.contains(.PerUserOnly) })
- let serializedValues = dict[TulsiOptionSet.PersistenceKey] as! [String: TulsiOption.PersistenceType]
+ let serializedValues = dict[TulsiOptionSet.PersistenceKey] as! [String: TulsiOption
+ .PersistenceType]
XCTAssertEqual(serializedValues.count, perUserOptions.count)
let optionsDict = TulsiOptionSet.getOptionsFromContainerDictionary(dict) ?? [:]
@@ -120,7 +122,6 @@
parent[.SuppressSwiftUpdateCheck].projectValue = "NO"
parent[.IncludeBuildSources].projectValue = "NO"
-
let childValue = "ChildValue"
let child = TulsiOptionSet(withInheritanceEnabled: true)
child[.BazelBuildOptionsDebug].projectValue = childValue
diff --git a/src/TulsiGeneratorTests/TulsiProjectTests.swift b/src/TulsiGeneratorTests/TulsiProjectTests.swift
index 3acacb7..bae257d 100644
--- a/src/TulsiGeneratorTests/TulsiProjectTests.swift
+++ b/src/TulsiGeneratorTests/TulsiProjectTests.swift
@@ -13,36 +13,39 @@
// limitations under the License.
import XCTest
-@testable import TulsiGenerator
+@testable import TulsiGenerator
class TulsiProjectTests: XCTestCase {
let projectName = "TestProject"
let projectBundleURL = URL(fileURLWithPath: "/test/project/tulsiproject/")
let workspaceRootURL = URL(fileURLWithPath: "/test/project/root/")
+
// Relative path from projectBundleURL to workspaceRootURL.
let relativeRootPath = "../root"
+
let bazelPackages = [
- "some/package",
- "another/package",
- "package",
+ "some/package",
+ "another/package",
+ "package",
]
var project: TulsiProject! = nil
override func setUp() {
super.setUp()
- project = TulsiProject(projectName: projectName,
- projectBundleURL: projectBundleURL,
- workspaceRootURL: workspaceRootURL,
- bazelPackages: bazelPackages)
+ project = TulsiProject(
+ projectName: projectName,
+ projectBundleURL: projectBundleURL,
+ workspaceRootURL: workspaceRootURL,
+ bazelPackages: bazelPackages)
}
-
func testSave() {
do {
let data = try project.save()
- let dict = try JSONSerialization.jsonObject(with: data as Data, options: JSONSerialization.ReadingOptions()) as! [String: Any]
+ let dict = try JSONSerialization.jsonObject(
+ with: data as Data, options: JSONSerialization.ReadingOptions()) as! [String: Any]
XCTAssertEqual(dict["packages"] as! [String], bazelPackages)
XCTAssertEqual(dict["projectName"] as! String, projectName)
XCTAssertEqual(dict["workspaceRoot"] as! String, relativeRootPath)
@@ -57,8 +60,9 @@
"packages": bazelPackages,
"projectName": projectName,
"workspaceRoot": relativeRootPath,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
project = try TulsiProject(data: data, projectBundleURL: projectBundleURL)
XCTAssertEqual(project.bazelPackages, bazelPackages)
@@ -75,8 +79,9 @@
"packages": bazelPackages,
"projectName": projectName,
"workspaceRoot": relativeRootPath + "/",
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
project = try TulsiProject(data: data, projectBundleURL: projectBundleURL)
XCTAssertEqual(project.bazelPackages, bazelPackages)
@@ -92,8 +97,9 @@
let dict = [
"packages": bazelPackages,
"projectName": projectName,
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let _ = try TulsiProject(data: data, projectBundleURL: projectBundleURL)
XCTFail("Unexpectedly succeeded without a workspace root")
} catch TulsiProject.ProjectError.deserializationFailed {
@@ -109,8 +115,9 @@
"packages": bazelPackages,
"projectName": projectName,
"workspaceRoot": "/invalid/absolute/path",
- ] as [String : Any]
- let data = try JSONSerialization.data(withJSONObject: dict, options: JSONSerialization.WritingOptions())
+ ] as [String: Any]
+ let data = try JSONSerialization.data(
+ withJSONObject: dict, options: JSONSerialization.WritingOptions())
let _ = try TulsiProject(data: data, projectBundleURL: projectBundleURL)
XCTFail("Unexpectedly succeeded with an invalid workspace root")
} catch TulsiProject.ProjectError.deserializationFailed {
diff --git a/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift b/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift
index 24a512c..be51cf9 100644
--- a/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift
+++ b/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift
@@ -13,39 +13,48 @@
// limitations under the License.
import XCTest
-@testable import TulsiGenerator
+@testable import TulsiGenerator
class XcodeProjectGeneratorTests: XCTestCase {
static let outputFolderPath = "/dev/null/project"
static let projectName = "ProjectName"
let outputFolderURL = URL(fileURLWithPath: XcodeProjectGeneratorTests.outputFolderPath)
- let xcodeProjectPath = "\(XcodeProjectGeneratorTests.outputFolderPath)/\(XcodeProjectGeneratorTests.projectName).xcodeproj"
+ let xcodeProjectPath
+ = "\(XcodeProjectGeneratorTests.outputFolderPath)/\(XcodeProjectGeneratorTests.projectName).xcodeproj"
let workspaceRoot = URL(fileURLWithPath: "/workspace")
let testTulsiVersion = "9.99.999.9999"
- let buildTargetLabels = ["//test:MainTarget", "//test/path/to/target:target"].map({ BuildLabel($0) })
+ let buildTargetLabels = ["//test:MainTarget", "//test/path/to/target:target"].map({
+ BuildLabel($0)
+ })
let pathFilters = Set<String>(["test", "additional"])
let additionalFilePaths = ["additional/File1", "additional/File2"]
- let bazelURL = TulsiParameter(value: URL(fileURLWithPath: "/test/dir/testBazel"),
- source: .explicitlyProvided)
+ let bazelURL = TulsiParameter(
+ value: URL(fileURLWithPath: "/test/dir/testBazel"),
+ source: .explicitlyProvided)
let resourceURLs = XcodeProjectGenerator.ResourceSourcePathURLs(
- buildScript: URL(fileURLWithPath: "/scripts/Build"),
- cleanScript: URL(fileURLWithPath: "/scripts/Clean"),
- extraBuildScripts: [URL(fileURLWithPath: "/scripts/Logging")],
- iOSUIRunnerEntitlements: URL(fileURLWithPath: "/generatedProjectResources/iOSXCTRunner.entitlements"),
- macOSUIRunnerEntitlements: URL(fileURLWithPath: "/generatedProjectResources/macOSXCTRunner.entitlements"),
- stubInfoPlist: URL(fileURLWithPath: "/generatedProjectResources/StubInfoPlist.plist"),
- stubIOSAppExInfoPlistTemplate: URL(fileURLWithPath: "/generatedProjectResources/stubIOSAppExInfoPlist.plist"),
- stubWatchOS2InfoPlist: URL(fileURLWithPath: "/generatedProjectResources/StubWatchOS2InfoPlist.plist"),
- stubWatchOS2AppExInfoPlist: URL(fileURLWithPath: "/generatedProjectResources/StubWatchOS2AppExInfoPlist.plist"),
- bazelWorkspaceFile: URL(fileURLWithPath: "/WORKSPACE"),
- tulsiPackageFiles: [URL(fileURLWithPath: "/tulsi/tulsi_aspects.bzl")])
+ buildScript: URL(fileURLWithPath: "/scripts/Build"),
+ cleanScript: URL(fileURLWithPath: "/scripts/Clean"),
+ extraBuildScripts: [URL(fileURLWithPath: "/scripts/Logging")],
+ iOSUIRunnerEntitlements: URL(
+ fileURLWithPath: "/generatedProjectResources/iOSXCTRunner.entitlements"),
+ macOSUIRunnerEntitlements: URL(
+ fileURLWithPath: "/generatedProjectResources/macOSXCTRunner.entitlements"),
+ stubInfoPlist: URL(fileURLWithPath: "/generatedProjectResources/StubInfoPlist.plist"),
+ stubIOSAppExInfoPlistTemplate: URL(
+ fileURLWithPath: "/generatedProjectResources/stubIOSAppExInfoPlist.plist"),
+ stubWatchOS2InfoPlist: URL(
+ fileURLWithPath: "/generatedProjectResources/StubWatchOS2InfoPlist.plist"),
+ stubWatchOS2AppExInfoPlist: URL(
+ fileURLWithPath: "/generatedProjectResources/StubWatchOS2AppExInfoPlist.plist"),
+ bazelWorkspaceFile: URL(fileURLWithPath: "/WORKSPACE"),
+ tulsiPackageFiles: [URL(fileURLWithPath: "/tulsi/tulsi_aspects.bzl")])
var config: TulsiGeneratorConfig! = nil
var mockLocalizedMessageLogger: MockLocalizedMessageLogger! = nil
@@ -72,17 +81,27 @@
mockLocalizedMessageLogger.assertNoWarnings()
XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/project.pbxproj"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/project.xcworkspace/xcuserdata/USER.xcuserdatad/WorkspaceSettings.xcsettings"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-path-to-target-target.xcscheme"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-MainTarget.xcscheme"))
+ XCTAssert(
+ writtenFiles.contains(
+ "\(xcodeProjectPath)/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings"))
+ XCTAssert(
+ writtenFiles.contains(
+ "\(xcodeProjectPath)/project.xcworkspace/xcuserdata/USER.xcuserdatad/WorkspaceSettings.xcsettings"
+ ))
+ XCTAssert(
+ writtenFiles.contains(
+ "\(xcodeProjectPath)/xcshareddata/xcschemes/test-path-to-target-target.xcscheme"))
+ XCTAssert(
+ writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-MainTarget.xcscheme")
+ )
let supportScriptsURL = mockFileManager.homeDirectoryForCurrentUser.appendingPathComponent(
- "Library/Application Support/Tulsi/Scripts", isDirectory: true)
+ "Library/Application Support/Tulsi/Scripts", isDirectory: true)
XCTAssert(mockFileManager.directoryOperations.contains(supportScriptsURL.path))
- let cacheReaderURL = supportScriptsURL.appendingPathComponent("bazel_cache_reader",
- isDirectory: false)
+ let cacheReaderURL = supportScriptsURL.appendingPathComponent(
+ "bazel_cache_reader",
+ isDirectory: false)
XCTAssert(mockFileManager.copyOperations.keys.contains(cacheReaderURL.path))
let xcp = "\(xcodeProjectPath)/xcuserdata/USER.xcuserdatad/xcschemes/xcschememanagement.plist"
@@ -98,31 +117,42 @@
func testExtensionPlistGeneration() {
@discardableResult
- func addRule(_ labelName: String,
- type: String,
- attributes: [String: AnyObject] = [:],
- weakDependencies: Set<BuildLabel>? = nil,
- extensions: Set<BuildLabel>? = nil,
- extensionType: String? = nil,
- productType: PBXTarget.ProductType? = nil) -> BuildLabel {
+ func addRule(
+ _ labelName: String,
+ type: String,
+ attributes: [String: AnyObject] = [:],
+ weakDependencies: Set<BuildLabel>? = nil,
+ extensions: Set<BuildLabel>? = nil,
+ extensionType: String? = nil,
+ productType: PBXTarget.ProductType? = nil
+ ) -> BuildLabel {
let label = BuildLabel(labelName)
- mockExtractor.labelToRuleEntry[label] = Swift.type(of: self).makeRuleEntry(label,
- type: type,
- attributes: attributes,
- weakDependencies: weakDependencies,
- extensions: extensions,
- productType: productType,
- extensionType: extensionType)
+ mockExtractor.labelToRuleEntry[label] = Swift.type(of: self).makeRuleEntry(
+ label,
+ type: type,
+ attributes: attributes,
+ weakDependencies: weakDependencies,
+ extensions: extensions,
+ productType: productType,
+ extensionType: extensionType)
return label
}
- let test1 = addRule("//test:ExtFoo", type: "ios_extension", extensionType: "com.apple.extension-foo", productType: .AppExtension)
- let test2 = addRule("//test:ExtBar", type: "ios_extension", extensionType: "com.apple.extension-bar", productType: .AppExtension)
- addRule("//test:Application", type: "ios_application", extensions: [test1, test2], productType: .Application)
+ let test1 = addRule(
+ "//test:ExtFoo", type: "ios_extension", extensionType: "com.apple.extension-foo",
+ productType: .AppExtension)
+ let test2 = addRule(
+ "//test:ExtBar", type: "ios_extension", extensionType: "com.apple.extension-bar",
+ productType: .AppExtension)
+ addRule(
+ "//test:Application", type: "ios_application", extensions: [test1, test2],
+ productType: .Application)
prepareGenerator(mockExtractor.labelToRuleEntry)
func assertPlist(withData data: Data, equalTo value: NSDictionary) {
- let content = try! PropertyListSerialization.propertyList(from: data, options: PropertyListSerialization.ReadOptions.mutableContainers, format: nil) as! NSDictionary
+ let content = try! PropertyListSerialization.propertyList(
+ from: data, options: PropertyListSerialization.ReadOptions.mutableContainers, format: nil)
+ as! NSDictionary
XCTAssertEqual(content, value)
}
@@ -131,13 +161,21 @@
mockLocalizedMessageLogger.assertNoErrors()
mockLocalizedMessageLogger.assertNoWarnings()
- XCTAssert(mockFileManager.writeOperations.keys.contains("\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtFoo.plist"))
- assertPlist(withData: mockFileManager.writeOperations["\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtFoo.plist"]!,
- equalTo: ["NSExtension": ["NSExtensionPointIdentifier": "com.apple.extension-foo"]])
+ XCTAssert(
+ mockFileManager.writeOperations.keys.contains(
+ "\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtFoo.plist"))
+ assertPlist(
+ withData: mockFileManager.writeOperations[
+ "\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtFoo.plist"]!,
+ equalTo: ["NSExtension": ["NSExtensionPointIdentifier": "com.apple.extension-foo"]])
- XCTAssert(mockFileManager.writeOperations.keys.contains("\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtBar.plist"))
- assertPlist(withData: mockFileManager.writeOperations["\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtBar.plist"]!,
- equalTo: ["NSExtension": ["NSExtensionPointIdentifier": "com.apple.extension-bar"]])
+ XCTAssert(
+ mockFileManager.writeOperations.keys.contains(
+ "\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtBar.plist"))
+ assertPlist(
+ withData: mockFileManager.writeOperations[
+ "\(xcodeProjectPath)/.tulsi/Resources/Stub_test-ExtBar.plist"]!,
+ equalTo: ["NSExtension": ["NSExtensionPointIdentifier": "com.apple.extension-bar"]])
} catch let e {
XCTFail("Unexpected exception \(e)")
}
@@ -168,8 +206,10 @@
do {
_ = try generator.generateXcodeProjectInFolder(invalidOutputFolderURL)
XCTFail("Generation succeeded unexpectedly")
- } catch XcodeProjectGenerator.ProjectGeneratorError.invalidXcodeProjectPath(let pathFound,
- let reason) {
+ } catch XcodeProjectGenerator.ProjectGeneratorError.invalidXcodeProjectPath(
+ let pathFound,
+ let reason)
+ {
// Expected failure on path with a /bazel-* directory.
XCTAssertEqual(pathFound, invalidOutputFolderString)
XCTAssertEqual(reason, "a Bazel generated temp directory (\"/bazel-\")")
@@ -179,44 +219,53 @@
}
func testTestSuiteSchemeGenerationWithSkylarkUnitTest() {
- checkTestSuiteSchemeGeneration("ios_unit_test",
- testProductType: .UnitTest,
- testHostAttributeName: "test_host")
+ checkTestSuiteSchemeGeneration(
+ "ios_unit_test",
+ testProductType: .UnitTest,
+ testHostAttributeName: "test_host")
}
func testTestSuiteSchemeGenerationWithSkylarkUITest() {
- checkTestSuiteSchemeGeneration("ios_ui_test",
- testProductType: .UIUnitTest,
- testHostAttributeName: "test_host")
+ checkTestSuiteSchemeGeneration(
+ "ios_ui_test",
+ testProductType: .UIUnitTest,
+ testHostAttributeName: "test_host")
}
- func checkTestSuiteSchemeGeneration(_ testRuleType: String,
- testProductType: PBXTarget.ProductType,
- testHostAttributeName: String) {
+ func checkTestSuiteSchemeGeneration(
+ _ testRuleType: String,
+ testProductType: PBXTarget.ProductType,
+ testHostAttributeName: String
+ ) {
@discardableResult
- func addRule(_ labelName: String,
- type: String,
- attributes: [String: AnyObject] = [:],
- weakDependencies: Set<BuildLabel>? = nil,
- productType: PBXTarget.ProductType? = nil) -> BuildLabel {
+ func addRule(
+ _ labelName: String,
+ type: String,
+ attributes: [String: AnyObject] = [:],
+ weakDependencies: Set<BuildLabel>? = nil,
+ productType: PBXTarget.ProductType? = nil
+ ) -> BuildLabel {
let label = BuildLabel(labelName)
- mockExtractor.labelToRuleEntry[label] = Swift.type(of: self).makeRuleEntry(label,
- type: type,
- attributes: attributes,
- weakDependencies: weakDependencies,
- productType: productType)
+ mockExtractor.labelToRuleEntry[label] = Swift.type(of: self).makeRuleEntry(
+ label,
+ type: type,
+ attributes: attributes,
+ weakDependencies: weakDependencies,
+ productType: productType)
return label
}
let app = addRule("//test:Application", type: "ios_application", productType: .Application)
- let test1 = addRule("//test:TestOne",
- type: testRuleType,
- attributes: [testHostAttributeName: app.value as AnyObject],
- productType: testProductType)
- let test2 = addRule("//test:TestTwo",
- type: testRuleType,
- attributes: [testHostAttributeName: app.value as AnyObject],
- productType: testProductType)
+ let test1 = addRule(
+ "//test:TestOne",
+ type: testRuleType,
+ attributes: [testHostAttributeName: app.value as AnyObject],
+ productType: testProductType)
+ let test2 = addRule(
+ "//test:TestTwo",
+ type: testRuleType,
+ attributes: [testHostAttributeName: app.value as AnyObject],
+ productType: testProductType)
addRule("//test:UnusedTest", type: testRuleType, productType: testProductType)
addRule("//test:TestSuite", type: "test_suite", weakDependencies: Set([test1, test2]))
prepareGenerator(mockExtractor.labelToRuleEntry)
@@ -227,13 +276,26 @@
mockLocalizedMessageLogger.assertNoWarnings()
XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/project.pbxproj"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/project.xcworkspace/xcuserdata/USER.xcuserdatad/WorkspaceSettings.xcsettings"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-Application.xcscheme"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-TestOne.xcscheme"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-TestTwo.xcscheme"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-UnusedTest.xcscheme"))
- XCTAssert(writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/TestSuite_Suite.xcscheme"))
+ XCTAssert(
+ writtenFiles.contains(
+ "\(xcodeProjectPath)/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings"))
+ XCTAssert(
+ writtenFiles.contains(
+ "\(xcodeProjectPath)/project.xcworkspace/xcuserdata/USER.xcuserdatad/WorkspaceSettings.xcsettings"
+ ))
+ XCTAssert(
+ writtenFiles.contains(
+ "\(xcodeProjectPath)/xcshareddata/xcschemes/test-Application.xcscheme"))
+ XCTAssert(
+ writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-TestOne.xcscheme"))
+ XCTAssert(
+ writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-TestTwo.xcscheme"))
+ XCTAssert(
+ writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/test-UnusedTest.xcscheme")
+ )
+ XCTAssert(
+ writtenFiles.contains("\(xcodeProjectPath)/xcshareddata/xcschemes/TestSuite_Suite.xcscheme")
+ )
} catch let e {
XCTFail("Unexpected exception \(e)")
}
@@ -241,11 +303,12 @@
func testProjectSDKROOT() {
func validate(_ types: [(String, String)], _ expectedSDKROOT: String?, line: UInt = #line) {
- let rules = types.map() { tuple in
+ let rules = types.map { tuple in
// Both the platform and osDeploymentTarget must be set in order to create a valid
// deploymentTarget for the RuleEntry.
- XcodeProjectGeneratorTests.makeRuleEntry(BuildLabel(tuple.0), type: tuple.0, platformType: tuple.1,
- osDeploymentTarget: "this_must_not_be_nil")
+ XcodeProjectGeneratorTests.makeRuleEntry(
+ BuildLabel(tuple.0), type: tuple.0, platformType: tuple.1,
+ osDeploymentTarget: "this_must_not_be_nil")
}
let sdkroot = XcodeProjectGenerator.projectSDKROOT(rules)
XCTAssertEqual(sdkroot, expectedSDKROOT, line: line)
@@ -261,7 +324,9 @@
// MARK: - Private methods
- private static func labelToRuleEntryMapForLabels(_ labels: [BuildLabel]) -> [BuildLabel: RuleEntry] {
+ private static func labelToRuleEntryMapForLabels(_ labels: [BuildLabel]) -> [BuildLabel:
+ RuleEntry]
+ {
var ret = [BuildLabel: RuleEntry]()
for label in labels {
ret[label] = makeRuleEntry(label, type: "ios_application", productType: .Application)
@@ -269,53 +334,57 @@
return ret
}
- private static func makeRuleEntry(_ label: BuildLabel,
- type: String,
- attributes: [String: AnyObject] = [:],
- artifacts: [BazelFileInfo] = [],
- sourceFiles: [BazelFileInfo] = [],
- nonARCSourceFiles: [BazelFileInfo] = [],
- dependencies: Set<BuildLabel> = Set(),
- secondaryArtifacts: [BazelFileInfo] = [],
- weakDependencies: Set<BuildLabel>? = nil,
- buildFilePath: String? = nil,
- objcDefines: [String]? = nil,
- swiftDefines: [String]? = nil,
- includePaths: [RuleEntry.IncludePath]? = nil,
- extensions: Set<BuildLabel>? = nil,
- productType: PBXTarget.ProductType? = nil,
- extensionType: String? = nil,
- platformType: String? = nil,
- osDeploymentTarget: String? = nil) -> RuleEntry {
- return RuleEntry(label: label,
- type: type,
- attributes: attributes,
- artifacts: artifacts,
- sourceFiles: sourceFiles,
- nonARCSourceFiles: nonARCSourceFiles,
- dependencies: dependencies,
- secondaryArtifacts: secondaryArtifacts,
- weakDependencies: weakDependencies,
- extensions: extensions,
- productType: productType,
- platformType: platformType,
- osDeploymentTarget: osDeploymentTarget,
- buildFilePath: buildFilePath,
- objcDefines: objcDefines,
- swiftDefines: swiftDefines,
- includePaths: includePaths,
- extensionType: extensionType)
+ private static func makeRuleEntry(
+ _ label: BuildLabel,
+ type: String,
+ attributes: [String: AnyObject] = [:],
+ artifacts: [BazelFileInfo] = [],
+ sourceFiles: [BazelFileInfo] = [],
+ nonARCSourceFiles: [BazelFileInfo] = [],
+ dependencies: Set<BuildLabel> = Set(),
+ secondaryArtifacts: [BazelFileInfo] = [],
+ weakDependencies: Set<BuildLabel>? = nil,
+ buildFilePath: String? = nil,
+ objcDefines: [String]? = nil,
+ swiftDefines: [String]? = nil,
+ includePaths: [RuleEntry.IncludePath]? = nil,
+ extensions: Set<BuildLabel>? = nil,
+ productType: PBXTarget.ProductType? = nil,
+ extensionType: String? = nil,
+ platformType: String? = nil,
+ osDeploymentTarget: String? = nil
+ ) -> RuleEntry {
+ return RuleEntry(
+ label: label,
+ type: type,
+ attributes: attributes,
+ artifacts: artifacts,
+ sourceFiles: sourceFiles,
+ nonARCSourceFiles: nonARCSourceFiles,
+ dependencies: dependencies,
+ secondaryArtifacts: secondaryArtifacts,
+ weakDependencies: weakDependencies,
+ extensions: extensions,
+ productType: productType,
+ platformType: platformType,
+ osDeploymentTarget: osDeploymentTarget,
+ buildFilePath: buildFilePath,
+ objcDefines: objcDefines,
+ swiftDefines: swiftDefines,
+ includePaths: includePaths,
+ extensionType: extensionType)
}
private func prepareGenerator(_ ruleEntries: [BuildLabel: RuleEntry]) {
let options = TulsiOptionSet()
// To avoid creating ~/Library folders and changing UserDefaults during CI testing.
- config = TulsiGeneratorConfig(projectName: XcodeProjectGeneratorTests.projectName,
- buildTargetLabels: Array(ruleEntries.keys),
- pathFilters: pathFilters,
- additionalFilePaths: additionalFilePaths,
- options: options,
- bazelURL: bazelURL)
+ config = TulsiGeneratorConfig(
+ projectName: XcodeProjectGeneratorTests.projectName,
+ buildTargetLabels: Array(ruleEntries.keys),
+ pathFilters: pathFilters,
+ additionalFilePaths: additionalFilePaths,
+ options: options,
+ bazelURL: bazelURL)
let projectURL = URL(fileURLWithPath: xcodeProjectPath, isDirectory: true)
mockFileManager.allowedDirectoryCreates.insert(projectURL.path)
@@ -323,13 +392,14 @@
mockFileManager.allowedDirectoryCreates.insert(tulsiworkspace.path)
let bazelCacheReaderURL = mockFileManager.homeDirectoryForCurrentUser.appendingPathComponent(
- "Library/Application Support/Tulsi/Scripts", isDirectory: true)
+ "Library/Application Support/Tulsi/Scripts", isDirectory: true)
mockFileManager.allowedDirectoryCreates.insert(bazelCacheReaderURL.path)
let xcshareddata = projectURL.appendingPathComponent("project.xcworkspace/xcshareddata")
mockFileManager.allowedDirectoryCreates.insert(xcshareddata.path)
- let xcuserdata = projectURL.appendingPathComponent("project.xcworkspace/xcuserdata/USER.xcuserdatad")
+ let xcuserdata = projectURL.appendingPathComponent(
+ "project.xcworkspace/xcuserdata/USER.xcuserdatad")
mockFileManager.allowedDirectoryCreates.insert(xcuserdata.path)
let xcschemes = projectURL.appendingPathComponent("xcshareddata/xcschemes")
@@ -354,19 +424,21 @@
mockFileManager.allowedDirectoryCreates.insert(tulsiBazelPackage.path)
let mockTemplate = ["NSExtension": ["NSExtensionPointIdentifier": "com.apple.intents-service"]]
- let templateData = try! PropertyListSerialization.data(fromPropertyList: mockTemplate, format: .xml, options: 0)
+ let templateData = try! PropertyListSerialization.data(
+ fromPropertyList: mockTemplate, format: .xml, options: 0)
mockFileManager.mockContent[resourceURLs.stubIOSAppExInfoPlistTemplate.path] = templateData
mockExtractor.labelToRuleEntry = ruleEntries
- generator = XcodeProjectGenerator(workspaceRootURL: workspaceRoot,
- config: config,
- localizedMessageLogger: mockLocalizedMessageLogger,
- workspaceInfoExtractor: mockExtractor,
- resourceURLs: resourceURLs,
- tulsiVersion: testTulsiVersion,
- fileManager: mockFileManager,
- pbxTargetGeneratorType: MockPBXTargetGenerator.self)
+ generator = XcodeProjectGenerator(
+ workspaceRootURL: workspaceRoot,
+ config: config,
+ localizedMessageLogger: mockLocalizedMessageLogger,
+ workspaceInfoExtractor: mockExtractor,
+ resourceURLs: resourceURLs,
+ tulsiVersion: testTulsiVersion,
+ fileManager: mockFileManager,
+ pbxTargetGeneratorType: MockPBXTargetGenerator.self)
generator.redactWorkspaceSymlink = true
generator.suppressModifyingUserDefaults = true
generator.suppressGeneratingBuildSettings = true
@@ -377,7 +449,6 @@
}
}
-
class MockFileManager: FileManager {
var filesThatExist = Set<String>()
var allowedDirectoryCreates = Set<String>()
@@ -396,9 +467,11 @@
return filesThatExist.contains(path)
}
- override func createDirectory(at url: URL,
- withIntermediateDirectories createIntermediates: Bool,
- attributes: [FileAttributeKey: Any]?) throws {
+ override func createDirectory(
+ at url: URL,
+ withIntermediateDirectories createIntermediates: Bool,
+ attributes: [FileAttributeKey: Any]?
+ ) throws {
guard !allowedDirectoryCreates.contains(url.path) else {
directoryOperations.append(url.path)
if let attributes = attributes {
@@ -406,14 +479,17 @@
}
return
}
- throw NSError(domain: "MockFileManager: Directory creation disallowed",
- code: 0,
- userInfo: nil)
+ throw NSError(
+ domain: "MockFileManager: Directory creation disallowed",
+ code: 0,
+ userInfo: nil)
}
- override func createDirectory(atPath path: String,
- withIntermediateDirectories createIntermediates: Bool,
- attributes: [FileAttributeKey: Any]?) throws {
+ override func createDirectory(
+ atPath path: String,
+ withIntermediateDirectories createIntermediates: Bool,
+ attributes: [FileAttributeKey: Any]?
+ ) throws {
guard !allowedDirectoryCreates.contains(path) else {
directoryOperations.append(path)
if let attributes = attributes {
@@ -421,9 +497,10 @@
}
return
}
- throw NSError(domain: "MockFileManager: Directory creation disallowed",
- code: 0,
- userInfo: nil)
+ throw NSError(
+ domain: "MockFileManager: Directory creation disallowed",
+ code: 0,
+ userInfo: nil)
}
override func removeItem(at URL: URL) throws {
@@ -446,7 +523,9 @@
return mockContent[path]
}
- override func createFile(atPath path: String, contents data: Data?, attributes attr: [FileAttributeKey : Any]? = nil) -> Bool {
+ override func createFile(
+ atPath path: String, contents data: Data?, attributes attr: [FileAttributeKey: Any]? = nil
+ ) -> Bool {
if writeOperations.keys.contains(path) {
fatalError("Attempting to overwrite an existing file at \(path)")
}
@@ -457,20 +536,21 @@
return true
}
- fileprivate func setAttributes(_ attributes: [FileAttributeKey : Any], path: String) {
- var currentAttributes = attributesMap[path] ?? [FileAttributeKey : Any]()
+ fileprivate func setAttributes(_ attributes: [FileAttributeKey: Any], path: String) {
+ var currentAttributes = attributesMap[path] ?? [FileAttributeKey: Any]()
attributes.forEach { (k, v) in
currentAttributes[k] = v
}
attributesMap[path] = currentAttributes
}
- override func setAttributes(_ attributes: [FileAttributeKey : Any], ofItemAtPath path: String) throws {
+ override func setAttributes(_ attributes: [FileAttributeKey: Any], ofItemAtPath path: String)
+ throws
+ {
self.setAttributes(attributes, path: path)
}
}
-
final class MockPBXTargetGenerator: PBXTargetGeneratorProtocol {
var project: PBXProject
@@ -483,58 +563,68 @@
}
static func mainGroupForOutputFolder(_ outputFolderURL: URL, workspaceRootURL: URL) -> PBXGroup {
- return PBXGroup(name: "mainGroup",
- path: "/A/Test/Path",
- sourceTree: .Absolute,
- parent: nil)
+ return PBXGroup(
+ name: "mainGroup",
+ path: "/A/Test/Path",
+ sourceTree: .Absolute,
+ parent: nil)
}
- required init(bazelPath: String,
- bazelBinPath: String,
- project: PBXProject,
- buildScriptPath: String,
- stubInfoPlistPaths: StubInfoPlistPaths,
- tulsiVersion: String,
- options: TulsiOptionSet,
- localizedMessageLogger: LocalizedMessageLogger,
- workspaceRootURL: URL,
- suppressCompilerDefines: Bool,
- redactWorkspaceSymlink: Bool) {
+ required init(
+ bazelPath: String,
+ bazelBinPath: String,
+ project: PBXProject,
+ buildScriptPath: String,
+ stubInfoPlistPaths: StubInfoPlistPaths,
+ tulsiVersion: String,
+ options: TulsiOptionSet,
+ localizedMessageLogger: LocalizedMessageLogger,
+ workspaceRootURL: URL,
+ suppressCompilerDefines: Bool,
+ redactWorkspaceSymlink: Bool
+ ) {
self.project = project
}
func generateFileReferencesForFilePaths(_ paths: [String], pathFilters: Set<String>?) {
}
- func registerRuleEntryForIndexer(_ ruleEntry: RuleEntry,
- ruleEntryMap: RuleEntryMap,
- pathFilters: Set<String>,
- processedEntries: inout [RuleEntry: (NSOrderedSet)]) {
+ func registerRuleEntryForIndexer(
+ _ ruleEntry: RuleEntry,
+ ruleEntryMap: RuleEntryMap,
+ pathFilters: Set<String>,
+ processedEntries: inout [RuleEntry: (NSOrderedSet)]
+ ) {
}
func generateIndexerTargets() -> [String: PBXTarget] {
return [:]
}
- func generateBazelCleanTarget(_ scriptPath: String, workingDirectory: String,
- startupOptions: [String]) {
+ func generateBazelCleanTarget(
+ _ scriptPath: String, workingDirectory: String,
+ startupOptions: [String]
+ ) {
}
func generateTopLevelBuildConfigurations(_ buildSettingOverrides: [String: String]) {
}
- func generateBuildTargetsForRuleEntries(_ ruleEntries: Set<RuleEntry>,
- ruleEntryMap: RuleEntryMap) throws {
+ func generateBuildTargetsForRuleEntries(
+ _ ruleEntries: Set<RuleEntry>,
+ ruleEntryMap: RuleEntryMap
+ ) throws {
// This works as this file only tests native targets that don't have multiple configurations.
- let namedRuleEntries = ruleEntries.map() { (e: RuleEntry) -> (String, RuleEntry) in
+ let namedRuleEntries = ruleEntries.map { (e: RuleEntry) -> (String, RuleEntry) in
return (e.label.asFullPBXTargetName!, e)
}
var testTargetLinkages = [(PBXTarget, BuildLabel)]()
for (name, entry) in namedRuleEntries {
- let target = project.createNativeTarget(name,
- deploymentTarget: entry.deploymentTarget,
- targetType: entry.pbxTargetType!)
+ let target = project.createNativeTarget(
+ name,
+ deploymentTarget: entry.deploymentTarget,
+ targetType: entry.pbxTargetType!)
if let hostLabelString = entry.attributes[.test_host] as? String {
let hostLabel = BuildLabel(hostLabelString)