@@ -161,8 +161,16 @@ if platform.system() == 'Darwin':
161
161
config .environment ['TOOLCHAINS' ] = \
162
162
os .environ .get ('TOOLCHAINS' , config .darwin_xcrun_toolchain )
163
163
164
+ # NOTE: this mirrors the kIsWindows from lit.lit.TestRunner in LLVM
165
+ kIsWindows = platform .system () == 'Windows'
166
+
164
167
# testFormat: The test format to use to interpret tests.
165
- config .test_format = swift_test .SwiftTest (coverage_mode = config .coverage_mode )
168
+
169
+ # Choose between list's internal shell pipeline runner and a real shell. If
170
+ # LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
171
+ use_lit_shell = os .environ .get ('LIT_USE_INTERNAL_SHELL' , not kIsWindows )
172
+ config .test_format = swift_test .SwiftTest (coverage_mode = config .coverage_mode ,
173
+ execute_external = use_lit_shell )
166
174
167
175
# suffixes: A list of file extensions to treat as test files.
168
176
config .suffixes = ['.swift' , '.ll' , '.sil' , '.gyb' , '.m' , '.test-sh' ]
@@ -281,6 +289,9 @@ config.PathSanitizingFileCheck = make_path(config.swift_utils, 'PathSanitizingFi
281
289
config .swift_lib_dir = make_path (config .swift , '..' , '..' , 'lib' )
282
290
config .round_trip_syntax_test = make_path (config .swift_utils , 'round-trip-syntax-test' )
283
291
292
+ config .link = lit .util .which ('link' , config .environment ['PATH' ]) or \
293
+ lit .util .which ('lld-link' , config .environment ['PATH' ])
294
+
284
295
# Find the resource directory. Assume it's near the swift compiler if not set.
285
296
test_resource_dir = lit_config .params .get ('test_resource_dir' )
286
297
if test_resource_dir :
@@ -694,7 +705,7 @@ if run_vendor == 'apple':
694
705
config .target_run_simple_swift = (
695
706
"%s %%s" % (target_run_base ))
696
707
config .target_run_simple_swiftgyb = (
697
- 'rm -rf %%t && mkdir -p %%t && '
708
+ '%%empty-directory( %%t) && '
698
709
'%%gyb %%s -o %%t/main.swift && '
699
710
'%%line-directive %%t/main.swift -- %s %%t/main.swift'
700
711
% (target_run_base ))
@@ -757,6 +768,55 @@ if run_vendor == 'apple':
757
768
"-Xlinker -install_name -Xlinker @executable_path/$(basename '\\ 1')"
758
769
% (config .target_build_swift ))
759
770
771
+ elif run_os in ['windows-msvc' ]:
772
+ lit_config .note ('Testing Windows ' + config .variant_triple )
773
+ config .target_object_format = 'coff'
774
+ config .target_dylib_extension = 'dll'
775
+ config .target_sdk_name = 'windows'
776
+ config .target_runtime = 'native'
777
+ config .target_swiftmodule_name = run_cpu + '.swiftmodule'
778
+ config .target_swiftdoc_name = run_cpu + '.swiftdoc'
779
+
780
+ config .target_build_swift = \
781
+ ('%r -target %s %s %s %s %s %s' % (config .swiftc , \
782
+ config .variant_triple , \
783
+ resource_dir_opt , mcp_opt , \
784
+ config .swift_test_options , \
785
+ config .swift_driver_test_options , \
786
+ swift_execution_tests_extra_flags ))
787
+ config .target_run = ''
788
+ config .target_swift_frontend = \
789
+ ('%r -frontend -target %s %s %s %s %s' % (config .swiftc , \
790
+ config .variant_triple , \
791
+ resource_dir_opt , mcp_opt , \
792
+ config .swift_test_options , \
793
+ config .swift_frontend_test_options ))
794
+ config .target_codesign = ''
795
+ subst_target_swift_frontend_mock_sdk = config .target_swift_frontend
796
+ subst_target_swift_frontend_mock_sdk_after = ''
797
+ config .target_build_swift_dylib = \
798
+ ("%r -parse-as-library -emit-library -o '\\ 1'" % (config .target_build_swift ))
799
+ config .target_clang = \
800
+ ('clang++ -target %s %s' % (config .variant_triple , clang_mcp_opt ))
801
+ config .target_ld = \
802
+ ('%r -libpath:%s' % (config .link , os .path .join (test_resource_dir , \
803
+ config .target_sdk_name )))
804
+ config .target_sil_opt = \
805
+ ('%r -target %s %s %s %s' % (config .sil_opt , config .variant_triple , \
806
+ resource_dir_opt , mcp_opt , \
807
+ config .sil_test_options ))
808
+ config .target_swift_ide_test = \
809
+ ('%r -target %s %s %s %s' % (config .swift_ide_test , \
810
+ config .variant_triple , \
811
+ resource_dir_opt , mcp_opt , ccp_opt ))
812
+ subst_target_swift_ide_test_mock_sdk = config .target_swift_ide_test
813
+ subst_target_swift_ide_test_mock_sdk_after = ''
814
+ config .target_swiftc_driver = \
815
+ ('%r -target %s %s %s' % (config .swiftc , config .variant_triple , \
816
+ resource_dir_opt , mcp_opt ))
817
+ config .target_swift_modulewrap = \
818
+ ('%r -modulewrap -target %s' % (config .swiftc , config .variant_triple ))
819
+
760
820
elif run_os in ['linux-gnu' , 'linux-gnueabihf' , 'freebsd' , 'windows-cygnus' , 'windows-gnu' ]:
761
821
# Linux/FreeBSD/Cygwin
762
822
if run_os == 'windows-cygnus' :
@@ -1041,11 +1101,9 @@ config.substitutions.append(('%target-runtime', config.target_runtime))
1041
1101
1042
1102
config .substitutions .append (('%target-typecheck-verify-swift' , config .target_parse_verify_swift ))
1043
1103
1044
- config .substitutions .append (
1045
- ('%target-swift-frontend\(mock-sdk:([^)]+)\)' ,
1046
- '%s \\ 1 %s' %
1047
- (subst_target_swift_frontend_mock_sdk ,
1048
- subst_target_swift_frontend_mock_sdk_after )))
1104
+ config .substitutions .append (('%target-swift-frontend\(mock-sdk:([^)]+)\)' ,
1105
+ SubstituteCaptures (r'%s \1 %s' % (subst_target_swift_frontend_mock_sdk ,
1106
+ subst_target_swift_frontend_mock_sdk_after ))))
1049
1107
config .substitutions .append (('%target-swift-frontend' , config .target_swift_frontend ))
1050
1108
1051
1109
@@ -1070,25 +1128,23 @@ config.substitutions.append(
1070
1128
1071
1129
config .substitutions .append (('%utils' , config .swift_utils ))
1072
1130
config .substitutions .append (('%line-directive' , config .line_directive ))
1073
- config .substitutions .append (('%gyb' , config .gyb ))
1131
+ config .substitutions .append (('%gyb' , '%r %s' % ( sys . executable , config .gyb ) ))
1074
1132
config .substitutions .append (('%round-trip-syntax-test' , config .round_trip_syntax_test ))
1075
1133
config .substitutions .append (('%rth' , config .rth ))
1076
1134
config .substitutions .append (('%scale-test' ,
1077
1135
'{} --swiftc-binary={} --tmpdir=%t' .format (
1078
1136
config .scale_test , config .swiftc )))
1079
- config .substitutions .append (
1080
- ( '%empty-directory\(([^)]+)\)' , ' rm -rf \" \\ 1 \ " && mkdir -p \" \\ 1 \" ' ))
1137
+ config .substitutions .append (( '%empty-directory\(([^)]+)\)' ,
1138
+ SubstituteCaptures ( r' rm -rf "\1 " && mkdir -p "\1"' ) ))
1081
1139
1082
1140
config .substitutions .append (('%target-sil-opt' , config .target_sil_opt ))
1083
1141
config .substitutions .append (('%target-sil-func-extractor' , config .target_sil_func_extractor ))
1084
1142
config .substitutions .append (('%target-sil-llvm-gen' , config .target_sil_llvm_gen ))
1085
1143
config .substitutions .append (('%target-sil-nm' , config .target_sil_nm ))
1086
- config .substitutions .append (
1087
- ('%target-swift-ide-test\(mock-sdk:([^)]+)\)' ,
1088
- '%s \\ 1 %s -swift-version %s' %
1089
- (subst_target_swift_ide_test_mock_sdk ,
1090
- subst_target_swift_ide_test_mock_sdk_after ,
1091
- swift_version )))
1144
+ config .substitutions .append (('%target-swift-ide-test\(mock-sdk:([^)]+)\)' ,
1145
+ SubstituteCaptures (r'%s \1 %s -swift-version %s' % (subst_target_swift_ide_test_mock_sdk ,
1146
+ subst_target_swift_ide_test_mock_sdk_after ,
1147
+ swift_version ))))
1092
1148
config .substitutions .append (('%target-swift-ide-test' , "%s -swift-version %s" % (config .target_swift_ide_test , swift_version )))
1093
1149
config .substitutions .append (('%target-swift-reflection-test' , lit .util .which ('swift-reflection-test{variant_suffix}' .format (variant_suffix = config .variant_suffix ), config .environment ['PATH' ])))
1094
1150
config .substitutions .append (('%target-swift-reflection-dump' , '{} {} {}' .format (config .swift_reflection_dump , '-arch' , run_cpu )))
@@ -1128,13 +1184,12 @@ config.substitutions.append(('%target-resilience-test', config.target_resilience
1128
1184
config .substitutions .append (('%llvm-profdata' , config .llvm_profdata ))
1129
1185
config .substitutions .append (('%llvm-cov' , config .llvm_cov ))
1130
1186
1131
- config .substitutions .append (
1132
- ('%FileCheck' ,
1133
- '%s --sanitize \' BUILD_DIR=%s\' --sanitize \' SOURCE_DIR=%s\' --use-filecheck \' %s\' ' %
1134
- (config .PathSanitizingFileCheck ,
1135
- pipes .quote (swift_obj_root ),
1136
- pipes .quote (config .swift_src_root ),
1137
- pipes .quote (config .filecheck ))))
1187
+ config .substitutions .append (('%FileCheck' ,
1188
+ '%r %r --sanitize BUILD_DIR=%r --sanitize SOURCE_DIR=%r --use-filecheck %r' % (sys .executable ,
1189
+ config .PathSanitizingFileCheck ,
1190
+ swift_obj_root ,
1191
+ config .swift_src_root ,
1192
+ config .filecheck )))
1138
1193
config .substitutions .append (('%raw-FileCheck' , pipes .quote (config .filecheck )))
1139
1194
1140
1195
# If static stdlib is present, enable static stdlib tests
0 commit comments