@@ -6757,14 +6757,64 @@ final class SwiftDriverTests: XCTestCase {
6757
6757
}
6758
6758
6759
6759
func testPluginPaths( ) throws {
6760
- var driver = try Driver ( args: [ " swiftc " , " -typecheck " , " foo.swift " ] )
6761
- guard driver. isFrontendArgSupported ( . pluginPath) else {
6760
+ let sdkRoot = testInputsPath. appending ( component: " SDKChecks " ) . appending ( component: " iPhoneOS.sdk " )
6761
+ 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 " ] )
6762
+ guard driver. isFrontendArgSupported ( . pluginPath) && driver. isFrontendArgSupported ( . externalPluginPath) else {
6762
6763
return
6763
6764
}
6764
6765
6765
6766
let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
6766
6767
XCTAssertEqual ( jobs. count, 1 )
6767
6768
let job = jobs. first!
6769
+
6770
+ // Check that the we have the plugin paths we expect, in the order we expect.
6771
+ let pluginAIndex = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginA " ) ) ) )
6772
+ XCTAssertNotNil ( pluginAIndex)
6773
+
6774
+ let pluginBIndex = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginB#Bexe " ) ) ) )
6775
+ XCTAssertNotNil ( pluginBIndex)
6776
+ XCTAssertLessThan ( pluginAIndex!, pluginBIndex!)
6777
+
6778
+ let pluginB2Index = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginB2 " ) ) ) )
6779
+ XCTAssertNotNil ( pluginB2Index)
6780
+ XCTAssertLessThan ( pluginBIndex!, pluginB2Index!)
6781
+
6782
+ let pluginCIndex = job. commandLine. firstIndex ( of: . path( VirtualPath . relative ( . init( " PluginC " ) ) ) )
6783
+ XCTAssertNotNil ( pluginCIndex)
6784
+ XCTAssertLessThan ( pluginB2Index!, pluginCIndex!)
6785
+
6786
+ #if os(macOS)
6787
+ XCTAssertTrue ( job. commandLine. contains ( . flag( " -external-plugin-path " ) ) )
6788
+ let sdkServerPath = sdkRoot. appending ( components: " usr " , " bin " , " swift-plugin-server " ) . pathString
6789
+ let sdkPluginPath = sdkRoot. appending ( components: " usr " , " lib " , " swift " , " host " , " plugins " ) . pathString
6790
+
6791
+ let sdkPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( sdkPluginPath) # \( sdkServerPath) " ) )
6792
+ XCTAssertNotNil ( sdkPluginPathIndex)
6793
+ XCTAssertLessThan ( pluginCIndex!, sdkPluginPathIndex!)
6794
+
6795
+ let sdkLocalPluginPath = sdkRoot. appending ( components: " usr " , " local " , " lib " , " swift " , " host " , " plugins " ) . pathString
6796
+ let sdkLocalPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( sdkLocalPluginPath) # \( sdkServerPath) " ) )
6797
+ XCTAssertNotNil ( sdkLocalPluginPathIndex)
6798
+ XCTAssertLessThan ( sdkPluginPathIndex!, sdkLocalPluginPathIndex!)
6799
+
6800
+ let platformPath = sdkRoot. parentDirectory. parentDirectory. parentDirectory. appending ( components: " Developer " , " usr " )
6801
+ let platformServerPath = platformPath. appending ( components: " bin " , " swift-plugin-server " ) . pathString
6802
+
6803
+ let platformPluginPath = platformPath. appending ( components: " lib " , " swift " , " host " , " plugins " )
6804
+ let platformPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( platformPluginPath) # \( platformServerPath) " ) )
6805
+ XCTAssertNotNil ( platformPluginPathIndex)
6806
+ XCTAssertLessThan ( sdkLocalPluginPathIndex!, platformPluginPathIndex!)
6807
+
6808
+ let platformLocalPluginPath = platformPath. appending ( components: " local " , " lib " , " swift " , " host " , " plugins " )
6809
+ let platformLocalPluginPathIndex = job. commandLine. firstIndex ( of: . flag( " \( platformLocalPluginPath) # \( platformServerPath) " ) )
6810
+ XCTAssertNotNil ( platformLocalPluginPathIndex)
6811
+ XCTAssertLessThan ( platformPluginPathIndex!, platformLocalPluginPathIndex!)
6812
+
6813
+ let toolchainPluginPathIndex = job. commandLine. firstIndex ( of: . path( . absolute( try driver. toolchain. executableDir. parentDirectory. appending ( components: " lib " , " swift " , " host " , " plugins " ) ) ) )
6814
+ XCTAssertNotNil ( toolchainPluginPathIndex)
6815
+ XCTAssertLessThan ( platformLocalPluginPathIndex!, toolchainPluginPathIndex!)
6816
+ #endif
6817
+
6768
6818
XCTAssertTrue ( job. commandLine. contains ( . flag( " -plugin-path " ) ) )
6769
6819
XCTAssertTrue ( job. commandLine. contains ( . path( . absolute( try driver. toolchain. executableDir. parentDirectory. appending ( components: " lib " , " swift " , " host " , " plugins " ) ) ) ) )
6770
6820
XCTAssertTrue ( job. commandLine. contains ( . path( . absolute( try driver. toolchain. executableDir. parentDirectory. appending ( components: " local " , " lib " , " swift " , " host " , " plugins " ) ) ) ) )
0 commit comments