Commit f6af3d8
authored
On Apple platforms, when an error occurs in an Objective-C method or C
function, convention is to return the error as an instance of
`NSError`/`CFError` via an out-parameter. When that Objective-C method
or C function is called by a Swift function, the Swift function detects
the error, then effectively rethrows it, at which point our
`swift_willThrow` hook is triggered. This can obscure the real origin of
the error which may be many stack frames down from the point Swift takes
over.
This PR asks Foundation, via a relatively new internal function, to
capture backtraces for instances of `NSError` and `CFError` at the point
they are created. Then, when Swift Testing attempts to look up the
backtrace for an error it has caught, if Foundation has generated one,
then Swift Testing can substitute it in place of the one it generated in
the `swift_willThrow` hook.
Resolves rdar://114386243.
### 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 e7a7e23 commit f6af3d8
File tree
2 files changed
+71
-1
lines changed- Sources/Testing/SourceAttribution
- Tests/TestingTests
2 files changed
+71
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
325 | 350 | | |
326 | 351 | | |
327 | 352 | | |
328 | 353 | | |
329 | 354 | | |
330 | 355 | | |
| 356 | + | |
| 357 | + | |
331 | 358 | | |
332 | 359 | | |
333 | 360 | | |
| |||
369 | 396 | | |
370 | 397 | | |
371 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
372 | 402 | | |
373 | 403 | | |
374 | 404 | | |
| |||
379 | 409 | | |
380 | 410 | | |
381 | 411 | | |
382 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
383 | 420 | | |
384 | 421 | | |
385 | 422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
98 | 131 | | |
99 | 132 | | |
100 | 133 | | |
| |||
0 commit comments