@@ -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)
609- try ? FileHandle . stderr. write ( barrierValue)
608+ try ? FileHandle . stdout. write ( barrierValue. span . bytes )
609+ try ? FileHandle . stderr. write ( barrierValue. span . bytes )
610610 }
611611
612612 /// A handler that is invoked when an exit test starts.
@@ -712,13 +712,11 @@ 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 var idString = Environment . variable ( named: Self . _idEnvironmentVariableName) else {
715+ guard let idString = Environment . variable ( named: Self . _idEnvironmentVariableName) else {
716716 return nil
717717 }
718718
719- return try ? idString. withUTF8 { idBuffer in
720- try JSON . decode ( ExitTest . ID. self, from: UnsafeRawBufferPointer ( idBuffer) )
721- }
719+ return try ? JSON . decode ( ExitTest . ID. self, from: idString. utf8. span. bytes)
722720 }
723721
724722 /// Find the exit test function specified in the environment of the current
@@ -870,7 +868,7 @@ extension ExitTest {
870868 // Insert a specific variable that tells the child process which exit test
871869 // to run.
872870 try JSON . withEncoding ( of: exitTest. id) { json in
873- childEnvironment [ Self . _idEnvironmentVariableName] = String ( decoding: json, as: UTF8 . self)
871+ childEnvironment [ Self . _idEnvironmentVariableName] = String ( decoding: Array ( json) , as: UTF8 . self)
874872 }
875873
876874 typealias ResultUpdater = @Sendable ( inout ExitTest . Result ) -> Void
@@ -1007,9 +1005,7 @@ extension ExitTest {
10071005
10081006 for recordJSON in bytes. split ( whereSeparator: \. isASCIINewline) where !recordJSON. isEmpty {
10091007 do {
1010- try recordJSON. withUnsafeBufferPointer { recordJSON in
1011- try Self . _processRecord ( . init( recordJSON) , fromBackChannel: backChannel)
1012- }
1008+ try Self . _processRecord ( recordJSON. span. bytes, fromBackChannel: backChannel)
10131009 } catch {
10141010 // NOTE: an error caught here indicates a decoding problem.
10151011 // TODO: should we record these issues as systemic instead?
@@ -1026,7 +1022,7 @@ extension ExitTest {
10261022 /// - backChannel: The file handle that `recordJSON` was read from.
10271023 ///
10281024 /// - Throws: Any error encountered attempting to decode or process the JSON.
1029- private static func _processRecord( _ recordJSON: UnsafeRawBufferPointer , fromBackChannel backChannel: borrowing FileHandle ) throws {
1025+ private static func _processRecord( _ recordJSON: borrowing RawSpan , fromBackChannel backChannel: borrowing FileHandle ) throws {
10301026 let record = try JSON . decode ( ABI . Record< ABI . BackChannelVersion> . self , from: recordJSON)
10311027 guard case let . event( event) = record. kind else {
10321028 return
@@ -1093,9 +1089,7 @@ extension ExitTest {
10931089 var capturedValue = capturedValue
10941090
10951091 func open< T> ( _ type: T . Type ) throws -> T where T: Codable & Sendable {
1096- return try capturedValueJSON. withUnsafeBytes { capturedValueJSON in
1097- try JSON . decode ( type, from: capturedValueJSON)
1098- }
1092+ return try JSON . decode ( type, from: capturedValueJSON. span. bytes)
10991093 }
11001094 capturedValue. wrappedValue = try open ( capturedValue. typeOfWrappedValue)
11011095
@@ -1118,7 +1112,7 @@ extension ExitTest {
11181112 /// This function should only be used when the process was started via the
11191113 /// `__swiftPMEntryPoint()` function. The effect of using it under other
11201114 /// configurations is undefined.
1121- private borrowing func _withEncodedCapturedValuesForEntryPoint( _ body: ( UnsafeRawBufferPointer ) throws -> Void ) throws -> Void {
1115+ private borrowing func _withEncodedCapturedValuesForEntryPoint( _ body: ( borrowing RawSpan ) throws -> Void ) throws -> Void {
11221116 for capturedValue in capturedValues {
11231117 try JSON . withEncoding ( of: capturedValue. wrappedValue!) { capturedValueJSON in
11241118 try JSON . asJSONLine ( capturedValueJSON, body)
0 commit comments