@@ -605,8 +605,8 @@ extension ExitTest {
605605 /// and standard error streams of the current process.
606606 private static func _writeBarrierValues( ) {
607607 let barrierValue = Self . barrierValue
608- try ? FileHandle . stdout. write ( barrierValue. span . bytes )
609- try ? FileHandle . stderr. write ( barrierValue. span . bytes )
608+ try ? FileHandle . stdout. write ( barrierValue)
609+ try ? FileHandle . stderr. write ( barrierValue)
610610 }
611611
612612 /// A handler that is invoked when an exit test starts.
@@ -712,11 +712,13 @@ extension ExitTest {
712712
713713 /// The ID of the exit test to run, if any, specified in the environment.
714714 static var environmentIDForEntryPoint : ID ? {
715- guard let idString = Environment . variable ( named: Self . _idEnvironmentVariableName) else {
715+ guard var idString = Environment . variable ( named: Self . _idEnvironmentVariableName) else {
716716 return nil
717717 }
718718
719- return try ? JSON . decode ( ExitTest . ID. self, from: idString. utf8. span. bytes)
719+ return try ? idString. withUTF8 { idBuffer in
720+ try JSON . decode ( ExitTest . ID. self, from: UnsafeRawBufferPointer ( idBuffer) )
721+ }
720722 }
721723
722724 /// Find the exit test function specified in the environment of the current
@@ -868,7 +870,7 @@ extension ExitTest {
868870 // Insert a specific variable that tells the child process which exit test
869871 // to run.
870872 try JSON . withEncoding ( of: exitTest. id) { json in
871- childEnvironment [ Self . _idEnvironmentVariableName] = String ( decoding: Array ( json) , as: UTF8 . self)
873+ childEnvironment [ Self . _idEnvironmentVariableName] = String ( decoding: json, as: UTF8 . self)
872874 }
873875
874876 typealias ResultUpdater = @Sendable ( inout ExitTest . Result ) -> Void
@@ -1005,7 +1007,9 @@ extension ExitTest {
10051007
10061008 for recordJSON in bytes. split ( whereSeparator: \. isASCIINewline) where !recordJSON. isEmpty {
10071009 do {
1008- try Self . _processRecord ( recordJSON. span. bytes, fromBackChannel: backChannel)
1010+ try recordJSON. withUnsafeBufferPointer { recordJSON in
1011+ try Self . _processRecord ( . init( recordJSON) , fromBackChannel: backChannel)
1012+ }
10091013 } catch {
10101014 // NOTE: an error caught here indicates a decoding problem.
10111015 // TODO: should we record these issues as systemic instead?
@@ -1022,7 +1026,7 @@ extension ExitTest {
10221026 /// - backChannel: The file handle that `recordJSON` was read from.
10231027 ///
10241028 /// - Throws: Any error encountered attempting to decode or process the JSON.
1025- private static func _processRecord( _ recordJSON: borrowing RawSpan , fromBackChannel backChannel: borrowing FileHandle ) throws {
1029+ private static func _processRecord( _ recordJSON: UnsafeRawBufferPointer , fromBackChannel backChannel: borrowing FileHandle ) throws {
10261030 let record = try JSON . decode ( ABI . Record< ABI . BackChannelVersion> . self , from: recordJSON)
10271031 guard case let . event( event) = record. kind else {
10281032 return
@@ -1089,7 +1093,9 @@ extension ExitTest {
10891093 var capturedValue = capturedValue
10901094
10911095 func open< T> ( _ type: T . Type ) throws -> T where T: Codable & Sendable {
1092- return try JSON . decode ( type, from: capturedValueJSON. span. bytes)
1096+ return try capturedValueJSON. withUnsafeBytes { capturedValueJSON in
1097+ try JSON . decode ( type, from: capturedValueJSON)
1098+ }
10931099 }
10941100 capturedValue. wrappedValue = try open ( capturedValue. typeOfWrappedValue)
10951101
@@ -1112,7 +1118,7 @@ extension ExitTest {
11121118 /// This function should only be used when the process was started via the
11131119 /// `__swiftPMEntryPoint()` function. The effect of using it under other
11141120 /// configurations is undefined.
1115- private borrowing func _withEncodedCapturedValuesForEntryPoint( _ body: ( borrowing RawSpan ) throws -> Void ) throws -> Void {
1121+ private borrowing func _withEncodedCapturedValuesForEntryPoint( _ body: ( UnsafeRawBufferPointer ) throws -> Void ) throws -> Void {
11161122 for capturedValue in capturedValues {
11171123 try JSON . withEncoding ( of: capturedValue. wrappedValue!) { capturedValueJSON in
11181124 try JSON . asJSONLine ( capturedValueJSON, body)
0 commit comments