Commit b5fa554
authored
Include code comments before expectations which are preceded by try/await in recorded issues (#1092)
This fixes an issue where code comments placed before an expectation
like `#expect()` which has effect introducer keywords like `try` or
`await` are ignored, and ensures they are included in the recorded issue
if the expectation fails.
Consider this example of two failing expectations:
```swift
// Uh oh!
#expect(try x() == 2)
// Uh oh!
try #expect(x() == 2)
```
Prior to this PR, if `x()` returned a value other than `2`, there would
be two issues recorded, but the second one would not have the comment
`“Uh oh!”` because from the macro’s perspective, that code comment was
on the `try` keyword and it could only see trivia associated with
`#expect()`.
Now, with the recent swift-syntax fix from
swiftlang/swift-syntax#3037, the `try` keyword
and its associated trivia can be included and this bug can be fixed. We
recently adopted a new-enough swift-syntax in #1069, so the only fix
needed is to adopt `lexicalContext` for this new purpose in our macro.
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.1 parent cacb295 commit b5fa554
File tree
3 files changed
+79
-2
lines changed- Sources/TestingMacros
- Support
- Tests/TestingMacrosTests
3 files changed
+79
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
161 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
162 | 171 | | |
163 | 172 | | |
164 | 173 | | |
| |||
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
243 | 296 | | |
244 | 297 | | |
245 | 298 | | |
| |||
0 commit comments