Skip to content

Commit

Permalink
It is valid for HEAD to have no Package.swift
Browse files Browse the repository at this point in the history
Provided the tag that we pick *does* have a Package.swift.
  • Loading branch information
mxcl committed Dec 4, 2015
1 parent c6e676c commit 6acd0f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Sources/dep/get.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,13 @@ extension Sandbox: Fetcher {
*/
class RawClone: Fetchable {
let path: String
let manifest: Manifest!

init(path: String) throws {
// lazy because the tip of the default branch does not have to be a valid package
//FIXME we should error gracefully if a selected version does not however
lazy var manifest: Manifest = try! Manifest(path: Path.join(self.path, Manifest.filename), baseURL: self.repo.origin!)

init(path: String) {
self.path = path
do {
let manifestPath = Path.join(path, Manifest.filename)
self.manifest = try Manifest(path: manifestPath, baseURL: Git.Repo(root: path)!.origin!)
} catch {
self.manifest = nil
throw error
}
}

var repo: Git.Repo {
Expand Down
24 changes: 24 additions & 0 deletions Tests/dep/FunctionalBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,28 @@ class FunctionalBuildTests: XCTestCase, XCTestCaseProvider {
XCTAssertNotNil(try? executeSwiftBuild("\(prefix)/app"))
}
}

// if HEAD of the default branch has no Package.swift it is still
// valid provided the selected version tag has a Package.swift
func testTipHasNoPackageSwift() {
fixture(name: "102_mattts_dealer") { prefix in
let path = Path.join(prefix, "FisherYates")
try system("git", "-C", path, "rm", "Package.swift")
try system("git", "-C", path, "commit", "-mwip")

XCTAssertNotNil(try? executeSwiftBuild("\(prefix)/app"))
}
}

// if a tag does not have a valid Package.swift, the build fails
func testFailsIfVersionTagHasNoPackageSwift() {
fixture(name: "102_mattts_dealer") { prefix in
let path = Path.join(prefix, "FisherYates")
try system("git", "-C", path, "rm", "Package.swift")
try system("git", "-C", path, "commit", "-mwip")
try system("git", "-C", path, "tag", "-f", "1.2.3")

XCTAssertNil(try? executeSwiftBuild("\(prefix)/app"))
}
}
}

0 comments on commit 6acd0f8

Please sign in to comment.