Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,32 @@ public struct BinaryDependenciesConfigurationReader {

let dependencies = configuration.dependencies
let dependenciesInfo = dependencies
.map { " \($0.repo)(\($0.tag))" }
.flatMap { dependency in
dependency.assets.map { " \(info(for: dependency, asset: $0))" }
}
.joined(separator: "\n")
Logger.log(
"[Read] Found \(dependencies.count) dependencies:\n\(dependenciesInfo)"
)

return configuration
}

/// Builds a single-line description of a dependency asset, e.g. `owner/repo(1.0.0) Asset.zip -> output/dir`.
/// - Parameters:
/// - dependency: The dependency the asset belongs to.
/// - asset: The asset to describe.
/// - Returns: A string with the repo, tag, asset pattern (or contents), and output directory when present.
func info(for dependency: Dependency, asset: Dependency.Asset) -> String {
var components: [String] = ["\(dependency.repo)(\(dependency.tag))"]
if let pattern = asset.pattern ?? asset.contents {
components.append(pattern)
}
if let outputDirectory = asset.outputDirectory {
components.append("-> \(outputDirectory)")
}
return components.joined(separator: " ")
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,29 @@ final class BinaryDependenciesConfigurationReaderTests: XCTestCase {
)
XCTAssertEqual(config, expected)
}

func test_info_withPattern() {
let sut = makeReader(withFiles: [])
let dependency = Dependency(repo: "test/repo", tag: "1.0.0", assets: [])
let asset = Dependency.Asset(checksum: "check1", pattern: "Asset.xcframework.zip")

XCTAssertEqual(sut.info(for: dependency, asset: asset), "test/repo(1.0.0) Asset.xcframework.zip")
}

func test_info_withPatternAndOutputDirectory() {
let sut = makeReader(withFiles: [])
let dependency = Dependency(repo: "test/repo", tag: "1.0.0", assets: [])
let asset = Dependency.Asset(checksum: "check1", pattern: "Asset.framework.zip", outputDirectory: "sandbox")

XCTAssertEqual(sut.info(for: dependency, asset: asset), "test/repo(1.0.0) Asset.framework.zip -> sandbox")
}

func test_info_withoutPattern_fallsBackToContents() {
let sut = makeReader(withFiles: [])
let dependency = Dependency(repo: "test/repo", tag: "1.0.0", assets: [])
let asset = Dependency.Asset(checksum: "check1", contents: "Products")

XCTAssertEqual(sut.info(for: dependency, asset: asset), "test/repo(1.0.0) Products")
}
}

Loading