@@ -176,51 +176,129 @@ set(SWIFT_LIT_ARGS "" CACHE STRING "Arguments to pass to lit")
176
176
177
177
set (SWIFT_LIT_ENVIRONMENT "" CACHE STRING "Environment to use for lit invocations" )
178
178
179
- if (NOT SWIFT_INCLUDE_TOOLS )
180
- if (SWIFT_RUN_TESTS_WITH_HOST_COMPILER )
181
- precondition (CMAKE_Swift_COMPILER MESSAGE "Can only run tests if a Swift compiler is specified" )
182
- get_filename_component (SWIFT_COMPILER_DIR "${CMAKE_Swift_COMPILER} " DIRECTORY )
183
- precondition (SWIFT_COMPILER_DIR )
184
- # We assume that we are building against a toolchain where all tools are
185
- # next to swiftc.
186
- list (APPEND SWIFT_LIT_ARGS
187
- "--path=${SWIFT_COMPILER_DIR} " )
188
- else ()
189
- list (APPEND SWIFT_LIT_ARGS
190
- "--path=${SWIFT_NATIVE_LLVM_TOOLS_PATH} "
191
- "--param" "swift_native_llvm_tools_path=${SWIFT_NATIVE_LLVM_TOOLS_PATH} "
192
- "--path=${SWIFT_NATIVE_CLANG_TOOLS_PATH} "
193
- "--param" "swift_native_clang_tools_path=${SWIFT_NATIVE_CLANG_TOOLS_PATH} "
194
- "--path=${SWIFT_NATIVE_SWIFT_TOOLS_PATH} "
195
- "--param" "swift_native_swift_tools_path=${SWIFT_NATIVE_SWIFT_TOOLS_PATH} "
196
- )
197
- endif ()
198
- if (SWIFT_BUILD_STDLIB )
199
- # If building only static stdlib, use `swift_static` resources directory.
200
- if (NOT SWIFT_BUILD_DYNAMIC_STDLIB AND SWIFT_BUILD_STATIC_STDLIB )
201
- list (APPEND SWIFT_LIT_ARGS
202
- "--param" "test_resource_dir=${SWIFTSTATICLIB_DIR} " )
179
+ option (SWIFT_TEST_USE_LEAKS "Run Swift stdlib tests under leaks" FALSE )
180
+
181
+ function (setup_lit_args ARGS_VAR_OUT tested_sdk test_results_dir resource_dir_override )
182
+ set (swift_lit_args_result )
183
+
184
+ if (NOT SWIFT_INCLUDE_TOOLS )
185
+ if (SWIFT_RUN_TESTS_WITH_HOST_COMPILER )
186
+ precondition (CMAKE_Swift_COMPILER MESSAGE "Can only run tests if a Swift compiler is specified" )
187
+ get_filename_component (SWIFT_COMPILER_DIR "${CMAKE_Swift_COMPILER} " DIRECTORY )
188
+ precondition (SWIFT_COMPILER_DIR )
189
+ # We assume that we are building against a toolchain where all tools are
190
+ # next to swiftc.
191
+ list (APPEND swift_lit_args_result
192
+ "--path=${SWIFT_COMPILER_DIR} " )
203
193
else ()
204
- list (APPEND SWIFT_LIT_ARGS
205
- "--param" "test_resource_dir=${SWIFTLIB_DIR} " )
194
+ list (APPEND swift_lit_args_result
195
+ "--path=${SWIFT_NATIVE_LLVM_TOOLS_PATH} "
196
+ "--param" "swift_native_llvm_tools_path=${SWIFT_NATIVE_LLVM_TOOLS_PATH} "
197
+ "--path=${SWIFT_NATIVE_CLANG_TOOLS_PATH} "
198
+ "--param" "swift_native_clang_tools_path=${SWIFT_NATIVE_CLANG_TOOLS_PATH} "
199
+ "--path=${SWIFT_NATIVE_SWIFT_TOOLS_PATH} "
200
+ "--param" "swift_native_swift_tools_path=${SWIFT_NATIVE_SWIFT_TOOLS_PATH} "
201
+ )
202
+ endif ()
203
+ if (SWIFT_BUILD_STDLIB )
204
+ if (resource_dir_override )
205
+ list (APPEND swift_lit_args_result
206
+ "--param" "test_resource_dir=${resource_dir_override} " )
207
+ # If building only static stdlib, use `swift_static` resources directory.
208
+ elseif (NOT SWIFT_BUILD_DYNAMIC_STDLIB AND SWIFT_BUILD_STATIC_STDLIB )
209
+ list (APPEND swift_lit_args_result
210
+ "--param" "test_resource_dir=${SWIFTSTATICLIB_DIR} " )
211
+ else ()
212
+ list (APPEND swift_lit_args_result
213
+ "--param" "test_resource_dir=${SWIFTLIB_DIR} " )
214
+ endif ()
206
215
endif ()
207
216
endif ()
208
- endif ()
209
217
210
- option (SWIFT_TEST_USE_LEAKS "Run Swift stdlib tests under leaks" FALSE )
211
- if (SWIFT_TEST_USE_LEAKS )
212
- list (APPEND SWIFT_LIT_ARGS "--param" "leaks-all" )
213
- endif ()
218
+ if (SWIFT_TEST_USE_LEAKS )
219
+ list (APPEND swift_lit_args_result "--param" "leaks-all" )
220
+ endif ()
214
221
215
- if (SWIFT_ENABLE_ARRAY_COW_CHECKS )
216
- list (APPEND SWIFT_LIT_ARGS
217
- "--param" "array_cow_checks" )
218
- endif ()
222
+ if (SWIFT_ENABLE_ARRAY_COW_CHECKS )
223
+ list (APPEND swift_lit_args_result
224
+ "--param" "array_cow_checks" )
225
+ endif ()
219
226
220
- if (NOT CMAKE_CFG_INTDIR STREQUAL "." )
221
- list (APPEND SWIFT_LIT_ARGS
222
- "--param" "build_mode=${CMAKE_CFG_INTDIR} " )
223
- endif ()
227
+ if (NOT CMAKE_CFG_INTDIR STREQUAL "." )
228
+ list (APPEND swift_lit_args_result
229
+ "--param" "build_mode=${CMAKE_CFG_INTDIR} " )
230
+ endif ()
231
+
232
+ if (SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING )
233
+ list (APPEND swift_lit_args_result "--param" "differentiable_programming" )
234
+ endif ()
235
+
236
+ if (SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY )
237
+ list (APPEND swift_lit_args_result "--param" "concurrency" )
238
+ endif ()
239
+
240
+ if (SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED )
241
+ list (APPEND swift_lit_args_result "--param" "distributed" )
242
+ endif ()
243
+
244
+ if (SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING )
245
+ list (APPEND swift_lit_args_result "--param" "string_processing" )
246
+ endif ()
247
+
248
+ if (SWIFT_ENABLE_BACKTRACING )
249
+ list (APPEND swift_lit_args_result "--param" "backtracing" )
250
+ endif ()
251
+
252
+ if (SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION )
253
+ list (APPEND swift_lit_args_result "--param" "observation" )
254
+ endif ()
255
+
256
+ if (SWIFT_ENABLE_SYNCHRONIZATION )
257
+ list (APPEND swift_lit_args_result "--param" "synchronization" )
258
+ endif ()
259
+
260
+ if (SWIFT_ENABLE_VOLATILE )
261
+ list (APPEND swift_lit_args_result "--param" "volatile" )
262
+ endif ()
263
+
264
+ if (SWIFT_ENABLE_RUNTIME_MODULE )
265
+ list (APPEND swift_lit_args_result "--param" "runtime_module" )
266
+ endif ()
267
+
268
+ if (SWIFT_BUILD_REMOTE_MIRROR )
269
+ list (APPEND swift_lit_args_result "--param" "remote_mirror" )
270
+ endif ()
271
+
272
+ list (APPEND swift_lit_args_result "--param" "threading=${SWIFT_SDK_${tested_sdk} _THREADING_PACKAGE}" )
273
+
274
+ # Enable on-crash backtracing if supported
275
+ if (("${tested_sdk} " STREQUAL "OSX" OR "${tested_sdk} " STREQUAL "LINUX" )
276
+ AND NOT SWIFT_ASAN_BUILD )
277
+ list (APPEND swift_lit_args_result "--param" "backtrace_on_crash" )
278
+ endif ()
279
+
280
+ execute_process (COMMAND
281
+ $< TARGET_FILE:Python3::Interpreter> "-c" "import psutil"
282
+ RESULT_VARIABLE python_psutil_status
283
+ TIMEOUT 1 # second
284
+ ERROR_QUIET )
285
+ if (NOT python_psutil_status )
286
+ list (APPEND swift_lit_args_result "--timeout=3000" ) # 50 minutes
287
+ endif ()
288
+
289
+ list (APPEND swift_lit_args_result "--xunit-xml-output=${test_results_dir} /lit-tests.xml" )
290
+
291
+ if (NOT SWIFT_BUILD_STDLIB AND NOT SWIFT_PATH_TO_EXTERNAL_STDLIB_BUILD )
292
+ list (APPEND swift_lit_args_result
293
+ "--param" "test_sdk_overlay_dir=${SWIFTLIB_DIR} /${SWIFT_SDK_${tested_sdk} _LIB_SUBDIR}" )
294
+ endif ()
295
+
296
+
297
+ set (LIT_ARGS "${swift_lit_args_result} ${SWIFT_LIT_ARGS} ${LLVM_LIT_ARGS} " )
298
+ separate_arguments (swift_lit_args_result )
299
+
300
+ set (${ARGS_VAR_OUT} ${swift_lit_args_result} PARENT_SCOPE )
301
+ endfunction ()
224
302
225
303
if (LLVM_USE_SANITIZER STREQUAL "Address" )
226
304
set (SWIFT_ASAN_BUILD TRUE )
@@ -425,73 +503,6 @@ foreach(SDK ${SWIFT_SDKS})
425
503
COMMENT "Uploading stdlib" )
426
504
427
505
foreach (test_mode ${TEST_MODES} )
428
- set (LIT_ARGS "${SWIFT_LIT_ARGS} ${LLVM_LIT_ARGS} " )
429
- separate_arguments (LIT_ARGS )
430
-
431
- if (NOT SWIFT_BUILD_STDLIB AND NOT SWIFT_PATH_TO_EXTERNAL_STDLIB_BUILD )
432
- list (APPEND LIT_ARGS
433
- "--param" "test_sdk_overlay_dir=${SWIFTLIB_DIR} /${SWIFT_SDK_${SDK} _LIB_SUBDIR}" )
434
- endif ()
435
-
436
- execute_process (COMMAND
437
- $< TARGET_FILE:Python3::Interpreter> "-c" "import psutil"
438
- RESULT_VARIABLE python_psutil_status
439
- TIMEOUT 1 # second
440
- ERROR_QUIET )
441
- if (NOT python_psutil_status )
442
- list (APPEND LIT_ARGS "--timeout=3000" ) # 50 minutes
443
- endif ()
444
-
445
- list (APPEND LIT_ARGS "--xunit-xml-output=${SWIFT_TEST_RESULTS_DIR} /lit-tests.xml" )
446
-
447
- if (SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING )
448
- list (APPEND LIT_ARGS "--param" "differentiable_programming" )
449
- endif ()
450
-
451
- if (SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY )
452
- list (APPEND LIT_ARGS "--param" "concurrency" )
453
- endif ()
454
-
455
- if (SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED )
456
- list (APPEND LIT_ARGS "--param" "distributed" )
457
- endif ()
458
-
459
- if (SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING )
460
- list (APPEND LIT_ARGS "--param" "string_processing" )
461
- endif ()
462
-
463
- if (SWIFT_ENABLE_BACKTRACING )
464
- list (APPEND LIT_ARGS "--param" "backtracing" )
465
- endif ()
466
-
467
- if (SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION )
468
- list (APPEND LIT_ARGS "--param" "observation" )
469
- endif ()
470
-
471
- if (SWIFT_ENABLE_SYNCHRONIZATION )
472
- list (APPEND LIT_ARGS "--param" "synchronization" )
473
- endif ()
474
-
475
- if (SWIFT_ENABLE_VOLATILE )
476
- list (APPEND LIT_ARGS "--param" "volatile" )
477
- endif ()
478
-
479
- if (SWIFT_ENABLE_RUNTIME_MODULE )
480
- list (APPEND LIT_ARGS "--param" "runtime_module" )
481
- endif ()
482
-
483
- if (SWIFT_BUILD_REMOTE_MIRROR )
484
- list (APPEND LIT_ARGS "--param" "remote_mirror" )
485
- endif ()
486
-
487
- list (APPEND LIT_ARGS "--param" "threading=${SWIFT_SDK_${SDK} _THREADING_PACKAGE}" )
488
-
489
- # Enable on-crash backtracing if supported
490
- if (("${SDK} " STREQUAL "OSX" OR "${SDK} " STREQUAL "LINUX" )
491
- AND NOT SWIFT_ASAN_BUILD )
492
- list (APPEND LIT_ARGS "--param" "backtrace_on_crash" )
493
- endif ()
494
-
495
506
foreach (test_subset ${TEST_SUBSETS} )
496
507
set (directories )
497
508
set (dependencies ${test_dependencies} )
@@ -531,6 +542,8 @@ foreach(SDK ${SWIFT_SDKS})
531
542
set (maybe_command_upload_stdlib ${command_upload_stdlib} )
532
543
endif ()
533
544
545
+ setup_lit_args (final_lit_args "${SDK} " "${SWIFT_TEST_RESULTS_DIR} " OFF )
546
+
534
547
set (test_target_name
535
548
"check-swift${test_subset_target_suffix}${test_mode_target_suffix}${VARIANT_SUFFIX} " )
536
549
add_custom_target ("${test_target_name} "
@@ -540,7 +553,7 @@ foreach(SDK ${SWIFT_SDKS})
540
553
COMMAND
541
554
${CMAKE_COMMAND} -E env ${SWIFT_LIT_ENVIRONMENT}
542
555
$< TARGET_FILE:Python3::Interpreter> "${LIT} "
543
- ${LIT_ARGS }
556
+ ${final_lit_args }
544
557
"--param" "swift_test_subset=${test_subset} "
545
558
"--param" "swift_test_mode=${test_mode} "
546
559
${directories}
@@ -560,7 +573,7 @@ foreach(SDK ${SWIFT_SDKS})
560
573
COMMAND
561
574
${CMAKE_COMMAND} -E env ${SWIFT_LIT_ENVIRONMENT}
562
575
$< TARGET_FILE:Python3::Interpreter> "${LIT} "
563
- ${LIT_ARGS }
576
+ ${final_lit_args }
564
577
"--param" "swift_test_subset=${test_subset} "
565
578
"--param" "swift_test_mode=${test_mode} "
566
579
${SWIFT_LIT_TEST_PATHS}
@@ -622,7 +635,6 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING)
622
635
"${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX} /lit.site.cfg"
623
636
"test${VARIANT_SUFFIX} .lit.site.cfg" )
624
637
swift_generate_lit_swift_features_cfg ("${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX} /lit.swift-features.cfg" )
625
- message (STATUS "SWIFT_LIT_ARGS is ${SWIFT_LIT_ARGS} " )
626
638
endif ()
627
639
628
640
# Add shortcuts for the default variant.
0 commit comments