mirror of https://github.com/cirruslabs/tart.git
fix: parse CRLF stdout from guest agent in GuestDropParseTests
split(whereSeparator: { $0 == "\n" || $0 == "\r" }) never matches CRLF
because Swift treats "\r\n" as a single Character (grapheme cluster
U+000D, U+000A), so the closure — which compares against the
single-codepoint characters "\n" and "\r" — fires for neither. With
CRLF input the entire stdout becomes one "line" that doesn't have the
tartdrop-dest= prefix, and the parser returns nil.
Switch to String.enumerateLines, which handles LF, CR, and CRLF.
This commit is contained in:
parent
6375d224c1
commit
daed6eee82
|
|
@ -239,8 +239,10 @@ enum GuestDropSynthesis {
|
|||
/// match, and takes the *last* such line so a trailing real value wins.
|
||||
/// Returns nil when no non-empty value is present. Pure — unit-tested.
|
||||
static func parseDestinationFolder(stdout: String) -> String? {
|
||||
// enumerateLines handles LF, CR, and CRLF — split(whereSeparator:) misses
|
||||
// CRLF because Swift treats "\r\n" as a single Character.
|
||||
var folderName: String?
|
||||
for line in stdout.split(whereSeparator: { $0 == "\n" || $0 == "\r" }) {
|
||||
stdout.enumerateLines { line, _ in
|
||||
if line.hasPrefix("tartdrop-dest=") {
|
||||
folderName = String(line.dropFirst("tartdrop-dest=".count))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue