-
Notifications
You must be signed in to change notification settings - Fork 102
Fix crash when loading test content records from the type metadata section. #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,35 +11,37 @@ | |
#if !SWT_NO_LEGACY_TEST_DISCOVERY | ||
@_spi(Experimental) @_spi(ForToolsIntegrationOnly) internal import _TestDiscovery | ||
|
||
/// A shadow declaration of `_TestDiscovery.TestContentRecordContainer` that | ||
/// allows us to add public conformances to it without causing the | ||
/// `_TestDiscovery` module to appear in `Testing.private.swiftinterface`. | ||
/// | ||
/// This protocol is not part of the public interface of the testing library. | ||
@_alwaysEmitConformanceMetadata | ||
protocol TestContentRecordContainer: _TestDiscovery.TestContentRecordContainer {} | ||
|
||
/// An abstract base class describing a type that contains tests. | ||
/// A protocol base class describing a type that contains tests. | ||
/// | ||
/// - Warning: This class is used to implement the `@Test` macro. Do not use it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo here fixed on main already. |
||
/// directly. | ||
open class __TestContentRecordContainer: TestContentRecordContainer { | ||
/// The corresponding test content record. | ||
@_alwaysEmitConformanceMetadata | ||
public protocol __TestContentRecordContainer { | ||
/// The test content record associated with this container. | ||
/// | ||
/// - Warning: This property is used to implement the `@Test` macro. Do not | ||
/// use it directly. | ||
open nonisolated class var __testContentRecord: __TestContentRecord { | ||
(0, 0, nil, 0, 0) | ||
} | ||
nonisolated static var __testContentRecord: __TestContentRecord { get } | ||
} | ||
|
||
extension DiscoverableAsTestContent where Self: ~Copyable { | ||
/// Get all test content of this type known to Swift and found in the current | ||
/// process using the legacy discovery mechanism. | ||
/// | ||
/// - Returns: A sequence of instances of ``TestContentRecord``. Only test | ||
/// content records matching this ``TestContent`` type's requirements are | ||
/// included in the sequence. | ||
static func allTypeMetadataBasedTestContentRecords() -> AnySequence<TestContentRecord<Self>> { | ||
return allTypeMetadataBasedTestContentRecords { type, buffer in | ||
guard let type = type as? any __TestContentRecordContainer.Type else { | ||
return false | ||
} | ||
|
||
static func storeTestContentRecord(to outTestContentRecord: UnsafeMutableRawPointer) -> Bool { | ||
outTestContentRecord.withMemoryRebound(to: __TestContentRecord.self, capacity: 1) { outTestContentRecord in | ||
outTestContentRecord.initialize(to: __testContentRecord) | ||
buffer.withMemoryRebound(to: __TestContentRecord.self) { buffer in | ||
buffer.baseAddress!.initialize(to: type.__testContentRecord) | ||
} | ||
return true | ||
} | ||
} | ||
} | ||
|
||
@available(*, unavailable) | ||
extension __TestContentRecordContainer: Sendable {} | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here fixed on main already.