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