@@ -163,8 +163,16 @@ if platform.system() == 'Darwin':
163
163
config .environment ['TOOLCHAINS' ] = \
164
164
os .environ .get ('TOOLCHAINS' , config .darwin_xcrun_toolchain )
165
165
166
+ # NOTE: this mirrors the kIsWindows from lit.lit.TestRunner in LLVM
167
+ kIsWindows = platform .system () == 'Windows'
168
+
166
169
# testFormat: The test format to use to interpret tests.
167
- config .test_format = swift_test .SwiftTest (coverage_mode = config .coverage_mode )
170
+
171
+ # Choose between lit's internal shell pipeline runner and a real shell. If
172
+ # LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
173
+ use_lit_shell = os .environ .get ('LIT_USE_INTERNAL_SHELL' , not kIsWindows )
174
+ config .test_format = swift_test .SwiftTest (coverage_mode = config .coverage_mode ,
175
+ execute_external = use_lit_shell )
168
176
169
177
# suffixes: A list of file extensions to treat as test files.
170
178
config .suffixes = ['.swift' , '.ll' , '.sil' , '.gyb' , '.m' , '.swiftinterface' ,
@@ -288,6 +296,9 @@ config.PathSanitizingFileCheck = make_path(config.swift_utils, 'PathSanitizingFi
288
296
config .swift_lib_dir = make_path (config .swift , '..' , '..' , 'lib' )
289
297
config .round_trip_syntax_test = make_path (config .swift_utils , 'round-trip-syntax-test' )
290
298
299
+ config .link = lit .util .which ('link' , config .environment .get ('PATH' , '' )) or \
300
+ lit .util .which ('lld-link' , config .environment .get ('PATH' , '' ))
301
+
291
302
# Find the resource directory. Assume it's near the swift compiler if not set.
292
303
test_resource_dir = lit_config .params .get ('test_resource_dir' )
293
304
if test_resource_dir :
@@ -786,6 +797,63 @@ if run_vendor == 'apple':
786
797
"-Xlinker -install_name -Xlinker @executable_path/$(basename '\\ 1')"
787
798
% (config .target_build_swift ))
788
799
800
+ elif run_os in ['windows-msvc' ]:
801
+ lit_config .note ('Testing Windows ' + config .variant_triple )
802
+ config .target_object_format = 'coff'
803
+ config .target_dylib_extension = 'dll'
804
+ config .target_sdk_name = 'windows'
805
+ config .target_runtime = 'native'
806
+ config .target_swiftmodule_name = run_cpu + '.swiftmodule'
807
+ config .target_swiftdoc_name = run_cpu + '.swiftdoc'
808
+
809
+ config .target_build_swift = \
810
+ ('%r -target %s %s %s %s %s %s' % (config .swiftc , \
811
+ config .variant_triple , \
812
+ resource_dir_opt , mcp_opt , \
813
+ config .swift_test_options , \
814
+ config .swift_driver_test_options , \
815
+ swift_execution_tests_extra_flags ))
816
+
817
+ config .target_run = ''
818
+
819
+ config .target_swift_frontend = \
820
+ ('%r -frontend -target %s %s %s %s %s' % (config .swiftc , \
821
+ config .variant_triple , \
822
+ resource_dir_opt , mcp_opt , \
823
+ config .swift_test_options , \
824
+ config .swift_frontend_test_options ))
825
+
826
+ config .target_codesign = ''
827
+
828
+ subst_target_swift_frontend_mock_sdk = config .target_swift_frontend
829
+ subst_target_swift_frontend_mock_sdk_after = ''
830
+
831
+ config .target_build_swift_dylib = \
832
+ ("%r -parse-as-library -emit-librar -o '\\ 1'" % (config .target_build_swift ))
833
+ config .target_clang = \
834
+ ('clang++ -target %s %s' % (config .variant_triple , clang_mcp_opt ))
835
+ config .target_ld = \
836
+ ('%r -libpath:%s' % (config .link , os .path .join (test_resource_dir , \
837
+ config .target_sdk_name )))
838
+ config .target_sil_opt = \
839
+ ('%r -target %s %s %s %s' % (config .sil_opt , config .variant_triple , \
840
+ resource_dir_opt , mcp_opt , \
841
+ config .sil_test_options ))
842
+ config .target_swift_ide_test = \
843
+ ('%r -target %s %s %s %s' % (config .swift_ide_test , \
844
+ config .variant_triple , \
845
+ resource_dir_opt , pcp_opt , ccp_opt ))
846
+
847
+ subst_target_swift_ide_test_mock_sdk = config .target_swift_ide_test
848
+ subst_target_swift_ide_test_mock_sdk_after = ''
849
+
850
+ config .target_swiftc_driver = \
851
+ ('%r -target %s %s %s' % (config .swiftc , config .variant_triple , \
852
+ resource_dir_opt , mcp_opt ))
853
+ config .target_swift_modulewrap = \
854
+ ('%r -modulewrap -target %s' % (config .swiftc , config .variant_triple ))
855
+
856
+
789
857
elif run_os in ['linux-gnu' , 'linux-gnueabihf' , 'freebsd' , 'windows-cygnus' , 'windows-gnu' ]:
790
858
# Linux/FreeBSD/Cygwin
791
859
if run_os == 'windows-cygnus' :
@@ -1167,17 +1235,18 @@ config.substitutions.append(('%target-runtime', config.target_runtime))
1167
1235
1168
1236
config .substitutions .append (('%target-typecheck-verify-swift' , config .target_parse_verify_swift ))
1169
1237
1170
- config .substitutions .append (('%target-swift-emit-silgen\(mock-sdk:([^)]+)\)' , '%target-swift-frontend(mock-sdk:\\ 1) -emit-silgen -verify-syntax-tree -enable-sil-ownership' ))
1238
+ config .substitutions .append (('%target-swift-emit-silgen\(mock-sdk:([^)]+)\)' ,
1239
+ SubstituteCaptures (r'%target-swift-frontend(mock-sdk:\1) -emit-silgen -verify-syntax-tree -enable-sil-ownership' )))
1171
1240
config .substitutions .append (('%target-swift-emit-silgen' , '%target-swift-frontend -emit-silgen -verify-syntax-tree -enable-sil-ownership' ))
1172
- config .substitutions .append (('%target-swift-emit-sil\(mock-sdk:([^)]+)\)' , '%target-swift-frontend(mock-sdk:\\ 1) -emit-sil -verify-syntax-tree' ))
1241
+ config .substitutions .append (('%target-swift-emit-sil\(mock-sdk:([^)]+)\)' ,
1242
+ SubstituteCaptures (r'%target-swift-frontend(mock-sdk:\1) -emit-sil -verify-syntax-tree' )))
1173
1243
config .substitutions .append (('%target-swift-emit-sil' , '%target-swift-frontend -emit-sil -verify-syntax-tree' ))
1174
- config .substitutions .append (('%target-swift-emit-ir\(mock-sdk:([^)]+)\)' , '%target-swift-frontend(mock-sdk:\\ 1) -emit-ir -verify-syntax-tree' ))
1244
+ config .substitutions .append (('%target-swift-emit-ir\(mock-sdk:([^)]+)\)' ,
1245
+ SubstituteCaptures (r'%target-swift-frontend(mock-sdk:\1) -emit-ir -verify-syntax-tree' )))
1175
1246
config .substitutions .append (('%target-swift-emit-ir' , '%target-swift-frontend -emit-ir -verify-syntax-tree' ))
1176
- config .substitutions .append (
1177
- ('%target-swift-frontend\(mock-sdk:([^)]+)\)' ,
1178
- '%s \\ 1 %s' %
1179
- (subst_target_swift_frontend_mock_sdk ,
1180
- subst_target_swift_frontend_mock_sdk_after )))
1247
+ config .substitutions .append (('%target-swift-frontend\(mock-sdk:([^)]+)\)' ,
1248
+ SubstituteCaptures (r'%s \1 %s' % (subst_target_swift_frontend_mock_sdk ,
1249
+ subst_target_swift_frontend_mock_sdk_after ))))
1181
1250
config .substitutions .append (('%target-swift-frontend' , config .target_swift_frontend ))
1182
1251
1183
1252
@@ -1202,27 +1271,25 @@ config.substitutions.append(
1202
1271
r'ln \1 \2 || cp \1 \2' ))
1203
1272
1204
1273
config .substitutions .append (('%utils' , config .swift_utils ))
1205
- config .substitutions .append (('%line-directive' , config .line_directive ))
1206
- config .substitutions .append (('%gyb' , config .gyb ))
1274
+ config .substitutions .append (('%line-directive' , '%r %s' % ( sys . executable , config .line_directive ) ))
1275
+ config .substitutions .append (('%gyb' , '%r %s' % ( sys . executable , config .gyb ) ))
1207
1276
config .substitutions .append (('%round-trip-syntax-test' , config .round_trip_syntax_test ))
1208
1277
config .substitutions .append (('%rth' , config .rth ))
1209
1278
config .substitutions .append (('%scale-test' ,
1210
1279
'{} --swiftc-binary={} --tmpdir=%t' .format (
1211
1280
config .scale_test , config .swiftc )))
1212
- config .substitutions .append (
1213
- ( '%empty-directory\(([^)]+)\)' , ' rm -rf \" \\ 1 \ " && mkdir -p \" \\ 1 \" ' ))
1281
+ config .substitutions .append (( '%empty-directory\(([^)]+)\)' ,
1282
+ SubstituteCaptures ( r' rm -rf "\1 " && mkdir -p "\1"' ) ))
1214
1283
1215
1284
config .substitutions .append (('%target-sil-opt' , config .target_sil_opt ))
1216
1285
config .substitutions .append (('%target-sil-func-extractor' , config .target_sil_func_extractor ))
1217
1286
config .substitutions .append (('%target-sil-llvm-gen' , config .target_sil_llvm_gen ))
1218
1287
config .substitutions .append (('%target-sil-nm' , config .target_sil_nm ))
1219
1288
1220
- config .substitutions .append (
1221
- ('%target-swift-ide-test\(mock-sdk:([^)]+)\)' ,
1222
- '%s \\ 1 %s -swift-version %s' %
1223
- (subst_target_swift_ide_test_mock_sdk ,
1224
- subst_target_swift_ide_test_mock_sdk_after ,
1225
- swift_version )))
1289
+ config .substitutions .append (('%target-swift-ide-test\(mock-sdk:([^)]+)\)' ,
1290
+ SubstituteCaptures (r'%s \1 %s -swift-version %s' % (subst_target_swift_ide_test_mock_sdk ,
1291
+ subst_target_swift_ide_test_mock_sdk_after ,
1292
+ swift_version ))))
1226
1293
config .substitutions .append (('%target-swift-ide-test' , "%s -swift-version %s" % (config .target_swift_ide_test , swift_version )))
1227
1294
1228
1295
if not hasattr (config , 'target_swift_reflection_test' ):
@@ -1267,13 +1334,12 @@ config.substitutions.append(('%target-resilience-test', config.target_resilience
1267
1334
config .substitutions .append (('%llvm-profdata' , config .llvm_profdata ))
1268
1335
config .substitutions .append (('%llvm-cov' , config .llvm_cov ))
1269
1336
1270
- config .substitutions .append (
1271
- ('%FileCheck' ,
1272
- '%s --sanitize \' BUILD_DIR=%s\' --sanitize \' SOURCE_DIR=%s\' --use-filecheck \' %s\' ' %
1273
- (config .PathSanitizingFileCheck ,
1274
- pipes .quote (swift_obj_root ),
1275
- pipes .quote (config .swift_src_root ),
1276
- pipes .quote (config .filecheck ))))
1337
+ config .substitutions .append (('%FileCheck' ,
1338
+ '%r %r --sanitize BUILD_DIR=%r --sanitize SOURCE_DIR=%r --use-filecheck %r' % (sys .executable ,
1339
+ config .PathSanitizingFileCheck ,
1340
+ swift_obj_root ,
1341
+ config .swift_src_root ,
1342
+ config .filecheck )))
1277
1343
config .substitutions .append (('%raw-FileCheck' , pipes .quote (config .filecheck )))
1278
1344
1279
1345
# If static stdlib is present, enable static stdlib tests
0 commit comments