Skip to content

Commit aee0821

Browse files
authored
Fix statically-linked platforms building new test content discovery code. (#897)
This PR fixes an undefined symbol error for `SWTTestContentSectionBounds` when building for statically-linked platforms. This issue appears to only occur with CMake and is (I think) a quirk of that build system. ### 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 de09c23 commit aee0821

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Sources/Testing/Discovery+Platform.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private func _testContentSectionBounds() -> [SectionBounds] {
210210
/// contained in the same image as the testing library itself.
211211
private func _testContentSectionBounds() -> CollectionOfOne<SectionBounds> {
212212
let (sectionBegin, sectionEnd) = SWTTestContentSectionBounds
213-
let buffer = UnsafeRawBufferPointer(start: n, count: max(0, sectionEnd - sectionBegin))
213+
let buffer = UnsafeRawBufferPointer(start: sectionBegin, count: max(0, sectionEnd - sectionBegin))
214214
let sb = SectionBounds(imageAddress: nil, buffer: buffer)
215215
return CollectionOfOne(sb)
216216
}

Sources/_TestingInternals/include/Discovery.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ SWT_IMPORT_FROM_STDLIB void swift_enumerateAllMetadataSections(
6262
);
6363
#endif
6464

65-
#if defined(SWT_NO_DYNAMIC_LINKING)
6665
#pragma mark - Statically-linked section bounds
6766

6867
/// The bounds of the test content section statically linked into the image
6968
/// containing Swift Testing.
69+
///
70+
/// - Note: This symbol is _declared_, but not _defined_, on platforms with
71+
/// dynamic linking because the `SWT_NO_DYNAMIC_LINKING` C++ macro (not the
72+
/// Swift compiler conditional of the same name) is not consistently declared
73+
/// when Swift files import the `_TestingInternals` C++ module.
7074
SWT_EXTERN const void *_Nonnull const SWTTestContentSectionBounds[2];
71-
#endif
7275

7376
#pragma mark - Legacy test discovery
7477

0 commit comments

Comments
 (0)