Skip to content

Commit

Permalink
add StaticFramework test and fix url target path
Browse files Browse the repository at this point in the history
  • Loading branch information
sidepelican committed Sep 23, 2019
1 parent 6c1b85f commit b9a1073
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
24 changes: 15 additions & 9 deletions Source/CarthageKit/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1002,19 +1002,15 @@ public final class Project { // swiftlint:disable:this type_body_length
var urls: [URL] = []
urls += (try? fileManager
.contentsOfDirectory(
at: self.directoryURL.appendingPathComponent(
Constants.checkoutsFolderPath, isDirectory: true
),
at: self.directoryURL.appendingPathComponent(Constants.checkoutsFolderPath, isDirectory: true),
includingPropertiesForKeys: nil
)
.map { $0.resolvingSymlinksInPath() }
.filter { !checkoutURLs.contains($0) }) ?? []

urls += (try? fileManager
.contentsOfDirectory(
at: self.directoryURL.appendingPathComponent(
Constants.binariesFolderPath, isDirectory: true
),
at: self.directoryURL.appendingPathComponent(Constants.binariesFolderPath, isDirectory: true),
includingPropertiesForKeys: nil
)
.map { $0.resolvingSymlinksInPath() }
Expand All @@ -1025,9 +1021,19 @@ public final class Project { // swiftlint:disable:this type_body_length
.flatMap { platform -> [URL] in
(try? fileManager
.contentsOfDirectory(
at: self.directoryURL.appendingPathComponent(
platform.relativePath, isDirectory: true
),
at: self.directoryURL.appendingPathComponent(platform.relativePath, isDirectory: true),
includingPropertiesForKeys: nil
)
.filter { !binaryURLs.contains($0) && $0.lastPathComponent != FrameworkType.staticFolderName }) ?? []
}

urls += Platform.supportedPlatforms
.flatMap { platform -> [URL] in
(try? fileManager
.contentsOfDirectory(
at: self.directoryURL
.appendingPathComponent(platform.relativePath, isDirectory: true)
.appendingPathComponent(FrameworkType.staticFolderName, isDirectory: true),
includingPropertiesForKeys: nil
)
.filter { !binaryURLs.contains($0) }) ?? []
Expand Down
30 changes: 30 additions & 0 deletions Tests/CarthageKitTests/ProjectSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,36 @@ class ProjectSpec: QuickSpec {

expect(Set(removedItems)) == expectedItems
}

it("should successfully remove static frameworks") {
let directoryURL = baseDirectoryURL.appendingPathComponent("StaticFramework", isDirectory: true)
let project = Project(directoryURL: directoryURL)
var events = [ProjectEvent]()
project.projectEvents.observeValues { events.append($0) }

expect(project.removeUnneededItems().wait().error).to(beNil())

let removedItems = events.compactMap { event -> URL? in
guard case let .removingUnneededItem(url) = event else {
fail()
return nil
}
return url
}

let expectedPaths = [
("Build/Mac/Static/TestFramework.framework", true),
("Build/iOS/Static/TestFramework.framework", true),
("Checkouts/TestFramework", true),
("Build/.TestFramework.version", false),
]

let expectedItems = Set(expectedPaths.map {
directoryURL.appendingPathComponent("Carthage/\($0)", isDirectory: $1)
})

expect(Set(removedItems)) == expectedItems
}
}

describe("transitiveDependencies") {
Expand Down
Binary file modified Tests/CarthageKitTests/fixtures/CleanupTest.zip
Binary file not shown.

0 comments on commit b9a1073

Please sign in to comment.