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
Relax the alignment requirement for DiscoverableAsTestContent.Context. (#1076)
This PR allows `DiscoverableAsTestContent.Context` to be less-aligned
than `UInt` so long as its stride remains the same. It also removes the
sneaky conformance of `ExitTest` to `DiscoverableAsTestContent`, opting
instead to use an internal type. Since the conformance to
`DiscoverableAsTestContent` and the implementation of `__store()` form a
closed system (where all type information is controlled by Swift Testing
at runtime), we can do this without breaking any ABI. I've updated
ABI/TestContent.md to remove some of the relevant implementation
details.
### 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.
---------
Co-authored-by: Stuart Montgomery <[email protected]>
Copy file name to clipboardExpand all lines: Documentation/ABI/TestContent.md
+7-19Lines changed: 7 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -149,25 +149,12 @@ The fourth argument to this function, `reserved`, is reserved for future use.
149
149
Accessor functions should assume it is `0` and must not access it.
150
150
151
151
The concrete Swift type of the value written to `outValue`, the type pointed to
152
-
by `type`, and the value pointed to by `hint` depend on the kind of record:
152
+
by `type`, and the value pointed to by `hint` depend on the kind of record.
153
153
154
-
- For test or suite declarations (kind `0x74657374`), the accessor produces a
155
-
structure of type `Testing.Test.Generator` that the testing library can use
156
-
to generate the corresponding test[^notAccessorSignature].
157
-
158
-
[^notAccessorSignature]: This level of indirection is necessary because
159
-
loading a test or suite declaration is an asynchronous operation, but C
160
-
functions cannot be `async`.
161
-
162
-
Test content records of this kind do not specify a type for `hint`. Always
163
-
pass `nil`.
164
-
165
-
- For exit test declarations (kind `0x65786974`), the accessor produces a
166
-
structure describing the exit test (of type `Testing.ExitTest`.)
167
-
168
-
Test content records of this kind accept a `hint` of type `Testing.ExitTest.ID`.
169
-
They only produce a result if they represent an exit test declared with the
170
-
same ID (or if `hint` is `nil`.)
154
+
The record kinds defined by Swift Testing (kinds `0x74657374` and `0x65786974`)
155
+
make use of the `DiscoverableAsTestContent` protocol in the `_TestDiscovery`
156
+
module and do not publicly expose the types of their accessor functions'
157
+
arguments. Do not call the accessor functions for these records directly.
171
158
172
159
> [!WARNING]
173
160
> Calling code should use [`withUnsafeTemporaryAllocation(of:capacity:_:)`](https://developer.apple.com/documentation/swift/withunsafetemporaryallocation(of:capacity:_:))
precondition(MemoryLayout<TestContentContext>.stride == MemoryLayout<UInt>.stride,"'\(self).TestContentContext' aka '\(TestContentContext.self)' must have the same stride as 'UInt'.")
55
-
precondition(MemoryLayout<TestContentContext>.alignment == MemoryLayout<UInt>.alignment,"'\(self).TestContentContext' aka '\(TestContentContext.self)' must have the same alignment as 'UInt'.")
55
+
precondition(MemoryLayout<TestContentContext>.alignment <= MemoryLayout<UInt>.alignment,"'\(self).TestContentContext' aka '\(TestContentContext.self)' must have an alignment less than or equal to that of 'UInt'.")
0 commit comments