Skip to content

Commit bc7fca6

Browse files
committed
Incorporate feedback removing version field
1 parent 00c3394 commit bc7fca6

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

Documentation/ABI/TestContent.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ testing library have the following layout:
4646
```swift
4747
typealias TestContentRecord = (
4848
kind: UInt32,
49-
version: UInt16,
50-
reserved1: UInt16,
49+
reserved1: UInt32,
5150
accessor: (@convention(c) (_ outValue: UnsafeMutableRawPointer, _ hint: UnsafeRawPointer?) -> CBool)?,
5251
context: UInt,
5352
reserved2: UInt
@@ -60,8 +59,7 @@ If needed, this type can be represented in C as a structure:
6059
```c
6160
struct SWTTestContentRecord {
6261
uint32_t kind;
63-
uint16_t version;
64-
uint16_t reserved1;
62+
uint32_t reserved1;
6563
bool (* _Nullable accessor)(void *outValue, const void *_Null_unspecified hint);
6664
uintptr_t context;
6765
uintptr_t reserved2;
@@ -84,11 +82,6 @@ record's kind is a 32-bit unsigned value. The following kinds are defined:
8482
<!-- When adding cases to this enumeration, be sure to also update the
8583
corresponding enumeration in TestContentGeneration.swift. -->
8684

87-
#### The version field
88-
89-
This field is currently always `0`. Implementations should ignore structures
90-
with other version values.
91-
9285
#### The accessor field
9386

9487
The function `accessor` is a C function. When called, it initializes the memory

Sources/Testing/Discovery.swift

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ private import _TestingInternals
1414
///
1515
/// - Parameters:
1616
/// - kind: The kind of this record.
17-
/// - version: The version of this record.
1817
/// - reserved1: Reserved for future use.
1918
/// - accessor: A function which, when called, produces the test content.
2019
/// - context: Kind-specific context for this record.
@@ -24,16 +23,12 @@ private import _TestingInternals
2423
/// directly.
2524
public typealias __TestContentRecord = (
2625
kind: UInt32,
27-
version: UInt16,
28-
reserved1: UInt16,
26+
reserved1: UInt32,
2927
accessor: (@convention(c) (_ outValue: UnsafeMutableRawPointer, _ hint: UnsafeRawPointer?) -> CBool)?,
3028
context: UInt,
3129
reserved2: UInt
3230
)
3331

34-
/// The current version of the `__TestContentRecord` type.
35-
private let _currentTestContentRecordVersion = UInt16(0)
36-
3732
/// Resign any pointers in a test content record.
3833
///
3934
/// - Parameters:
@@ -98,24 +93,12 @@ extension TestContent where Self: ~Copyable {
9893
private static func _testContentRecords(in sectionBounds: SectionBounds) -> some Sequence<(imageAddress: UnsafeRawPointer?, record: __TestContentRecord)> {
9994
sectionBounds.buffer.withMemoryRebound(to: __TestContentRecord.self) { records in
10095
records.lazy
101-
.filter { $0.version == _currentTestContentRecordVersion }
10296
.filter { $0.kind == testContentKind }
10397
.map(_resign)
10498
.map { (sectionBounds.imageAddress, $0) }
10599
}
106100
}
107101

108-
/// Enumerate all test content records found in all test content sections in
109-
/// the current process that match this ``TestContent`` type.
110-
///
111-
/// - Returns: A sequence of tuples. Each tuple contains an instance of
112-
/// `__TestContentRecord` and the base address of the image containing that
113-
/// test content record. Only test content records matching this
114-
/// ``TestContent`` type's requirements are included in the sequence.
115-
private static func _testContentRecords() -> some Sequence<(imageAddress: UnsafeRawPointer?, record: __TestContentRecord)> {
116-
SectionBounds.allTestContent.lazy.flatMap(_testContentRecords(in:))
117-
}
118-
119102
/// Call the given accessor function.
120103
///
121104
/// - Parameters:
@@ -177,8 +160,10 @@ extension TestContent where Self: ~Copyable {
177160
/// is used with move-only types (specifically ``ExitTest``) and
178161
/// `Sequence.Element` must be copyable.
179162
static func enumerateTestContent(withHint hint: TestContentAccessorHint? = nil, _ body: TestContentEnumerator) {
163+
let testContentRecords = SectionBounds.allTestContent.lazy.flatMap(_testContentRecords(in:))
164+
180165
var stop = false
181-
for (imageAddress, record) in _testContentRecords() {
166+
for (imageAddress, record) in testContentRecords {
182167
if let accessor = record.accessor, let result = _callAccessor(accessor, withHint: hint) {
183168
// Call the callback.
184169
body(imageAddress, result, record.context, &stop)

Sources/TestingMacros/Support/TestContentGeneration.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ func makeTestContentRecordDecl(named name: TokenSyntax, in typeName: TypeSyntax?
8282
private \(staticKeyword(for: typeName)) let \(name): Testing.__TestContentRecord = (
8383
\(kindExpr),\(kindComment)
8484
0,
85-
0,
8685
\(accessorName),
8786
\(contextExpr),
8887
0

0 commit comments

Comments
 (0)