From 9152e8466372d8e4ecaa8fe94a7ec9a9dc115c31 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 11 Mar 2025 11:05:21 -0400 Subject: [PATCH] Remove legacy test content discovery. This PR removes the legacy test content discovery mechanism that is based on finding protocol conformances in the type metadata section emitted by the Swift compiler. --- Documentation/Porting.md | 17 +- Sources/Testing/CMakeLists.txt | 1 - Sources/Testing/ExitTests/ExitTest.swift | 9 - Sources/Testing/Test+Discovery+Legacy.swift | 47 ----- Sources/Testing/Test+Discovery.swift | 42 +--- Sources/TestingMacros/ConditionMacro.swift | 19 +- .../TestingMacros/SuiteDeclarationMacro.swift | 19 +- .../TestingMacros/TestDeclarationMacro.swift | 19 +- .../DiscoverableAsTestContent.swift | 13 -- Sources/_TestDiscovery/SectionBounds.swift | 33 --- .../_TestDiscovery/TestContentRecord.swift | 56 ----- Sources/_TestingInternals/CMakeLists.txt | 1 - Sources/_TestingInternals/Discovery.cpp | 191 ------------------ Sources/_TestingInternals/include/Stubs.h | 14 ++ .../TestDeclarationMacroTests.swift | 3 - Tests/TestingTests/DiscoveryTests.swift | 17 -- 16 files changed, 27 insertions(+), 474 deletions(-) delete mode 100644 Sources/Testing/Test+Discovery+Legacy.swift delete mode 100644 Sources/_TestingInternals/Discovery.cpp diff --git a/Documentation/Porting.md b/Documentation/Porting.md index 6e83e0eb0..a6b725e2e 100644 --- a/Documentation/Porting.md +++ b/Documentation/Porting.md @@ -145,10 +145,6 @@ to load that information: + let resourceName: Str255 = switch kind { + case .testContent: + "__swift5_tests" -+#if !SWT_NO_LEGACY_TEST_DISCOVERY -+ case .typeMetadata: -+ "__swift5_types" -+#endif + } + + let oldRefNum = CurResFile() @@ -214,9 +210,8 @@ start with `"SWT_"`). If your platform does not support dynamic linking and loading, you will need to use static linkage instead. Define the `"SWT_NO_DYNAMIC_LINKING"` compiler conditional for your platform in both `Package.swift` and -`CompilerSettings.cmake`, then define the symbols `_testContentSectionBegin`, -`_testContentSectionEnd`, `_typeMetadataSectionBegin`, and -`_typeMetadataSectionEnd` in `SectionBounds.swift`: +`CompilerSettings.cmake`, then define the symbols `_testContentSectionBegin` and +`_testContentSectionEnd` in `SectionBounds.swift`: ```diff --- a/Sources/_TestDiscovery/SectionBounds.swift @@ -225,18 +220,10 @@ conditional for your platform in both `Package.swift` and +#elseif os(Classic) +@_silgen_name(raw: "...") private nonisolated(unsafe) var _testContentSectionBegin: _SectionBound +@_silgen_name(raw: "...") private nonisolated(unsafe) var _testContentSectionEnd: _SectionBound -+#if !SWT_NO_LEGACY_TEST_DISCOVERY -+@_silgen_name(raw: "...") private nonisolated(unsafe) var _typeMetadataSectionBegin: _SectionBound -+@_silgen_name(raw: "...") private nonisolated(unsafe) var _typeMetadataSectionEnd: _SectionBound -+#endif #else #warning("Platform-specific implementation missing: Runtime test discovery unavailable (static)") private nonisolated(unsafe) let _testContentSectionBegin = UnsafeMutableRawPointer.allocate(byteCount: 1, alignment: 16) private nonisolated(unsafe) let _testContentSectionEnd = _testContentSectionBegin - #if !SWT_NO_LEGACY_TEST_DISCOVERY - private nonisolated(unsafe) let _typeMetadataSectionBegin = UnsafeMutableRawPointer.allocate(byteCount: 1, alignment: 16) - private nonisolated(unsafe) let _typeMetadataSectionEnd = _typeMetadataSectionBegin - #endif #endif // ... ``` diff --git a/Sources/Testing/CMakeLists.txt b/Sources/Testing/CMakeLists.txt index 7e07636d5..78862ecfe 100644 --- a/Sources/Testing/CMakeLists.txt +++ b/Sources/Testing/CMakeLists.txt @@ -88,7 +88,6 @@ add_library(Testing Test.ID.swift Test.swift Test+Discovery.swift - Test+Discovery+Legacy.swift Test+Macro.swift Traits/Bug.swift Traits/Comment.swift diff --git a/Sources/Testing/ExitTests/ExitTest.swift b/Sources/Testing/ExitTests/ExitTest.swift index 69346b74e..6ae2f82c1 100644 --- a/Sources/Testing/ExitTests/ExitTest.swift +++ b/Sources/Testing/ExitTests/ExitTest.swift @@ -296,15 +296,6 @@ extension ExitTest { } } -#if !SWT_NO_LEGACY_TEST_DISCOVERY - // Call the legacy lookup function that discovers tests embedded in types. - for record in Self.allTypeMetadataBasedTestContentRecords() { - if let exitTest = record.load(withHint: id) { - return exitTest - } - } -#endif - return nil } } diff --git a/Sources/Testing/Test+Discovery+Legacy.swift b/Sources/Testing/Test+Discovery+Legacy.swift deleted file mode 100644 index 8ff878338..000000000 --- a/Sources/Testing/Test+Discovery+Legacy.swift +++ /dev/null @@ -1,47 +0,0 @@ -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for Swift project authors -// - -#if !SWT_NO_LEGACY_TEST_DISCOVERY -@_spi(Experimental) @_spi(ForToolsIntegrationOnly) internal import _TestDiscovery - -/// A protocol describing a type that contains tests. -/// -/// - Warning: This protocol is used to implement the `@Test` macro. Do not use -/// it directly. -@_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. - 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> { - return allTypeMetadataBasedTestContentRecords { type, buffer in - guard let type = type as? any __TestContentRecordContainer.Type else { - return false - } - - buffer.withMemoryRebound(to: __TestContentRecord.self) { buffer in - buffer.baseAddress!.initialize(to: type.__testContentRecord) - } - return true - } - } -} -#endif diff --git a/Sources/Testing/Test+Discovery.swift b/Sources/Testing/Test+Discovery.swift index 5d1b204ae..17d8f13d2 100644 --- a/Sources/Testing/Test+Discovery.swift +++ b/Sources/Testing/Test+Discovery.swift @@ -61,47 +61,15 @@ extension Test { // defective test records.) var result = Set() - // Figure out which discovery mechanism to use. By default, we'll use both - // the legacy and new mechanisms, but we can set an environment variable - // to explicitly select one or the other. When we remove legacy support, - // we can also remove this enumeration and environment variable check. -#if !SWT_NO_LEGACY_TEST_DISCOVERY - let (useNewMode, useLegacyMode) = switch Environment.flag(named: "SWT_USE_LEGACY_TEST_DISCOVERY") { - case .none: - (true, true) - case .some(true): - (false, true) - case .some(false): - (true, false) - } -#else - let useNewMode = true -#endif - // Walk all test content and gather generator functions, then call them in // a task group and collate their results. - if useNewMode { - let generators = Generator.allTestContentRecords().lazy.compactMap { $0.load() } - await withTaskGroup(of: Self.self) { taskGroup in - for generator in generators { - taskGroup.addTask { await generator.rawValue() } - } - result = await taskGroup.reduce(into: result) { $0.insert($1) } - } - } - -#if !SWT_NO_LEGACY_TEST_DISCOVERY - // Perform legacy test discovery if needed. - if useLegacyMode && result.isEmpty { - let generators = Generator.allTypeMetadataBasedTestContentRecords().lazy.compactMap { $0.load() } - await withTaskGroup(of: Self.self) { taskGroup in - for generator in generators { - taskGroup.addTask { await generator.rawValue() } - } - result = await taskGroup.reduce(into: result) { $0.insert($1) } + let generators = Generator.allTestContentRecords().lazy.compactMap { $0.load() } + await withTaskGroup(of: Self.self) { taskGroup in + for generator in generators { + taskGroup.addTask { await generator.rawValue() } } + result = await taskGroup.reduce(into: result) { $0.insert($1) } } -#endif return result } diff --git a/Sources/TestingMacros/ConditionMacro.swift b/Sources/TestingMacros/ConditionMacro.swift index 89498e1ec..2702d1ccf 100644 --- a/Sources/TestingMacros/ConditionMacro.swift +++ b/Sources/TestingMacros/ConditionMacro.swift @@ -12,8 +12,8 @@ public import SwiftSyntax import SwiftSyntaxBuilder public import SwiftSyntaxMacros -#if !hasFeature(SymbolLinkageMarkers) && SWT_NO_LEGACY_TEST_DISCOVERY -#error("Platform-specific misconfiguration: either SymbolLinkageMarkers or legacy test discovery is required to expand #expect(exitsWith:)") +#if !hasFeature(SymbolLinkageMarkers) +#error("Platform-specific misconfiguration: SymbolLinkageMarkers is required to expand #expect(exitsWith:)") #endif /// A protocol containing the common implementation for the expansions of the @@ -467,19 +467,6 @@ extension ExitTestConditionMacro { accessingWith: .identifier("accessor") ) - // Create another local type for legacy test discovery. - var recordDecl: DeclSyntax? -#if !SWT_NO_LEGACY_TEST_DISCOVERY - let legacyEnumName = context.makeUniqueName("__🟡$") - recordDecl = """ - enum \(legacyEnumName): Testing.__TestContentRecordContainer { - nonisolated static var __testContentRecord: Testing.__TestContentRecord { - \(enumName).testContentRecord - } - } - """ -#endif - decls.append( """ @available(*, deprecated, message: "This type is an implementation detail of the testing library. Do not use it directly.") @@ -495,8 +482,6 @@ extension ExitTestConditionMacro { } \(testContentRecordDecl) - - \(recordDecl) } """ ) diff --git a/Sources/TestingMacros/SuiteDeclarationMacro.swift b/Sources/TestingMacros/SuiteDeclarationMacro.swift index 60a276689..f14526bf5 100644 --- a/Sources/TestingMacros/SuiteDeclarationMacro.swift +++ b/Sources/TestingMacros/SuiteDeclarationMacro.swift @@ -13,8 +13,8 @@ public import SwiftSyntax import SwiftSyntaxBuilder public import SwiftSyntaxMacros -#if !hasFeature(SymbolLinkageMarkers) && SWT_NO_LEGACY_TEST_DISCOVERY -#error("Platform-specific misconfiguration: either SymbolLinkageMarkers or legacy test discovery is required to expand @Suite") +#if !hasFeature(SymbolLinkageMarkers) +#error("Platform-specific misconfiguration: SymbolLinkageMarkers is required to expand @Suite") #endif /// A type describing the expansion of the `@Suite` attribute macro. @@ -166,21 +166,6 @@ public struct SuiteDeclarationMacro: MemberMacro, PeerMacro, Sendable { ) ) -#if !SWT_NO_LEGACY_TEST_DISCOVERY - // Emit a type that contains a reference to the test content record. - let enumName = context.makeUniqueName("__🟡$") - result.append( - """ - @available(*, deprecated, message: "This type is an implementation detail of the testing library. Do not use it directly.") - enum \(enumName): Testing.__TestContentRecordContainer { - nonisolated static var __testContentRecord: Testing.__TestContentRecord { - \(testContentRecordName) - } - } - """ - ) -#endif - return result } } diff --git a/Sources/TestingMacros/TestDeclarationMacro.swift b/Sources/TestingMacros/TestDeclarationMacro.swift index 2a4da4e3c..12f1a2247 100644 --- a/Sources/TestingMacros/TestDeclarationMacro.swift +++ b/Sources/TestingMacros/TestDeclarationMacro.swift @@ -13,8 +13,8 @@ public import SwiftSyntax import SwiftSyntaxBuilder public import SwiftSyntaxMacros -#if !hasFeature(SymbolLinkageMarkers) && SWT_NO_LEGACY_TEST_DISCOVERY -#error("Platform-specific misconfiguration: either SymbolLinkageMarkers or legacy test discovery is required to expand @Test") +#if !hasFeature(SymbolLinkageMarkers) +#error("Platform-specific misconfiguration: SymbolLinkageMarkers is required to expand @Test") #endif /// A type describing the expansion of the `@Test` attribute macro. @@ -491,21 +491,6 @@ public struct TestDeclarationMacro: PeerMacro, Sendable { ) ) -#if !SWT_NO_LEGACY_TEST_DISCOVERY - // Emit a type that contains a reference to the test content record. - let enumName = context.makeUniqueName(thunking: functionDecl, withPrefix: "__🟡$") - result.append( - """ - @available(*, deprecated, message: "This type is an implementation detail of the testing library. Do not use it directly.") - enum \(enumName): Testing.__TestContentRecordContainer { - nonisolated static var __testContentRecord: Testing.__TestContentRecord { - \(testContentRecordName) - } - } - """ - ) -#endif - return result } } diff --git a/Sources/_TestDiscovery/DiscoverableAsTestContent.swift b/Sources/_TestDiscovery/DiscoverableAsTestContent.swift index a4b400bad..49d6eed41 100644 --- a/Sources/_TestDiscovery/DiscoverableAsTestContent.swift +++ b/Sources/_TestDiscovery/DiscoverableAsTestContent.swift @@ -39,17 +39,4 @@ public protocol DiscoverableAsTestContent: Sendable, ~Copyable { /// By default, this type equals `Never`, indicating that this type of test /// content does not support hinting during discovery. associatedtype TestContentAccessorHint = Never - -#if !SWT_NO_LEGACY_TEST_DISCOVERY - /// A string present in the names of types containing test content records - /// associated with this type. - @available(swift, deprecated: 100000.0, message: "Do not adopt this functionality in new code. It will be removed in a future release.") - static var _testContentTypeNameHint: String { get } -#endif -} - -extension DiscoverableAsTestContent where Self: ~Copyable { - public static var _testContentTypeNameHint: String { - "__🟡$" - } } diff --git a/Sources/_TestDiscovery/SectionBounds.swift b/Sources/_TestDiscovery/SectionBounds.swift index 1a3ae8e11..7d34f224e 100644 --- a/Sources/_TestDiscovery/SectionBounds.swift +++ b/Sources/_TestDiscovery/SectionBounds.swift @@ -26,11 +26,6 @@ struct SectionBounds: Sendable { enum Kind: Equatable, Hashable, CaseIterable { /// The test content metadata section. case testContent - -#if !SWT_NO_LEGACY_TEST_DISCOVERY - /// The type metadata section. - case typeMetadata -#endif } /// All section bounds of the given kind found in the current process. @@ -61,10 +56,6 @@ extension SectionBounds.Kind { switch self { case .testContent: ("__DATA_CONST", "__swift5_tests") -#if !SWT_NO_LEGACY_TEST_DISCOVERY - case .typeMetadata: - ("__TEXT", "__swift5_types") -#endif } } } @@ -189,10 +180,6 @@ private func _sectionBounds(_ kind: SectionBounds.Kind) -> [SectionBounds] { let range = switch context.pointee.kind { case .testContent: sections.swift5_tests -#if !SWT_NO_LEGACY_TEST_DISCOVERY - case .typeMetadata: - sections.swift5_type_metadata -#endif } let start = UnsafeRawPointer(bitPattern: range.start) let size = Int(clamping: range.length) @@ -284,10 +271,6 @@ private func _sectionBounds(_ kind: SectionBounds.Kind) -> some Sequence
CollectionOfOne Bool - ) -> AnySequence> { - validateMemoryLayout() - - let typeNameHint = _testContentTypeNameHint - let kind = testContentKind.rawValue - let loader: @Sendable (Any.Type) -> _TestContentRecord? = { type in - withUnsafeTemporaryAllocation(of: _TestContentRecord.self, capacity: 1) { buffer in - // Load the record from the container type. - guard loader(type, .init(buffer)) else { - return nil - } - return buffer.baseAddress!.move() - } - } - - let result = SectionBounds.all(.typeMetadata).lazy.flatMap { sb in - stride(from: 0, to: sb.buffer.count, by: SWTTypeMetadataRecordByteCount).lazy - .map { sb.buffer.baseAddress! + $0 } - .compactMap { swt_getType(fromTypeMetadataRecord: $0, ifNameContains: typeNameHint) } - .map { unsafeBitCast($0, to: Any.Type.self) } - .compactMap(loader) - .filter { $0.kind == kind } - .map { TestContentRecord(imageAddress: sb.imageAddress, record: $0) } - } - return AnySequence(result) - } -} -#endif diff --git a/Sources/_TestingInternals/CMakeLists.txt b/Sources/_TestingInternals/CMakeLists.txt index 16713ab27..b0d4eb047 100644 --- a/Sources/_TestingInternals/CMakeLists.txt +++ b/Sources/_TestingInternals/CMakeLists.txt @@ -11,7 +11,6 @@ set(CMAKE_CXX_SCAN_FOR_MODULES 0) include(LibraryVersion) include(TargetTriple) add_library(_TestingInternals STATIC - Discovery.cpp Versions.cpp WillThrow.cpp) target_include_directories(_TestingInternals PUBLIC diff --git a/Sources/_TestingInternals/Discovery.cpp b/Sources/_TestingInternals/Discovery.cpp deleted file mode 100644 index 1e70a038d..000000000 --- a/Sources/_TestingInternals/Discovery.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2023–2025 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for Swift project authors -// - -#include "Discovery.h" - -#if !defined(SWT_NO_LEGACY_TEST_DISCOVERY) -#include -#include -#include - -#pragma mark - Swift ABI - -#if defined(__PTRAUTH_INTRINSICS__) -#include -#define SWT_PTRAUTH_SWIFT_TYPE_DESCRIPTOR __ptrauth(ptrauth_key_process_independent_data, 1, 0xae86) -#else -#define SWT_PTRAUTH_SWIFT_TYPE_DESCRIPTOR -#endif - -/// A type representing a pointer relative to itself. -/// -/// This type is derived from `RelativeDirectPointerIntPair` in the Swift -/// repository. -template -struct SWTRelativePointer { -private: - int32_t _offset; - -public: - SWTRelativePointer(const SWTRelativePointer&) = delete; - SWTRelativePointer(const SWTRelativePointer&&) = delete; - SWTRelativePointer& operator =(const SWTRelativePointer&) = delete; - SWTRelativePointer& operator =(const SWTRelativePointer&&) = delete; - - int32_t getRawValue(void) const { - return _offset; - } - - const T *_Nullable get(void) const& { - int32_t maskedOffset = getRawValue() & ~maskValue; - if (maskedOffset == 0) { - return nullptr; - } - - auto offset = static_cast(static_cast(maskedOffset)); - auto result = reinterpret_cast(reinterpret_cast(this) + offset); -#if defined(__PTRAUTH_INTRINSICS__) - if (std::is_function_v && result) { - result = ptrauth_strip(result, ptrauth_key_function_pointer); - result = ptrauth_sign_unauthenticated(result, ptrauth_key_function_pointer, 0); - } -#endif - return reinterpret_cast(result); - } -}; - -/// A type representing a 32-bit absolute function pointer, usually used on platforms -/// where relative function pointers are not supported. -/// -/// This type is derived from `AbsoluteFunctionPointer` in the Swift repository. -template -struct SWTAbsoluteFunctionPointer { -private: - T *_pointer; - static_assert(sizeof(T *) == sizeof(int32_t), "Function pointer must be 32-bit when using compact absolute pointer"); - -public: - const T *_Nullable get(void) const & { - return _pointer; - } -}; - -/// A type representing a pointer relative to itself with low bits reserved for -/// use as flags. -/// -/// This type is derived from `RelativeDirectPointerIntPair` in the Swift -/// repository. -template -struct SWTRelativePointerIntPair: public SWTRelativePointer { - I getInt() const & { - return I(this->getRawValue() & maskValue); - } -}; - -template -#if defined(__wasm32__) -using SWTCompactFunctionPointer = SWTAbsoluteFunctionPointer; -#else -using SWTCompactFunctionPointer = SWTRelativePointer; -#endif - -/// A type representing a metatype as constructed during compilation of a Swift -/// module. -/// -/// This type is derived from `TargetTypeContextDescriptor` in the Swift -/// repository. -struct SWTTypeContextDescriptor { -private: - uint32_t _flags; - SWTRelativePointer _parent; - SWTRelativePointer _name; - - struct MetadataAccessResponse { - void *value; - size_t state; - }; - using MetadataAccessFunction = __attribute__((swiftcall)) MetadataAccessResponse(size_t); - SWTCompactFunctionPointer _metadataAccessFunction; - -public: - const char *_Nullable getName(void) const& { - return _name.get(); - } - - void *_Nullable getMetadata(void) const& { - if (auto fp = _metadataAccessFunction.get()) { - return (* fp)(0xFF).value; - } - return nullptr; - } - - bool isGeneric(void) const& { - return (_flags & 0x80u) != 0; - } -}; - -/// A type representing a relative pointer to a type descriptor. -/// -/// This type is derived from `TargetTypeMetadataRecord` in the Swift -/// repository. -struct SWTTypeMetadataRecord { -private: - SWTRelativePointerIntPair _pointer; - -public: - const SWTTypeContextDescriptor *_Nullable getContextDescriptor(void) const { - switch (_pointer.getInt()) { - case 0: // Direct pointer. - return reinterpret_cast(_pointer.get()); - case 1: // Indirect pointer (pointer to a pointer.) - // The inner pointer is signed when pointer authentication - // instructions are available. - if (auto contextDescriptor = reinterpret_cast(_pointer.get())) { - return *contextDescriptor; - } - [[fallthrough]]; - default: // Unsupported or invalid. - return nullptr; - } - } -}; - -#pragma mark - Legacy test discovery - -const size_t SWTTypeMetadataRecordByteCount = sizeof(SWTTypeMetadataRecord); - -const void *swt_getTypeFromTypeMetadataRecord(const void *recordAddress, const char *nameSubstring) { - auto record = reinterpret_cast(recordAddress); - auto contextDescriptor = record->getContextDescriptor(); - if (!contextDescriptor) { - // This type metadata record is invalid (or we don't understand how to - // get its context descriptor), so skip it. - return nullptr; - } else if (contextDescriptor->isGeneric()) { - // Generic types cannot be fully instantiated without generic - // parameters, which is not something we can know abstractly. - return nullptr; - } - - // Check that the type's name passes. This will be more expensive than the - // checks above, but should be cheaper than realizing the metadata. - const char *typeName = contextDescriptor->getName(); - bool nameOK = typeName && nullptr != std::strstr(typeName, nameSubstring); - if (!nameOK) { - return nullptr; - } - - if (void *typeMetadata = contextDescriptor->getMetadata()) { - return typeMetadata; - } - - return nullptr; -} -#endif diff --git a/Sources/_TestingInternals/include/Stubs.h b/Sources/_TestingInternals/include/Stubs.h index 8093a3722..0addf791f 100644 --- a/Sources/_TestingInternals/include/Stubs.h +++ b/Sources/_TestingInternals/include/Stubs.h @@ -117,6 +117,20 @@ static char *_Nullable *_Null_unspecified swt_environ(void) { } #endif +#if defined(__ELF__) && defined(__swift__) +#pragma mark - ELF image enumeration + +/// A function exported by the Swift runtime that enumerates all metadata +/// sections loaded into the current process. +/// +/// This function is needed on ELF-based platforms because they do not preserve +/// section information that we can discover at runtime. +SWT_IMPORT_FROM_STDLIB void swift_enumerateAllMetadataSections( + bool (* body)(const void *sections, void *context), + void *context +); +#endif + #if !defined(__ANDROID__) #if __has_include() && defined(si_pid) /// Get the value of the `si_pid` field of a `siginfo_t` structure. diff --git a/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift b/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift index 13ae3d180..1f6a645ee 100644 --- a/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift +++ b/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift @@ -411,9 +411,6 @@ struct TestDeclarationMacroTests { #if hasFeature(SymbolLinkageMarkers) #expect(output.contains("@_section")) -#endif -#if !SWT_NO_LEGACY_TEST_DISCOVERY - #expect(output.contains("__TestContentRecordContainer")) #endif if let expectedTypeName { #expect(output.contains(expectedTypeName)) diff --git a/Tests/TestingTests/DiscoveryTests.swift b/Tests/TestingTests/DiscoveryTests.swift index a730f8b53..a5e2ef1e3 100644 --- a/Tests/TestingTests/DiscoveryTests.swift +++ b/Tests/TestingTests/DiscoveryTests.swift @@ -141,21 +141,4 @@ struct DiscoveryTests { }) } #endif - -#if !SWT_NO_LEGACY_TEST_DISCOVERY && hasFeature(SymbolLinkageMarkers) - @Test("Legacy test discovery finds the same number of tests") func discoveredTestCount() async { - let oldFlag = Environment.variable(named: "SWT_USE_LEGACY_TEST_DISCOVERY") - defer { - Environment.setVariable(oldFlag, named: "SWT_USE_LEGACY_TEST_DISCOVERY") - } - - Environment.setVariable("1", named: "SWT_USE_LEGACY_TEST_DISCOVERY") - let testsWithOldCode = await Array(Test.all).count - - Environment.setVariable("0", named: "SWT_USE_LEGACY_TEST_DISCOVERY") - let testsWithNewCode = await Array(Test.all).count - - #expect(testsWithOldCode == testsWithNewCode) - } -#endif }