Skip to content

Commit 9e8266a

Browse files
committed
Merge pull request #2909 from apple/cmake-test-refactor
2 parents f693c25 + a30f90c commit 9e8266a

24 files changed

+60
-66
lines changed

docs/Testing.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ The testsuite is split into three subsets:
4444

4545
* Long tests, which are marked with ``REQUIRES: long_test``.
4646

47+
Unlike other tests, every long test should also include either
48+
``REQUIRES: nonexecutable_test`` or ``REQUIRES: executable_test``.
49+
4750
Running the LLVM lit-based testsuite
4851
------------------------------------
4952

test/CMakeLists.txt

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,6 @@ if(PYTHONINTERP_FOUND)
203203
set(LIT_ARGS "${SWIFT_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
204204
separate_arguments(LIT_ARGS)
205205

206-
if(test_mode STREQUAL "optimize_none")
207-
# No special arguments required.
208-
elseif(test_mode STREQUAL "optimize")
209-
list(APPEND LIT_ARGS "--param" "run_only_tests=executable_tests")
210-
elseif(test_mode STREQUAL "optimize_unchecked")
211-
list(APPEND LIT_ARGS "--param" "run_only_tests=executable_tests")
212-
elseif(test_mode STREQUAL "only_executable")
213-
list(APPEND LIT_ARGS "--param" "run_only_tests=executable_tests")
214-
elseif(test_mode STREQUAL "only_non_executable")
215-
list(APPEND LIT_ARGS "--param" "run_only_tests=non_executable_tests")
216-
else()
217-
message(FATAL_ERROR "Unknown test mode: ${test_mode}")
218-
endif()
219-
220-
set(test_mode_target_suffix "")
221-
if(NOT test_mode STREQUAL "optimize_none")
222-
list(APPEND LIT_ARGS "--param" "swift_test_mode=${test_mode}")
223-
set(test_mode_target_suffix "-${test_mode}")
224-
endif()
225-
226206
if(NOT SWIFT_BUILD_STDLIB)
227207
list(APPEND LIT_ARGS
228208
"--param" "test_sdk_overlay_dir=${SWIFTLIB_DIR}/${SWIFT_SDK_${SDK}_LIB_SUBDIR}")
@@ -236,23 +216,6 @@ if(PYTHONINTERP_FOUND)
236216
endif()
237217

238218
foreach(test_subset ${TEST_SUBSETS})
239-
# We will add arguments specific for this subset to LIT_ARGS. Copy
240-
# the original value and restore it later.
241-
set(LIT_ARGS_COPY "${LIT_ARGS}")
242-
243-
set(want_this_combination TRUE)
244-
if(test_subset STREQUAL "only_long")
245-
# Long tests are only run in 'optimize_none' mode.
246-
if(NOT test_mode STREQUAL "optimize_none")
247-
set(want_this_combination FALSE)
248-
endif()
249-
250-
list(APPEND LIT_ARGS "--param" "run_only_tests=long_tests")
251-
endif()
252-
if(test_subset STREQUAL "all")
253-
list(APPEND LIT_ARGS "--param" "run_only_tests=all")
254-
endif()
255-
256219
set(directories)
257220
set(dependencies ${test_dependencies})
258221

@@ -275,18 +238,25 @@ if(PYTHONINTERP_FOUND)
275238
set(test_subset_target_suffix "")
276239
endif()
277240

278-
if(want_this_combination)
279-
add_custom_target("check-swift${test_subset_target_suffix}${test_mode_target_suffix}${VARIANT_SUFFIX}"
280-
${command_upload_stdlib}
281-
${command_clean_test_results_dir}
282-
${command_profdata_merge_start}
283-
COMMAND ${PYTHON_EXECUTABLE} "${LIT}" ${LIT_ARGS} ${directories}
284-
${command_profdata_merge_stop}
285-
DEPENDS ${dependencies}
286-
COMMENT "Running ${test_subset} Swift tests for ${VARIANT_TRIPLE}"
287-
${cmake_3_2_USES_TERMINAL})
241+
set(test_mode_target_suffix "")
242+
if(NOT test_mode STREQUAL "optimize_none")
243+
set(test_mode_target_suffix "-${test_mode}")
288244
endif()
289-
set(LIT_ARGS "${LIT_ARGS_COPY}")
245+
246+
add_custom_target("check-swift${test_subset_target_suffix}${test_mode_target_suffix}${VARIANT_SUFFIX}"
247+
${command_upload_stdlib}
248+
${command_clean_test_results_dir}
249+
${command_profdata_merge_start}
250+
COMMAND
251+
${PYTHON_EXECUTABLE} "${LIT}"
252+
${LIT_ARGS}
253+
"--param" "swift_test_subset=${test_subset}"
254+
"--param" "swift_test_mode=${test_mode}"
255+
${directories}
256+
${command_profdata_merge_stop}
257+
DEPENDS ${dependencies}
258+
COMMENT "Running ${test_subset} Swift tests for ${VARIANT_TRIPLE}"
259+
${cmake_3_2_USES_TERMINAL})
290260
endforeach()
291261
endforeach()
292262
endforeach()

test/IDE/print_stdlib.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Check interface produced for the standard library.
22
//
33
// REQUIRES: long_test
4+
// REQUIRES: nonexecutable_test
45
//
56
// RUN: %target-swift-frontend -parse %s
67
// RUN: %target-swift-ide-test -print-module -module-to-print=Swift -source-filename %s -print-interface > %t.txt

test/lit.cfg

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -441,49 +441,49 @@ if "optimized_stdlib" in config.available_features:
441441
swift_test_mode = lit_config.params.get('swift_test_mode', 'optimize_none')
442442
swift_execution_tests_extra_flags = ''
443443
if swift_test_mode == 'optimize_none':
444+
config.available_features.add("nonexecutable_test")
445+
config.available_features.add("executable_test")
444446
config.available_features.add("swift_test_mode_optimize_none")
445447
# Add the cpu as a feature so we can selectively disable tests in an
446448
# optimize mode for a cpu.
447449
config.available_features.add("swift_test_mode_optimize_none_" + run_cpu)
448450
swift_execution_tests_extra_flags = ''
449451
elif swift_test_mode == 'optimize':
452+
config.available_features.add("executable_test")
453+
config.limit_to_features.add("executable_test")
450454
config.available_features.add("swift_test_mode_optimize")
451455
# Add the cpu as a feature so we can selectively disable tests in an
452456
# optimize mode for a cpu.
453457
config.available_features.add("swift_test_mode_optimize_" + run_cpu)
454458
swift_execution_tests_extra_flags = '-O'
455459
elif swift_test_mode == 'optimize_unchecked':
460+
config.available_features.add("executable_test")
461+
config.limit_to_features.add("executable_test")
462+
config.available_features.add("swift_test_mode_optimize_unchecked")
456463
# Add the cpu as a feature so we can selectively disable tests in an
457464
# optimize mode for a cpu.
458465
config.available_features.add("swift_test_mode_optimize_unchecked_" + run_cpu)
459-
config.available_features.add("swift_test_mode_optimize_unchecked")
460466
swift_execution_tests_extra_flags = '-Ounchecked'
461467
elif swift_test_mode == 'only_executable':
462-
# No extra flags needed.
463-
pass
468+
config.available_features.add("executable_test")
469+
config.limit_to_features.add("executable_test")
464470
elif swift_test_mode == 'only_non_executable':
465-
# No extra flags needed.
466-
pass
471+
config.available_features.add("nonexecutable_test")
467472
else:
468473
lit_config.fatal("Unknown test mode %r" % swift_test_mode)
469474

470-
# Only run the subset of tests that require 'executable_test'?
471-
swift_run_only_tests = lit_config.params.get('run_only_tests', 'all_except_long')
472-
if swift_run_only_tests == 'all':
473-
config.available_features.add("executable_test")
474-
config.available_features.add("long_test")
475-
elif swift_run_only_tests == 'executable_tests':
476-
config.available_features.add("executable_test")
477-
config.limit_to_features.add("executable_test")
478-
elif swift_run_only_tests == 'non_executable_tests':
475+
swift_test_subset = lit_config.params.get('swift_test_subset', 'validation')
476+
if swift_test_subset in ['primary', 'validation', 'only_validation']:
477+
# No extra flags needed.
479478
pass
480-
elif swift_run_only_tests == 'long_tests':
479+
elif swift_test_subset == 'all':
480+
config.available_features.add("long_test")
481+
elif swift_test_subset == 'only_long':
481482
config.available_features.add("long_test")
482483
config.limit_to_features.add("long_test")
483-
elif swift_run_only_tests == 'all_except_long':
484-
config.available_features.add("executable_test")
484+
config.limit_to_features.discard("executable_test")
485485
else:
486-
lit_config.fatal("Unknown test mode %r" % swift_run_only_tests)
486+
lit_config.fatal("Unknown test mode %r" % swift_test_subset)
487487

488488
# Add substitutions for the run target triple, CPU, OS, and pointer size.
489489
config.substitutions.append(('%target-triple', config.variant_triple))

validation-test/Driver/many-inputs.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
// RUN: nm %t/libMultiFile | FileCheck %t/check.txt
1818

1919
// REQUIRES: long_test
20+
// REQUIRES: executable_test
2021

validation-test/SIL/Inputs/gen_parse_stdlib_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ for id in $(seq 0 $process_id_max); do
1515
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
1616
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=$process_count -ast-verifier-process-id=$id > /dev/null
1717
// REQUIRES: long_test
18+
// REQUIRES: nonexecutable_test
1819
__EOF__
1920

2021
done

validation-test/SIL/parse_stdlib_0.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=0 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_1.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=1 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_10.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=10 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_11.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=11 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_12.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=12 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_13.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=13 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_14.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=14 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_15.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=15 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_16.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=16 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_2.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=2 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_3.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=3 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_4.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=4 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_5.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=5 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_6.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=6 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_7.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=7 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_8.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=8 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/parse_stdlib_9.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
// RUN: %target-sil-opt -enable-sil-verify-all -sil-disable-ast-dump %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil
88
// RUN: %target-sil-opt -enable-sil-verify-all %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=9 > /dev/null
99
// REQUIRES: long_test
10+
// REQUIRES: nonexecutable_test

validation-test/SIL/verify_all_overlays.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
// CHECK-NOT: Unknown
44

55
// REQUIRES: long_test
6+
// REQUIRES: nonexecutable_test

0 commit comments

Comments
 (0)