diff --git a/Sources/Build/describe().swift b/Sources/Build/describe().swift index 6233f3a2b64..fdfbec7e00e 100644 --- a/Sources/Build/describe().swift +++ b/Sources/Build/describe().swift @@ -27,7 +27,9 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module], let prefix = try mkdir(prefix, conf.dirname) let yaml = try YAML(path: "\(prefix).yaml") let write = yaml.write - let (tests, nontests) = targetSplitter(modules, products) + + let (buildableTests, buildableNonTests) = (modules.map{$0 as Buildable} + products.map{$0 as Buildable}).partition{$0.isTest} + let (tests, nontests) = (buildableTests.map{$0.targetName}, buildableNonTests.map{$0.targetName}) defer { yaml.close() } diff --git a/Sources/Build/misc.swift b/Sources/Build/misc.swift index d227ba70a8a..a514bbbfac3 100644 --- a/Sources/Build/misc.swift +++ b/Sources/Build/misc.swift @@ -107,17 +107,22 @@ func infoPlist(test: Product) -> String { return s } -// this function because I couldn't make a Buildable -// protocol and then implement an isTest function -// without Swift runtime erroring about "Could not -// convert Array from Objective-C. -// FIXME please improve! -func targetSplitter(modules: [Module], _ products: [Product]) -> ([String], [String]) { - let (testmodules, nontestmodules) = modules.partition{ $0 is TestModule } - let (testproducts, nontestproducts) = products.partition{ if case .Test = $0.type { return true } else { return false } } - - let one = testmodules.map{$0.targetName} + testproducts.map{$0.targetName} - let two = nontestmodules.map{$0.targetName} + nontestproducts.map{$0.targetName} - - return (one, two) +protocol Buildable { + var targetName: String { get } + var isTest: Bool { get } +} + +extension Module: Buildable { + var isTest: Bool { + return self is TestModule + } +} + +extension Product: Buildable { + var isTest: Bool { + if case .Test = type { + return true + } + return false + } }