@@ -6798,14 +6798,64 @@ final class SwiftDriverTests: XCTestCase {
6798
6798
}
6799
6799
6800
6800
func testPluginPaths( ) throws {
6801
- var driver = try Driver ( args: [ " swiftc " , " -typecheck " , " foo.swift " ] )
6802
- guard driver. isFrontendArgSupported ( . pluginPath) else {
6801
+ let sdkRoot = testInputsPath. appending ( component: " SDKChecks " ) . appending ( component: " iPhoneOS.sdk " )
6802
+ var driver = try Driver ( args: [ " swiftc " , " -typecheck " , " foo.swift " , " -sdk " , VirtualPath . absolute ( sdkRoot) . name, " -plugin-path " , " PluginA " , " -external-plugin-path " , " PluginB#Bexe " , " -load-plugin-library " , " PluginB2 " , " -plugin-path " , " PluginC " ] )
6803
+ guard driver. isFrontendArgSupported ( . pluginPath) && driver. isFrontendArgSupported ( . externalPluginPath) else {
6803
6804
return
6804
6805
}
6805
6806
6806
6807
let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
6807
6808
XCTAssertEqual ( jobs. count, 1 )
6808
6809
let job = jobs. first!
6810
+
6811
+ // Check that the we have the plugin paths we expect, in the order we expect.
6812
+ let pluginAIndex = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginA " ) ) ) )
6813
+ XCTAssertNotNil ( pluginAIndex)
6814
+
6815
+ let pluginBIndex = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginB#Bexe " ) ) ) )
6816
+ XCTAssertNotNil ( pluginBIndex)
6817
+ XCTAssertLessThan ( pluginAIndex!, pluginBIndex!)
6818
+
6819
+ let pluginB2Index = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginB2 " ) ) ) )
6820
+ XCTAssertNotNil ( pluginB2Index)
6821
+ XCTAssertLessThan ( pluginBIndex!, pluginB2Index!)
6822
+
6823
+ let pluginCIndex = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginC " ) ) ) )
6824
+ XCTAssertNotNil ( pluginCIndex)
6825
+ XCTAssertLessThan ( pluginB2Index!, pluginCIndex!)
6826
+
6827
+ #if os(macOS)
6828
+ XCTAssertTrue ( job. commandLine. contains ( . flag( " -external-plugin-path " ) ) )
6829
+ let sdkServerPath = sdkRoot. appending ( components: " usr " , " bin " , " swift-plugin-server " ) . pathString
6830
+ let sdkPluginPath = sdkRoot. appending ( components: " usr " , " lib " , " swift " , " host " , " plugins " ) . pathString
6831
+
6832
+ let sdkPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( sdkPluginPath) # \( sdkServerPath) " ) )
6833
+ XCTAssertNotNil ( sdkPluginPathIndex)
6834
+ XCTAssertLessThan ( pluginCIndex!, sdkPluginPathIndex!)
6835
+
6836
+ let sdkLocalPluginPath = sdkRoot. appending ( components: " usr " , " local " , " lib " , " swift " , " host " , " plugins " ) . pathString
6837
+ let sdkLocalPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( sdkLocalPluginPath) # \( sdkServerPath) " ) )
6838
+ XCTAssertNotNil ( sdkLocalPluginPathIndex)
6839
+ XCTAssertLessThan ( sdkPluginPathIndex!, sdkLocalPluginPathIndex!)
6840
+
6841
+ let platformPath = sdkRoot. parentDirectory. parentDirectory. parentDirectory. appending ( components: " Developer " , " usr " )
6842
+ let platformServerPath = platformPath. appending ( components: " bin " , " swift-plugin-server " ) . pathString
6843
+
6844
+ let platformPluginPath = platformPath. appending ( components: " lib " , " swift " , " host " , " plugins " )
6845
+ let platformPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( platformPluginPath) # \( platformServerPath) " ) )
6846
+ XCTAssertNotNil ( platformPluginPathIndex)
6847
+ XCTAssertLessThan ( sdkLocalPluginPathIndex!, platformPluginPathIndex!)
6848
+
6849
+ let platformLocalPluginPath = platformPath. appending ( components: " local " , " lib " , " swift " , " host " , " plugins " )
6850
+ let platformLocalPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( platformLocalPluginPath) # \( platformServerPath) " ) )
6851
+ XCTAssertNotNil ( platformLocalPluginPathIndex)
6852
+ XCTAssertLessThan ( platformPluginPathIndex!, platformLocalPluginPathIndex!)
6853
+
6854
+ let toolchainPluginPathIndex = job. commandLine. firstIndex ( of: . path( . absolute( try driver. toolchain. executableDir. parentDirectory. appending ( components: " lib " , " swift " , " host " , " plugins " ) ) ) )
6855
+ XCTAssertNotNil ( toolchainPluginPathIndex)
6856
+ XCTAssertLessThan ( platformLocalPluginPathIndex!, toolchainPluginPathIndex!)
6857
+ #endif
6858
+
6809
6859
XCTAssertTrue ( job. commandLine. contains ( . flag( " -plugin-path " ) ) )
6810
6860
XCTAssertTrue ( job. commandLine. contains ( . path( . absolute( try driver. toolchain. executableDir. parentDirectory. appending ( components: " lib " , " swift " , " host " , " plugins " ) ) ) ) )
6811
6861
XCTAssertTrue ( job. commandLine. contains ( . path( . absolute( try driver. toolchain. executableDir. parentDirectory. appending ( components: " local " , " lib " , " swift " , " host " , " plugins " ) ) ) ) )
0 commit comments