@@ -4251,6 +4251,57 @@ final class BuildPlanTests: XCTestCase {
4251
4251
try sanitizerTest ( . scudo, expectedName: " scudo " )
4252
4252
}
4253
4253
4254
+ func testSnippets( ) throws {
4255
+ let fs = InMemoryFileSystem ( emptyFiles:
4256
+ " /Pkg/Sources/Lib/Lib.swift " ,
4257
+ " /Pkg/Snippets/ASnippet.swift " ,
4258
+ " /Pkg/.build/release.yaml "
4259
+ )
4260
+ let buildPath = AbsolutePath ( path: " /Pkg/.build " )
4261
+ let observability = ObservabilitySystem . makeForTesting ( )
4262
+ let graph = try loadPackageGraph (
4263
+ fileSystem: fs,
4264
+ manifests: [
4265
+ Manifest . createRootManifest (
4266
+ name: " Lib " ,
4267
+ path: . init( path: " /Pkg " ) ,
4268
+ toolsVersion: . vNext,
4269
+ dependencies: [ ] ,
4270
+ products: [
4271
+ ProductDescription ( name: " Lib " , type: . library( . automatic) , targets: [ " Lib " ] )
4272
+ ] ,
4273
+ targets: [
4274
+ TargetDescription ( name: " Lib " , dependencies: [ ] , type: . regular) ,
4275
+ ] ) ,
4276
+ ] ,
4277
+ observabilityScope: observability. topScope
4278
+ )
4279
+ XCTAssertNoDiagnostics ( observability. diagnostics)
4280
+ let plan = try BuildPlan (
4281
+ buildParameters: mockBuildParameters ( buildPath: buildPath) ,
4282
+ graph: graph,
4283
+ fileSystem: fs,
4284
+ observabilityScope: observability. topScope
4285
+ )
4286
+
4287
+ let result = try BuildPlanResult ( plan: plan)
4288
+ result. checkProductsCount ( 1 )
4289
+ result. checkTargetsCount ( 2 )
4290
+ XCTAssertTrue ( result. targetMap. values. contains { $0. target. name == " ASnippet " && $0. target. type == . snippet } )
4291
+ XCTAssertTrue ( result. targetMap. values. contains { $0. target. name == " Lib " } )
4292
+
4293
+ let yaml = buildPath. appending ( component: " release.yaml " )
4294
+ let llbuild = LLBuildManifestBuilder ( plan, fileSystem: fs, observabilityScope: observability. topScope)
4295
+ try llbuild. generateManifest ( at: yaml)
4296
+
4297
+ let yamlContents : String = try fs. readFileContents ( yaml)
4298
+ print ( yamlContents)
4299
+ XCTAssertMatch ( yamlContents, . contains( """
4300
+ inputs: [ " /Pkg/Snippets/ASnippet.swift " , " /Pkg/.build/debug/Lib.swiftmodule "
4301
+ """ ) )
4302
+
4303
+ }
4304
+
4254
4305
private func sanitizerTest( _ sanitizer: PackageModel . Sanitizer , expectedName: String ) throws {
4255
4306
let fs = InMemoryFileSystem ( emptyFiles:
4256
4307
" /Pkg/Sources/exe/main.swift " ,
0 commit comments