Skip to content

Remove swt_copyABIEntryPoint_v0(). #1240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,4 @@ extension ABI.v0 {
@usableFromInline func abiv0_getEntryPoint() -> UnsafeRawPointer {
unsafeBitCast(ABI.v0.entryPoint, to: UnsafeRawPointer.self)
}

#if !SWT_NO_SNAPSHOT_TYPES
// MARK: - Xcode 16 compatibility

extension ABI.Xcode16 {
/// An older signature for ``ABI/v0/EntryPoint-swift.typealias`` used by
/// Xcode 16.
///
/// - Warning: This type will be removed in a future update.
@available(*, deprecated, message: "Use ABI.v0.EntryPoint instead.")
typealias EntryPoint = @Sendable (
_ argumentsJSON: UnsafeRawBufferPointer?,
_ recordHandler: @escaping @Sendable (_ recordJSON: UnsafeRawBufferPointer) -> Void
) async throws -> CInt
}

/// An older signature for ``ABI/v0/entryPoint-swift.type.property`` used by
/// Xcode 16.
///
/// - Warning: This function will be removed in a future update.
@available(*, deprecated, message: "Use ABI.v0.entryPoint (swt_abiv0_getEntryPoint()) instead.")
@_cdecl("swt_copyABIEntryPoint_v0")
@usableFromInline func copyABIEntryPoint_v0() -> UnsafeMutableRawPointer {
let result = UnsafeMutablePointer<ABI.Xcode16.EntryPoint>.allocate(capacity: 1)
result.initialize { configurationJSON, recordHandler in
var args = try configurationJSON.map { configurationJSON in
try JSON.decode(__CommandLineArguments_v0.self, from: configurationJSON)
}
if args?.eventStreamVersion == nil {
args?.eventStreamVersion = ABI.Xcode16.versionNumber
}
let eventHandler = try eventHandlerForStreamingEvents(version: args?.eventStreamVersion, encodeAsJSONLines: false, forwardingTo: recordHandler)

var exitCode = await Testing.entryPoint(passing: args, eventHandler: eventHandler)
if exitCode == EXIT_NO_TESTS_FOUND {
exitCode = EXIT_SUCCESS
}
return exitCode
}
return .init(result)
}
#endif
#endif
64 changes: 0 additions & 64 deletions Tests/TestingTests/ABIEntryPointTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,6 @@ private import _TestingInternals

@Suite("ABI entry point tests")
struct ABIEntryPointTests {
#if !SWT_NO_SNAPSHOT_TYPES
@available(*, deprecated)
@Test func v0_experimental() async throws {
var arguments = __CommandLineArguments_v0()
arguments.filter = ["NonExistentTestThatMatchesNothingHopefully"]
arguments.eventStreamVersion = 0
arguments.verbosity = .min

let result = try await _invokeEntryPointV0Experimental(passing: arguments) { recordJSON in
let record = try! JSON.decode(ABI.Record<ABI.v0>.self, from: recordJSON)
_ = record.kind
}

#expect(result == EXIT_SUCCESS)
}

@available(*, deprecated)
@Test("v0 experimental entry point with a large number of filter arguments")
func v0_experimental_manyFilters() async throws {
var arguments = __CommandLineArguments_v0()
arguments.filter = (1...100).map { "NonExistentTestThatMatchesNothingHopefully_\($0)" }
arguments.eventStreamVersion = 0
arguments.verbosity = .min

let result = try await _invokeEntryPointV0Experimental(passing: arguments)

#expect(result == EXIT_SUCCESS)
}

@available(*, deprecated)
private func _invokeEntryPointV0Experimental(
passing arguments: __CommandLineArguments_v0,
recordHandler: @escaping @Sendable (_ recordJSON: UnsafeRawBufferPointer) -> Void = { _ in }
) async throws -> CInt {
#if !SWT_NO_DYNAMIC_LINKING
// Get the ABI entry point by dynamically looking it up at runtime.
let copyABIEntryPoint_v0 = try withTestingLibraryImageAddress { testingLibrary in
try #require(
symbol(in: testingLibrary, named: "swt_copyABIEntryPoint_v0").map {
castCFunction(at: $0, to: (@convention(c) () -> UnsafeMutableRawPointer).self)
}
)
}
#endif
let abiEntryPoint = copyABIEntryPoint_v0().assumingMemoryBound(to: ABI.Xcode16.EntryPoint.self)
defer {
abiEntryPoint.deinitialize(count: 1)
abiEntryPoint.deallocate()
}

let argumentsJSON = try JSON.withEncoding(of: arguments) { argumentsJSON in
let result = UnsafeMutableRawBufferPointer.allocate(byteCount: argumentsJSON.count, alignment: 1)
result.copyMemory(from: argumentsJSON)
return result
}
defer {
argumentsJSON.deallocate()
}

// Call the entry point function.
return try await abiEntryPoint.pointee(.init(argumentsJSON), recordHandler)
}
#endif

@Test func v0() async throws {
var arguments = __CommandLineArguments_v0()
arguments.filter = ["NonExistentTestThatMatchesNothingHopefully"]
Expand Down