Skip to content

Commit ea6ca2b

Browse files
authored
Merge pull request swiftlang#83128 from MaxDesiatov/maxd/run-embedded-tests
test/CMakeLists.txt: run Embedded Swift for Wasm tests Run new `check-swift-embedded-wasi` target from `test/CMakeLists.txt`, tweak `lit.cfg` to support WASI Clang resource dir, exclude unsupported tests based on `CPU=wasm32` instead of `OS=wasi`.
2 parents 5023b90 + 9b23c08 commit ea6ca2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+118
-75
lines changed

test/CMakeLists.txt

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ foreach(SDK ${SWIFT_SDKS})
404404
set(VARIANT_EXTERNAL_EMBEDDED_PLATFORM FALSE)
405405
set(VARIANT_EXTERNAL_EMBEDDED_DEVICE)
406406

407+
# Reset these values for WASI, as Embedded Swift for WASI requires separate lit configs.
408+
set(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_old ${SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB})
409+
set(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING_old ${SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING})
410+
if(${SDK} STREQUAL "WASI")
411+
set(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB OFF)
412+
set(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING OFF)
413+
endif()
414+
407415
swift_configure_lit_site_cfg(
408416
"${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in"
409417
"${test_bin_dir}/lit.site.cfg"
@@ -426,6 +434,10 @@ foreach(SDK ${SWIFT_SDKS})
426434
"${test_bin_dir}/lit.swift-features.cfg"
427435
"${validation_test_bin_dir}/lit.swift-features.cfg")
428436

437+
# Restore old values in case they were reset for WASI tests lit configs.
438+
set(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB ${SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_old})
439+
set(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING ${SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING_old})
440+
429441
set(test_dependencies)
430442
get_test_dependencies("${SDK}" test_dependencies)
431443

