Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ extension Event.ConsoleOutputRecorder {
// text instead of just the symbol. Details may be multi-line messages,
// so split the message on newlines and indent all lines to align them
// to the indentation provided by the symbol.
var lines = message.stringValue.split(whereSeparator: \.isNewline)
var lines = message.stringValue.split(omittingEmptySubsequences: false, whereSeparator: \.isNewline)
lines = CollectionOfOne(lines[0]) + lines.dropFirst().map { line in
"\(padding) \(line)"
}
Expand Down
24 changes: 24 additions & 0 deletions Tests/TestingTests/EventRecorderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,30 @@ struct EventRecorderTests {
}
#endif

@Test(
"Uncommonly-formatted comments",
.bug("rdar://149482060"),
arguments: [
"", // Empty string
"\n\n\n", // Only newlines
"\nFoo\n\nBar\n\n\nBaz\n", // Newlines interspersed with non-empty strings
]
)
func uncommonComments(text: String) async throws {
let stream = Stream()

var configuration = Configuration()
configuration.eventHandlingOptions.isWarningIssueRecordedEventEnabled = true
let eventRecorder = Event.ConsoleOutputRecorder(writingUsing: stream.write)
configuration.eventHandler = { event, context in
eventRecorder.record(event, in: context)
}

await Test {
Issue.record(Comment(rawValue: text) /* empty */)
}.run(configuration: configuration)
}

@available(_regexAPI, *)
@Test("Issue counts are omitted on a successful test")
func issueCountOmittedForPassingTest() async throws {
Expand Down