You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Limit the amount of value reflection data expectation checking collects by default (#915)
This modifies the internal logic which recursively collects reflection
data about values passed to `#expect(...)` and similar expectation APIs
so that it imposes an artificial limit on the amount of data collected.
### Motivation:
Some users have attempted to use `#expect` with instances of values with
large collections or with deep value hierarchies involving many
sub-properties, etc. In these situations they have noticed that the
automatic value reflection is adding a noticeable amount of overhead to
the overall test execution time, and would like to reduce that by
default (near term), as well as have some ability to control that so the
behavior could be tweaked for particular tests (in the future).
### Modifications:
- Add some new `Configuration` properties controlling data collection
behaviors and setting default limits.
- Consult these new configuration properties in the relevant places in
`Expression.Value`.
- Make `Expression.Value.init(reflecting:)` optional and return `nil`
when value reflection is disabled in the configuration.
- Add a new initializer `Expression.Value.init(describing:)` as a
lighter-weight alternative to `init(reflecting:)` which only forms a
string description of its subject, and adopt this as a fallback in
places affected by the new optional in the previous bullet.
- Add representative new unit tests.
### 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.
Fixes rdar://138208832
0 commit comments