@@ -2833,12 +2833,28 @@ final class SwiftDriverTests: XCTestCase {
2833
2833
}
2834
2834
2835
2835
XCTAssertFalse ( job. commandLine. contains ( . flag( " -- " ) ) )
2836
- // On darwin, swift ships in the OS. Immediate mode should use that runtime.
2837
- #if os(macOS)
2838
- XCTAssertFalse ( job. extraEnvironment. keys. contains ( " \( driver. targetTriple. isDarwin ? " DYLD " : " LD " ) _LIBRARY_PATH " ) )
2839
- #else
2840
- XCTAssertTrue ( job. extraEnvironment. keys. contains ( " \( driver. targetTriple. isDarwin ? " DYLD " : " LD " ) _LIBRARY_PATH " ) )
2841
- #endif
2836
+
2837
+ let envVar : String
2838
+ if driver. targetTriple. isDarwin {
2839
+ envVar = " DYLD_LIBRARY_PATH "
2840
+ } else if driver. targetTriple. isWindows {
2841
+ envVar = " Path "
2842
+ } else {
2843
+ // assume Unix
2844
+ envVar = " LD_LIBRARY_PATH "
2845
+ }
2846
+
2847
+ // The library search path applies to import libraries not runtime
2848
+ // libraries on Windows. There is no way to derive the path from the
2849
+ // command on Windows.
2850
+ if !driver. targetTriple. isWindows {
2851
+ #if os(macOS)
2852
+ // On darwin, swift ships in the OS. Immediate mode should use that runtime.
2853
+ XCTAssertFalse ( job. extraEnvironment. keys. contains ( envVar) )
2854
+ #else
2855
+ XCTAssertTrue ( job. extraEnvironment. keys. contains ( envVar) )
2856
+ #endif
2857
+ }
2842
2858
}
2843
2859
2844
2860
do {
@@ -2869,11 +2885,25 @@ final class SwiftDriverTests: XCTestCase {
2869
2885
XCTAssertEqual ( job. inputs. count, 1 )
2870
2886
XCTAssertEqual ( job. inputs [ 0 ] . file, . relative( RelativePath ( " foo.swift " ) ) )
2871
2887
XCTAssertEqual ( job. outputs. count, 0 )
2872
- XCTAssertTrue ( job. extraEnvironment. contains {
2873
- $0 == " \( driver. targetTriple. isDarwin ? " DYLD " : " LD " ) _LIBRARY_PATH " && $1. contains ( " /path/to/lib " )
2874
- } )
2888
+
2889
+ let envVar : String
2875
2890
if driver. targetTriple. isDarwin {
2876
- XCTAssertTrue ( job. extraEnvironment. contains { $0 == " DYLD_FRAMEWORK_PATH " && $1. contains ( " /path/to/framework " ) } )
2891
+ envVar = " DYLD_LIBRARY_PATH "
2892
+ } else if driver. targetTriple. isWindows {
2893
+ envVar = " Path "
2894
+ } else {
2895
+ // assume Unix
2896
+ envVar = " LD_LIBRARY_PATH "
2897
+ }
2898
+
2899
+ // The library search path applies to import libraries not runtime
2900
+ // libraries on Windows. There is no way to derive the path from the
2901
+ // command on Windows.
2902
+ if !driver. targetTriple. isWindows {
2903
+ XCTAssertTrue ( job. extraEnvironment [ envVar, default: " " ] . contains ( " /path/to/lib " ) )
2904
+ if driver. targetTriple. isDarwin {
2905
+ XCTAssertTrue ( job. extraEnvironment [ " DYLD_FRAMEWORK_PATH " , default: " " ] . contains ( " /path/to/framework " ) )
2906
+ }
2877
2907
}
2878
2908
2879
2909
XCTAssertTrue ( job. commandLine. contains ( . flag( " -lsomelib " ) ) )
0 commit comments