@@ -587,6 +599,43 @@ foreach(SDK ${SWIFT_SDKS})
587599
PROPERTY FOLDER "Tests/check-swift")
588600
endforeach()
589601
endforeach()
602+
603+
if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING AND (${ARCH} STREQUAL "wasm32"))
604+
set(test_mode "optimize_none")
605+
set(test_subset "primary")
606+
set(VARIANT_SUFFIX "-embedded-wasi")
607+
set(VARIANT_TRIPLE "wasm32-unknown-wasip1")
608+
set(test_bin_dir "${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/embedded")
609+
set(VARIANT_EXTERNAL_EMBEDDED_PLATFORM FALSE)
610+
set(VARIANT_EXTERNAL_EMBEDDED_DEVICE)
611+
set(SWIFT_TEST_RESULTS_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/swift-test-results/${VARIANT_TRIPLE}")
612+
swift_configure_lit_site_cfg(
613+
"${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in"
614+
"${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.site.cfg"
615+
"test${VARIANT_SUFFIX}.lit.site.cfg")
616+
swift_generate_lit_swift_features_cfg("${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.swift-features.cfg")
617+
618+
set(test_target_name "check-swift${VARIANT_SUFFIX}")
619+
set(directories "${test_bin_dir}")
620+
621+
set(embedded_wasm_lit_args)
622+
setup_lit_args(embedded_wasm_lit_args "${SDK}" "${SWIFT_TEST_RESULTS_DIR}" "${SWIFTLIB_DIR}")
623+
624+
add_custom_target("${test_target_name}"
625+
${maybe_command_upload_stdlib}
626+
${command_upload_swift_reflection_test}
627+
${command_clean_test_results_dir}
628+
COMMAND
629+
${CMAKE_COMMAND} -E env ${SWIFT_LIT_ENVIRONMENT}
630+
$<TARGET_FILE:Python3::Interpreter> "${LIT}"
631+
${embedded_wasm_lit_args}
632+
"--param" "swift_test_subset=${test_subset}"
633+
"--param" "swift_test_mode=${test_mode}"
634+
${directories}
635+
DEPENDS ${dependencies}
636+
COMMENT "Running ${test_subset} Swift tests for ${VARIANT_TRIPLE}"
637+
USES_TERMINAL)
638+
endif()
590639
endforeach()
591640
endforeach()
592641
endforeach()
@@ -624,17 +673,6 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING)
624673
"${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.site.cfg"
625674
"test${VARIANT_SUFFIX}.lit.site.cfg")
626675
swift_generate_lit_swift_features_cfg("${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.swift-features.cfg")
627-
628-
set(VARIANT_SUFFIX "-embedded-wasi")
629-
set(VARIANT_TRIPLE "wasm32-unknown-wasip1")
630-
set(VARIANT_EXTERNAL_EMBEDDED_PLATFORM FALSE)
631-
set(VARIANT_EXTERNAL_EMBEDDED_DEVICE)
632-
set(SWIFT_TEST_RESULTS_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/swift-test-results/${VARIANT_TRIPLE}")
633-
swift_configure_lit_site_cfg(
634-
"${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in"
635-
"${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.site.cfg"
636-
"test${VARIANT_SUFFIX}.lit.site.cfg")
637-
swift_generate_lit_swift_features_cfg("${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.swift-features.cfg")
638676
endif()
639677

640678
# Add shortcuts for the default variant.

test/ClangImporter/availability_returns_twice.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// UNSUPPORTED: OS=windows-msvc
44

55
// `setjmp` is not available on WebAssembly/WASI
6-
// UNSUPPORTED: OS=wasi
6+
// UNSUPPORTED: OS=wasip1
77

88
// https://github.com/apple/swift/issues/51632
99
// In Android jmp_buf is int[16], which doesn't convert to &Int

test/Concurrency/Runtime/continuation_validation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// UNSUPPORTED: back_deploy_concurrency
1313
// UNSUPPORTED: use_os_stdlib
1414
// UNSUPPORTED: freestanding
15-
// UNSUPPORTED: OS=wasi
15+
// UNSUPPORTED: OS=wasip1
1616

1717
import StdlibUnittest
1818

test/Concurrency/Runtime/exclusivity.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// REQUIRES: concurrency_runtime
88
// UNSUPPORTED: back_deployment_runtime
9-
// UNSUPPORTED: OS=wasi
9+
// UNSUPPORTED: OS=wasip1
1010
// UNSUPPORTED: back_deploy_concurrency
1111

1212
// This test makes sure that:
@@ -365,7 +365,7 @@ struct Runner {
365365
debugLog("==> Enter callee2")
366366
debugLog("==> Exit callee2")
367367
}
368-
368+
369369
// We add an inline never here to make sure that we do not eliminate
370370
// the dynamic access after inlining.
371371
@MainActor
@@ -374,7 +374,7 @@ struct Runner {
374374
debugLog("==> Enter callee1")
375375
let handle = Task { @MainActor in
376376
debugLog("==> Enter callee1 Closure")
377-
377+
378378
// These accesses end before we await in the task.
379379
do {
380380
callee2(&global1, &global2, &global3)
@@ -389,7 +389,7 @@ struct Runner {
389389
await handle.value
390390
debugLog("==> Exit callee1")
391391
}
392-
392+
393393
debugLog("==> Enter 'testCase1'")
394394
await callee1()
395395
debugLog("==> Exit 'testCase1'")

test/Concurrency/Runtime/exclusivity_custom_executors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// UNSUPPORTED: back_deploy_concurrency
1313

1414
// Crash expectations can't be implemented on WASI/WebAssembly.
15-
// UNSUPPORTED: OS=wasi
15+
// UNSUPPORTED: OS=wasip1
1616

1717
// This test makes sure that we properly save/restore access when we
1818
// synchronously launch a task from a serial executor. The access from the task

test/IRGen/async/hop_to_executor.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
// REQUIRES: concurrency
44

5-
// WASI does not support the mandatory tail call, and needs to take the same
5+
// Wasm does not support the mandatory tail call, and needs to take the same
66
// path as CHECK-WIN, but will currently go down CHECK-SYSV, failing the test.
7-
// XFAIL: OS=wasi
7+
// XFAIL: CPU=wasm32
88

99
sil_stage canonical
1010

test/IRGen/loadable_by_address_address_assignment.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
44

55
// wasm currently disables aggressive reg2mem
6-
// UNSUPPORTED: wasm
7-
// UNSUPPORTED: OS=wasi
86
// UNSUPPORTED: CPU=wasm32
97

108
public struct LargeThing {

test/IRGen/loadable_by_address_reg2mem.sil

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-frontend %s -Xllvm -sil-print-types -Xllvm -sil-print-after=loadable-address -import-objc-header %S/Inputs/large_c.h -c -o %t/t.o 2>&1 | %FileCheck %s
22

33
// wasm currently disables aggressive reg2mem
4-
// UNSUPPORTED: wasm
5-
// UNSUPPORTED: OS=wasi
64
// UNSUPPORTED: CPU=wasm32
75
// REQUIRES: PTRSIZE=64
86

test/IRGen/loadable_by_address_reg2mem_fixed_array.sil

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// REQUIRES: swift_feature_BuiltinModule
66

77
// wasm currently disables aggressive reg2mem
8-
// UNSUPPORTED: wasm
9-
// UNSUPPORTED: OS=wasi
108
// UNSUPPORTED: CPU=wasm32
119

1210
import Builtin

test/IRGen/run-coroutine_accessors.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@
9191
// REQUIRES: concurrency_runtime
9292

9393
// TODO: CoroutineAccessors: Enable on WASM.
94-
// UNSUPPORTED: wasm
95-
// UNSUPPORTED: OS=wasi
9694
// UNSUPPORTED: CPU=wasm32
9795

9896
// REQUIRES: swift_feature_CoroutineAccessors
@@ -243,7 +241,7 @@ struct Boxtional<T> : ResilientWrapping {
243241

244242
@available(SwiftStdlib 9999, *)
245243
class NonresilientResilientWrappingSubclass<X : ResilientWrapping> : ResilientWrappingClass<X.Wrapped> {
246-
init(_ impl: X) {
244+
init(_ impl: X) {
247245
self.impl = impl
248246
super.init()
249247
}

0 commit comments

Comments
 (0)