Validate project reference path

This commit is contained in:
Yuta Saito
2020-01-06 20:51:58 +09:00
parent 4c44191737
commit 8fe5c0cd16
3 changed files with 16 additions and 0 deletions
+6
View File
@@ -178,6 +178,12 @@ extension Project {
}
}
for projectReference in projectReferences {
if !(basePath + projectReference.path).exists {
errors.append(.invalidProjectReferencePath(projectReference))
}
}
for scheme in schemes {
for buildTarget in scheme.build.targets {
switch buildTarget.target.location {
@@ -30,6 +30,7 @@ public struct SpecValidationError: Error, CustomStringConvertible {
case missingDefaultConfig(configName: String)
case invalidPerConfigSettings
case invalidProjectReference(scheme: String, reference: String)
case invalidProjectReferencePath(ProjectReference)
public var description: String {
switch self {
@@ -75,6 +76,8 @@ public struct SpecValidationError: Error, CustomStringConvertible {
return "Settings that are for a specific config must go in \"configs\". \"base\" can be used for common settings"
case let .invalidProjectReference(scheme, project):
return "Scheme \(scheme.quoted) has invalid project reference \(project.quoted)"
case let .invalidProjectReferencePath(reference):
return "Project reference \(reference.name) has a project file path that doesn't exist \"\(reference.path)\""
}
}
}
@@ -226,6 +226,13 @@ class ProjectSpecTests: XCTestCase {
try expectValidationError(project, .invalidProjectReference(scheme: "scheme1", reference: "invalidProjectRef"))
}
$0.it("fails with invalid project reference path") {
var project = baseProject
let reference = ProjectReference(name: "InvalidProj", path: "invalid_path")
project.projectReferences = [reference]
try expectValidationError(project, .invalidProjectReferencePath(reference))
}
$0.it("allows missing optional file") {
var project = baseProject
project.targets = [Target(