@@ -4633,6 +4633,119 @@ final class BuildPlanTests: XCTestCase {
4633
4633
] )
4634
4634
}
4635
4635
4636
+ func testSwiftTestingFlagsOnMacOSWithCustomToolchain( ) throws {
4637
+ #if !os(macOS)
4638
+ // This is testing swift-testing in a toolchain which is macOS only feature.
4639
+ try XCTSkipIf ( true , " test is only supported on macOS " )
4640
+ #endif
4641
+
4642
+ let fs = InMemoryFileSystem (
4643
+ emptyFiles:
4644
+ " /fake/path/lib/swift/macosx/testing/Testing.swiftmodule " ,
4645
+ " /fake/path/lib/swift/host/plugins/testing/libTesting.dylib " ,
4646
+ " /Pkg/Sources/Lib/main.swift " ,
4647
+ " /Pkg/Tests/LibTest/test.swift "
4648
+ )
4649
+ try fs. createMockToolchain ( )
4650
+
4651
+ let userSwiftSDK = SwiftSDK (
4652
+ hostTriple: . x86_64MacOS,
4653
+ targetTriple: . x86_64MacOS,
4654
+ toolset: . init(
4655
+ knownTools: [
4656
+ . cCompiler: . init( extraCLIOptions: [ ] ) ,
4657
+ . swiftCompiler: . init( extraCLIOptions: [ ] ) ,
4658
+ ] ,
4659
+ rootPaths: [ " /fake/path/to " ]
4660
+ ) ,
4661
+ pathsConfiguration: . init(
4662
+ sdkRootPath: " /fake/sdk " ,
4663
+ swiftResourcesPath: " /fake/lib/swift " ,
4664
+ swiftStaticResourcesPath: " /fake/lib/swift_static "
4665
+ )
4666
+ )
4667
+ let mockToolchain = try UserToolchain (
4668
+ swiftSDK: userSwiftSDK,
4669
+ environment: . mockEnvironment,
4670
+ fileSystem: fs
4671
+ )
4672
+
4673
+ XCTAssertEqual (
4674
+ mockToolchain. extraFlags. swiftCompilerFlags,
4675
+ [
4676
+ " -I " , " /fake/path/lib/swift/macosx/testing " ,
4677
+ " -L " , " /fake/path/lib/swift/macosx/testing " ,
4678
+ " -plugin-path " , " /fake/path/lib/swift/host/plugins/testing " ,
4679
+ " -sdk " , " /fake/sdk " ,
4680
+ ]
4681
+ )
4682
+ XCTAssertEqual (
4683
+ mockToolchain. extraFlags. linkerFlags,
4684
+ [ " -rpath " , " /fake/path/lib/swift/macosx/testing " ]
4685
+ )
4686
+
4687
+ let observability = ObservabilitySystem . makeForTesting ( )
4688
+ let graph = try loadModulesGraph (
4689
+ fileSystem: fs,
4690
+ manifests: [
4691
+ Manifest . createRootManifest (
4692
+ displayName: " Pkg " ,
4693
+ path: " /Pkg " ,
4694
+ targets: [
4695
+ TargetDescription ( name: " Lib " , dependencies: [ ] ) ,
4696
+ TargetDescription (
4697
+ name: " LibTest " ,
4698
+ dependencies: [ " Lib " ] ,
4699
+ type: . test
4700
+ ) ,
4701
+ ]
4702
+ ) ,
4703
+ ] ,
4704
+ observabilityScope: observability. topScope
4705
+ )
4706
+ XCTAssertNoDiagnostics ( observability. diagnostics)
4707
+
4708
+ let result = try BuildPlanResult ( plan: mockBuildPlan (
4709
+ toolchain: mockToolchain,
4710
+ graph: graph,
4711
+ commonFlags: . init( ) ,
4712
+ fileSystem: fs,
4713
+ observabilityScope: observability. topScope
4714
+ ) )
4715
+ result. checkProductsCount ( 2 )
4716
+ result. checkTargetsCount ( 3 )
4717
+
4718
+ let testProductLinkArgs = try result. buildProduct ( for: " Lib " ) . linkArguments ( )
4719
+ XCTAssertMatch ( testProductLinkArgs, [
4720
+ . anySequence,
4721
+ " -I " , " /fake/path/lib/swift/macosx/testing " ,
4722
+ " -L " , " /fake/path/lib/swift/macosx/testing " ,
4723
+ . anySequence,
4724
+ " -Xlinker " , " -rpath " ,
4725
+ " -Xlinker " , " /fake/path/lib/swift/macosx/testing " ,
4726
+ ] )
4727
+
4728
+ let libModuleArgs = try result. moduleBuildDescription ( for: " Lib " ) . swift ( ) . compileArguments ( )
4729
+ XCTAssertMatch ( libModuleArgs, [
4730
+ . anySequence,
4731
+ " -I " , " /fake/path/lib/swift/macosx/testing " ,
4732
+ " -L " , " /fake/path/lib/swift/macosx/testing " ,
4733
+ " -plugin-path " , " /fake/path/lib/swift/host/plugins/testing " ,
4734
+ . anySequence,
4735
+ ] )
4736
+ XCTAssertNoMatch ( libModuleArgs, [ " -Xlinker " ] )
4737
+
4738
+ let testModuleArgs = try result. moduleBuildDescription ( for: " LibTest " ) . swift ( ) . compileArguments ( )
4739
+ XCTAssertMatch ( testModuleArgs, [
4740
+ . anySequence,
4741
+ " -I " , " /fake/path/lib/swift/macosx/testing " ,
4742
+ " -L " , " /fake/path/lib/swift/macosx/testing " ,
4743
+ " -plugin-path " , " /fake/path/lib/swift/host/plugins/testing " ,
4744
+ . anySequence,
4745
+ ] )
4746
+ XCTAssertNoMatch ( testModuleArgs, [ " -Xlinker " ] )
4747
+ }
4748
+
4636
4749
func testUserToolchainWithToolsetCompileFlags( ) throws {
4637
4750
let fileSystem = InMemoryFileSystem (
4638
4751
emptyFiles:
0 commit comments