Tests: Use ABI entry point for swift-testing tests

Avoid the unstable SwiftPM entry point in favor of the stable ABI entry
point.
This commit is contained in:
Andrew Kaster 2024-11-17 15:29:25 -07:00 committed by Andrew Kaster
parent fca6fd0b85
commit 4b4a6991e3
Notes: github-actions[bot] 2024-11-19 21:54:02 +00:00
2 changed files with 18 additions and 5 deletions

View file

@ -21,6 +21,8 @@ if (APPLE)
set(CMAKE_Swift_COMPILER_TARGET "${SWIFT_TARGET_TRIPLE}")
endif()
add_compile_options("SHELL:$<$<COMPILE_LANGUAGE:Swift>:-enable-experimental-feature Extern>")
set(VFS_OVERLAY_DIRECTORY "${CMAKE_BINARY_DIR}/vfs_overlays" CACHE PATH "Directory to put VFS overlays in")
# FIXME: https://gitlab.kitware.com/cmake/cmake/-/issues/26195

View file

@ -4,13 +4,24 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
// FIXME: This file is intended to become redundant as swift-testing stabilizes
// See https://github.com/swiftlang/swift-testing/blob/133e30231c4583b02ab3ea2a7f678f3d7f4f8a3d/Documentation/CMake.md#add-an-entry-point
import Foundation
import Testing
typealias EntryPoint = @convention(thin) @Sendable (_ configurationJSON: UnsafeRawBufferPointer?, _ recordHandler: @escaping @Sendable (_ recordJSON: UnsafeRawBufferPointer) -> Void) async throws -> Bool
@_extern(c, "swt_abiv0_getEntryPoint")
func swt_abiv0_getEntryPoint() -> UnsafeRawPointer
@main struct Runner {
static func main() async {
await Testing.__swiftPMEntryPoint() as Never
static func main() async throws {
let configurationJSON: UnsafeRawBufferPointer? = nil
let recordHandler: @Sendable (UnsafeRawBufferPointer) -> Void = { _ in }
let entryPoint = unsafeBitCast(swt_abiv0_getEntryPoint(), to: EntryPoint.self)
if try await entryPoint(configurationJSON, recordHandler) {
exit(EXIT_SUCCESS)
} else {
exit(EXIT_FAILURE)
}
}
}