Skip to content

Commit e5afd30

Browse files
authored
Fix empty message crash. (#162)
* Fix empty message crash. * wip * wip
1 parent fd1b3d1 commit e5afd30

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Sources/IssueReportingTestSupport/SwiftTesting.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ private func __recordIssue(
1414
column: Int
1515
) {
1616
#if canImport(Testing)
17+
let message = message == "" ? nil : message
1718
Issue.record(
1819
message.map(Comment.init(rawValue:)),
1920
sourceLocation: SourceLocation(

Tests/IssueReportingTests/SwiftTestingTests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,36 @@
129129
&& issue.description == "Issue recorded: Something went wrong"
130130
}
131131
}
132+
133+
@Test
134+
func emptyMessage() {
135+
withKnownIssue {
136+
reportIssue("")
137+
}
138+
}
139+
140+
@Test
141+
func emptyMessage_async() async {
142+
await withKnownIssue {
143+
await Task.yield()
144+
reportIssue("")
145+
}
146+
}
147+
148+
@Test
149+
func emptyMessage_throws() throws {
150+
withKnownIssue {
151+
reportIssue("")
152+
}
153+
}
154+
155+
@Test
156+
func emptyMessage_asyncThrows() async throws {
157+
await withKnownIssue {
158+
await Task.yield()
159+
reportIssue("")
160+
}
161+
}
132162
}
133163

134164
private struct Failure: Error {}

0 commit comments

Comments
 (0)