@@ -1986,6 +1986,52 @@ final class ExplicitModuleBuildTests: XCTestCase {
19861986 }
19871987 }
19881988
1989+ /// Test the libSwiftScan dependency scanning.
1990+ func testDependencyScanningPluginFlagPropagation( ) throws {
1991+ let ( stdlibPath, shimsPath, toolchain, hostTriple) = try getDriverArtifactsForScanning ( )
1992+
1993+ // The dependency oracle wraps an instance of libSwiftScan and ensures thread safety across
1994+ // queries.
1995+ let dependencyOracle = InterModuleDependencyOracle ( )
1996+ let scanLibPath = try XCTUnwrap ( toolchain. lookupSwiftScanLib ( ) )
1997+ try dependencyOracle. verifyOrCreateScannerInstance ( swiftScanLibPath: scanLibPath)
1998+
1999+ // Create a simple test case.
2000+ try withTemporaryDirectory { path in
2001+ let main = path. appending ( component: " testDependencyScanning.swift " )
2002+ try localFileSystem. writeFileContents ( main, bytes:
2003+ """
2004+ import C; \
2005+ import E; \
2006+ import G;
2007+ """
2008+ )
2009+
2010+ let cHeadersPath : AbsolutePath =
2011+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2012+ . appending ( component: " CHeaders " )
2013+ let swiftModuleInterfacesPath : AbsolutePath =
2014+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2015+ . appending ( component: " Swift " )
2016+ let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
2017+ var driver = try Driver ( args: [ " swiftc " ,
2018+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2019+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2020+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2021+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2022+ " /tmp/Foo.o " ,
2023+ " -plugin-path " , " PluginA " , " -external-plugin-path " , " Plugin~B#Bexe " ,
2024+ " -explicit-module-build " ,
2025+ " -working-directory " , path. nativePathString ( escaped: true ) ,
2026+ " -disable-clang-target " ,
2027+ main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting)
2028+ let resolver = try ArgsResolver ( fileSystem: localFileSystem)
2029+ var scannerCommand = try driver. dependencyScannerInvocationCommand ( ) . 1 . map { try resolver. resolve ( $0) }
2030+ XCTAssertTrue ( scannerCommand. contains ( " -plugin-path " ) )
2031+ XCTAssertTrue ( scannerCommand. contains ( " -external-plugin-path " ) )
2032+ }
2033+ }
2034+
19892035 /// Test the libSwiftScan dependency scanning.
19902036 func testDependencyScanning( ) throws {
19912037 let ( stdlibPath, shimsPath, toolchain, hostTriple) = try getDriverArtifactsForScanning ( )
0 commit comments