Skip to content

Commit 014f595

Browse files
committed
Add a test case for static products with a binary artifact dependency
Add a test #8055 that checks we can successfully generate a manifest for a target -> static product -> binary artifact dependency. (cherry picked from commit 86d7dba)
1 parent 465c3a8 commit 014f595

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6738,4 +6738,103 @@ final class BuildPlanTests: XCTestCase {
67386738
)
67396739
}
67406740
}
6741+
6742+
func testProductWithBinaryArtifactDependency() async throws {
6743+
let fs = InMemoryFileSystem(
6744+
emptyFiles:
6745+
"/testpackage/Sources/SwiftLib/lib.swift",
6746+
"/testpackage/Sources/CLib/include/lib.h",
6747+
"/testpackage/Sources/CLib/lib.c"
6748+
)
6749+
6750+
try fs.createDirectory("/testpackagedep/SomeArtifact.xcframework", recursive: true)
6751+
try fs.writeFileContents(
6752+
"/testpackagedep/SomeArtifact.xcframework/Info.plist",
6753+
string: """
6754+
<?xml version="1.0" encoding="UTF-8"?>
6755+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
6756+
<plist version="1.0">
6757+
<dict>
6758+
<key>AvailableLibraries</key>
6759+
<array>
6760+
<dict>
6761+
<key>LibraryIdentifier</key>
6762+
<string>macos-arm64</string>
6763+
<key>HeadersPath</key>
6764+
<string>Headers</string>
6765+
<key>LibraryPath</key>
6766+
<string>libSomeArtifact.a</string>
6767+
<key>SupportedArchitectures</key>
6768+
<array>
6769+
<string>arm64</string>
6770+
</array>
6771+
<key>SupportedPlatform</key>
6772+
<string>macos</string>
6773+
</dict>
6774+
</array>
6775+
<key>CFBundlePackageType</key>
6776+
<string>XFWK</string>
6777+
<key>XCFrameworkFormatVersion</key>
6778+
<string>1.0</string>
6779+
</dict>
6780+
</plist>
6781+
"""
6782+
)
6783+
6784+
let observability = ObservabilitySystem.makeForTesting()
6785+
let graph = try loadModulesGraph(
6786+
fileSystem: fs,
6787+
manifests: [
6788+
Manifest.createFileSystemManifest(
6789+
displayName: "testpackagedep",
6790+
path: "/testpackagedep",
6791+
products: [
6792+
ProductDescription(name: "SomeArtifact", type: .library(.static), targets: ["SomeArtifact"]),
6793+
],
6794+
targets: [
6795+
TargetDescription(name: "SomeArtifact", path: "SomeArtifact.xcframework", type: .binary),
6796+
]
6797+
),
6798+
Manifest.createRootManifest(
6799+
displayName: "testpackage",
6800+
path: "/testpackage",
6801+
dependencies: [
6802+
.localSourceControl(path: "/testpackagedep", requirement: .upToNextMajor(from: "1.0.0")),
6803+
],
6804+
products: [
6805+
ProductDescription(name: "SwiftLib", type: .library(.static), targets: ["SwiftLib"]),
6806+
ProductDescription(name: "CLib", type: .library(.static), targets: ["CLib"]),
6807+
],
6808+
targets: [
6809+
TargetDescription(name: "SwiftLib", dependencies: ["SomeArtifact"]),
6810+
TargetDescription(name: "CLib", dependencies: ["SomeArtifact"])
6811+
]
6812+
),
6813+
],
6814+
binaryArtifacts: [
6815+
.plain("testpackagedep"): [
6816+
"SomeArtifact": .init(kind: .xcframework, originURL: nil, path: "/testpackagedep/SomeArtifact.xcframework"),
6817+
],
6818+
],
6819+
observabilityScope: observability.topScope
6820+
)
6821+
XCTAssertNoDiagnostics(observability.diagnostics)
6822+
6823+
let plan = try await mockBuildPlan(
6824+
graph: graph,
6825+
fileSystem: fs,
6826+
observabilityScope: observability.topScope
6827+
)
6828+
6829+
let llbuild = LLBuildManifestBuilder(
6830+
plan,
6831+
fileSystem: fs,
6832+
observabilityScope: observability.topScope
6833+
)
6834+
try llbuild.generateManifest(at: "/manifest.yaml")
6835+
let contents: String = try fs.readFileContents("/manifest.yaml")
6836+
6837+
XCTAssertMatch(contents, .regex(#"args: \[.*"-I","/testpackagedep/SomeArtifact.xcframework/macos-arm64/Headers".*,"/testpackage/Sources/CLib/lib.c".*]"#))
6838+
XCTAssertMatch(contents, .regex(#"args: \[.*"-module-name","SwiftLib",.*"-I","/testpackagedep/SomeArtifact.xcframework/macos-arm64/Headers".*]"#))
6839+
}
67416840
}

0 commit comments

Comments
 (0)