Skip to content

Commit ad5f7c2

Browse files
committed
Merge remote-tracking branch 'origin/main' into release/6.2
2 parents 63d4ef2 + cacb295 commit ad5f7c2

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
#
1010

11-
* @stmontgomery @grynspan @briancroom @SeanROlszewski @suzannaratcliff
11+
* @stmontgomery @grynspan @briancroom @suzannaratcliff

Documentation/ABI/TestContent.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ record's kind is a 32-bit unsigned value. The following kinds are defined:
100100
| `0x00000000` | – | Reserved (**do not use**) |
101101
| `0x74657374` | `'test'` | Test or suite declaration |
102102
| `0x65786974` | `'exit'` | Exit test |
103+
| `0x706c6179` | `'play'` | [Playground](https://github.com/apple/swift-play-experimental) |
103104

104-
<!-- When adding cases to this enumeration, be sure to also update the
105-
corresponding enumeration in TestContentGeneration.swift. -->
105+
<!-- The kind values listed in this table should be a superset of the cases in
106+
the `TestContentKind` enumeration. -->
106107

107108
If a test content record's `kind` field equals `0x00000000`, the values of all
108109
other fields in that record are undefined.

Sources/Testing/Events/Recorder/Event.ConsoleOutputRecorder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ extension Event.ConsoleOutputRecorder {
323323
// text instead of just the symbol. Details may be multi-line messages,
324324
// so split the message on newlines and indent all lines to align them
325325
// to the indentation provided by the symbol.
326-
var lines = message.stringValue.split(whereSeparator: \.isNewline)
326+
var lines = message.stringValue.split(omittingEmptySubsequences: false, whereSeparator: \.isNewline)
327327
lines = CollectionOfOne(lines[0]) + lines.dropFirst().map { line in
328328
"\(padding) \(line)"
329329
}

Sources/TestingMacros/Support/EffectfulExpressionHandling.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ func applyEffectfulKeywords(_ effectfulKeywords: Set<Keyword>, to expr: some Exp
111111

112112
let needAwait = effectfulKeywords.contains(.await) && !expr.is(AwaitExprSyntax.self)
113113
let needTry = effectfulKeywords.contains(.try) && !expr.is(TryExprSyntax.self)
114+
115+
// The 'unsafe' keyword was introduced in 6.2 as part of SE-0458. Older
116+
// toolchains are not aware of it, so avoid emitting expressions involving
117+
// that keyword when the macro has been built using an older toolchain.
118+
#if compiler(>=6.2)
114119
let needUnsafe = effectfulKeywords.contains(.unsafe) && !expr.is(UnsafeExprSyntax.self)
120+
#endif
115121

116122
// First, add thunk function calls.
117123
if needAwait {
@@ -120,9 +126,11 @@ func applyEffectfulKeywords(_ effectfulKeywords: Set<Keyword>, to expr: some Exp
120126
if needTry {
121127
expr = _makeCallToEffectfulThunk(.identifier("__requiringTry"), passing: expr)
122128
}
129+
#if compiler(>=6.2)
123130
if needUnsafe {
124131
expr = _makeCallToEffectfulThunk(.identifier("__requiringUnsafe"), passing: expr)
125132
}
133+
#endif
126134

127135
// Then add keyword expressions. (We do this separately so we end up writing
128136
// `try await __r(__r(self))` instead of `try __r(await __r(self))` which is
@@ -143,6 +151,7 @@ func applyEffectfulKeywords(_ effectfulKeywords: Set<Keyword>, to expr: some Exp
143151
)
144152
)
145153
}
154+
#if compiler(>=6.2)
146155
if needUnsafe {
147156
expr = ExprSyntax(
148157
UnsafeExprSyntax(
@@ -151,6 +160,7 @@ func applyEffectfulKeywords(_ effectfulKeywords: Set<Keyword>, to expr: some Exp
151160
)
152161
)
153162
}
163+
#endif
154164

155165
expr.leadingTrivia = originalExpr.leadingTrivia
156166
expr.trailingTrivia = originalExpr.trailingTrivia

Tests/TestingTests/EventRecorderTests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,30 @@ struct EventRecorderTests {
257257
}
258258
#endif
259259

260+
@Test(
261+
"Uncommonly-formatted comments",
262+
.bug("rdar://149482060"),
263+
arguments: [
264+
"", // Empty string
265+
"\n\n\n", // Only newlines
266+
"\nFoo\n\nBar\n\n\nBaz\n", // Newlines interspersed with non-empty strings
267+
]
268+
)
269+
func uncommonComments(text: String) async throws {
270+
let stream = Stream()
271+
272+
var configuration = Configuration()
273+
configuration.eventHandlingOptions.isWarningIssueRecordedEventEnabled = true
274+
let eventRecorder = Event.ConsoleOutputRecorder(writingUsing: stream.write)
275+
configuration.eventHandler = { event, context in
276+
eventRecorder.record(event, in: context)
277+
}
278+
279+
await Test {
280+
Issue.record(Comment(rawValue: text) /* empty */)
281+
}.run(configuration: configuration)
282+
}
283+
260284
@available(_regexAPI, *)
261285
@Test("Issue counts are omitted on a successful test")
262286
func issueCountOmittedForPassingTest() async throws {

0 commit comments

Comments
 (0)