Clean up project.

This commit is contained in:
Matyáš Kříž 2020-06-28 16:43:22 +02:00
parent 8abe3f2091
commit b3bec5f8ff
7 changed files with 15 additions and 142 deletions

View File

@ -1,49 +0,0 @@
import Foundation
@discardableResult
func shell(_ args: [String], inDir dir: String? = nil) -> Int32 {
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = args
if let dir = dir {
task.currentDirectoryPath = dir
}
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
let projectDir = ProcessInfo.processInfo.environment["PROJECT_DIR", default: "."]
let output = "\(projectDir)/Tests/Swift/Generated/GeneratedMocks.swift"
// Use seperate variables for each file.
let generatorArguments = [
"generate",
"--testable",
"Cuckoo",
"--exclude",
"ExcludedTestClass,ExcludedProtocol",
"--output",
output,
"\(projectDir)/Tests/Swift/Source/ClassForStubTesting.swift",
"\(projectDir)/Tests/Swift/Source/ClassWithOptionals.swift",
"\(projectDir)/Tests/Swift/Source/ObjcProtocol.swift",
"\(projectDir)/Tests/Swift/Source/UnicodeTestProtocol.swift",
"\(projectDir)/Tests/Swift/Source/TestedProtocol.swift",
"\(projectDir)/Tests/Swift/Source/TestedClass.swift",
"\(projectDir)/Tests/Swift/Source/TestedSubclass.swift",
"\(projectDir)/Tests/Swift/Source/TestedSubProtocol.swift",
"\(projectDir)/Tests/Swift/Source/ExcludedTestClass.swift",
"\(projectDir)/Tests/Swift/Source/GenericClass.swift",
"\(projectDir)/Tests/Swift/Source/GenericProtocol.swift",
"\(projectDir)/Tests/Swift/Source/GenericMethodClass.swift",
]
let useRun = Bool(ProcessInfo.processInfo.environment["USE_RUN", default: "false"]) ?? false
if useRun {
shell(["\(projectDir)/run", "--clean"] + generatorArguments)
} else {
shell(["swift", "run", "cuckoo_generator"] + generatorArguments, inDir: "\(projectDir)/Generator/")
}

View File

@ -1 +0,0 @@
4.2.1

View File

@ -153,8 +153,8 @@ public struct GenerateMocksCommand: CommandProtocol {
debugMode: Bool,
globEnabled: Bool,
regex: String,
files: [String]) {
files: [String]
) {
self.output = output
self.testableFrameworks = testableFrameworks.components(separatedBy: ",").filter { !$0.isEmpty }
self.exclude = exclude.components(separatedBy: ",").filter { !$0.isEmpty }.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }

View File

@ -54,8 +54,19 @@ func platformSet(platform: PlatformType, deploymentTarget: DeploymentTarget?) ->
],
actions: [
.pre(
path: "Scripts/RunCuckooGen.sh",
name: "Generate Mocks"
path: "run",
arguments: [
"generate",
"--testable",
"Cuckoo",
"--exclude",
"ExcludedTestClass,ExcludedProtocol",
"--output",
#""$PROJECT_DIR"/Tests/Swift/Generated/GeneratedMocks.swift"#,
"--glob",
#""$PROJECT_DIR"/Tests/Swift/Source/*.swift"#,
],
name: "Generate Mockinos"
)
],
dependencies: [
@ -120,86 +131,6 @@ func platformSet(platform: PlatformType, deploymentTarget: DeploymentTarget?) ->
return (targets, schemes)
}
// MARK: iOS target and scheme definition
// let iosTarget = Target(
// name: "Cuckoo-iOS",
// platform: .iOS,
// product: .framework,
// bundleId: "org.brightify.Cuckoo",
// deploymentTarget: .iOS(targetVersion: "9.0", devices: [.iphone, .ipad]),
// infoPlist: .extendingDefault(with: [:]),
// sources: "Source/**",
// settings: defaultBuildSettings
// )
//
// let iosTestTarget = Target(
// name: "Cuckoo-iOSTests",
// platform: .iOS,
// product: .unitTests,
// bundleId: "org.brightify.Cuckoo",
// infoPlist: .extendingDefault(with: [:]),
// sources: [
// "Tests/Common/**",
// "Tests/Swift/**",
// ],
// actions: [
// .pre(
// path: "Scripts/RunCuckooGen.sh",
// name: "Generate Mocks"
// )
// ],
// dependencies: [
// .target(name: iosTarget.name)
// ]
// )
//
// let iosObjCTarget = Target(
// name: "Cuckoo_OCMock-iOS",
// platform: .iOS,
// product: .framework,
// bundleId: "org.brightify.Cuckoo",
// deploymentTarget: .iOS(targetVersion: "9.0", devices: [.iphone, .ipad]),
// infoPlist: .extendingDefault(with: [:]),
// sources: [
// "Source/**",
// "OCMock/**",
// ],
// headers: .init(private: ["OCMock/**"]),
// dependencies: [
// .cocoapods(path: "."),
// .sdk(name: "OCMock.framework", status: .required),
// ],
// settings: objCBuildSettings
// )
//
// let iosObjCTestTarget = Target(
// name: "Cuckoo_OCMock-iOSTests",
// platform: .iOS,
// product: .unitTests,
// bundleId: "org.brightify.Cuckoo",
// infoPlist: .extendingDefault(with: [:]),
// sources: [
// "Tests/Common/**",
// "Tests/OCMock/**",
// ],
// dependencies: [
// .target(name: iosObjCTarget.name)
// ]
// )
//
// let iosScheme = Scheme(
// name: iosTarget.name,
// buildAction: .init(targets: [.init(stringLiteral: iosTarget.name)]),
// testAction: .init(targets: [.init(stringLiteral: iosTestTarget.name)])
// )
//
// let iosObjCScheme = Scheme(
// name: iosObjCTarget.name,
// shared: false,
// buildAction: .init(targets: [.init(stringLiteral: iosObjCTarget.name)]),
// testAction: .init(targets: [.init(stringLiteral: iosObjCTestTarget.name)])
// )
let (iOSTargets, iOSSchemes) = platformSet(platform: .iOS, deploymentTarget: .iOS(targetVersion: "8.0", devices: [.iphone, .ipad]))
let (macOSTargets, macOSSchemes) = platformSet(platform: .macOS, deploymentTarget: .macOS(targetVersion: "10.9"))
let (tvOSTargets, tvOSSchemes) = platformSet(platform: .tvOS, deploymentTarget: nil)

View File

@ -1,6 +0,0 @@
GENERATE=1
if [ $GENERATE -ne 0 ]; then
env -i PATH=$PATH PROJECT_DIR=$PROJECT_DIR USE_RUN=$USE_RUN swift "$PROJECT_DIR/GenerateMocksForTests.swift"
fi

View File

@ -1,9 +1,7 @@
import ProjectDescription
let generateMocksScript = "Scripts/RunCuckooGen.sh"
let generatorProject = "Generator/CuckooGenerator.xcodeproj"
let setup = Setup([
.custom(name: "Generator project must be created.", meet: ["make", "dev"], isMet: isMet: ["ls", generatorProject])
.custom(name: "Generate Mocks script must be executable.", meet: ["chmod", "u+x", generateMocksScript], isMet: ["if [[ -x \"\(generateMocksScript)\" ]]; then return 0; else return 1; fi"]),
])