diff --git a/.spi.yml b/.spi.yml index 499333a91..a85a01a68 100644 --- a/.spi.yml +++ b/.spi.yml @@ -3,8 +3,6 @@ metadata: authors: Apple Inc. builder: configs: - - swift_version: 5.10 - scheme: Testing - swift_version: 6.0 documentation_targets: [Testing] scheme: Testing diff --git a/Package.swift b/Package.swift index 374bbecbf..f7c10561d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.10 +// swift-tools-version: 6.0 // // This source file is part of the Swift.org open source project @@ -33,7 +33,7 @@ let package = Package( ], dependencies: [ - .package(url: "https://github.com/apple/swift-syntax.git", from: Version(stringLiteral: Context.environment["SWT_SWIFT_SYNTAX_VERSION"] ?? "600.0.0-latest")), + .package(url: "https://github.com/apple/swift-syntax.git", from: "600.0.0-latest"), ], targets: [ @@ -121,7 +121,6 @@ extension Array where Element == PackageDescription.SwiftSetting { .unsafeFlags(["-require-explicit-sendable"]), .enableExperimentalFeature("StrictConcurrency"), .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("InferSendableFromCaptures"), .enableExperimentalFeature("AccessLevelOnImport"), .enableUpcomingFeature("InternalImportsByDefault"), @@ -155,8 +154,20 @@ extension Array where Element == PackageDescription.CXXSetting { /// Settings intended to be applied to every C++ target in this package. /// Analogous to project-level build settings in an Xcode project. static var packageSettings: Self { - [ - .define("_SWT_TESTING_LIBRARY_VERSION", to: #""unknown (Swift 5.10 toolchain)""#), - ] + var result = Self() + + // Capture the testing library's version as a C++ string constant. + if let git = Context.gitInformation { + let testingLibraryVersion = if let tag = git.currentTag { + tag + } else if git.hasUncommittedChanges { + "\(git.currentCommit) (modified)" + } else { + git.currentCommit + } + result.append(.define("_SWT_TESTING_LIBRARY_VERSION", to: #""\#(testingLibraryVersion)""#)) + } + + return result } } diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift deleted file mode 100644 index 05312c616..000000000 --- a/Package@swift-6.0.swift +++ /dev/null @@ -1,173 +0,0 @@ -// swift-tools-version: 6.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 -// - -import PackageDescription -import CompilerPluginSupport - -let package = Package( - name: "swift-testing", - - platforms: [ - .macOS(.v10_15), - .iOS(.v13), - .watchOS(.v6), - .tvOS(.v13), - .macCatalyst(.v13), - .visionOS(.v1), - ], - - products: [ - .library( - name: "Testing", - targets: ["Testing"] - ), - ], - - dependencies: [ - .package(url: "https://github.com/apple/swift-syntax.git", from: Version(stringLiteral: Context.environment["SWT_SWIFT_SYNTAX_VERSION"] ?? "600.0.0-latest")), - ], - - targets: [ - .target( - name: "Testing", - dependencies: [ - "_TestingInternals", - "TestingMacros", - ], - exclude: ["CMakeLists.txt"], - cxxSettings: .packageSettings, - swiftSettings: .packageSettings - ), - .testTarget( - name: "TestingTests", - dependencies: [ - "Testing", - "_Testing_Foundation", - ], - swiftSettings: .packageSettings - ), - - .macro( - name: "TestingMacros", - dependencies: [ - .product(name: "SwiftDiagnostics", package: "swift-syntax"), - .product(name: "SwiftSyntax", package: "swift-syntax"), - .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), - .product(name: "SwiftParser", package: "swift-syntax"), - .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), - .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), - ], - exclude: ["CMakeLists.txt"], - swiftSettings: .packageSettings + [ - // The only target which needs the ability to import this macro - // implementation target's module is its unit test target. Users of the - // macros this target implements use them via their declarations in the - // Testing module. This target's module is never distributed to users, - // but as an additional guard against accidental misuse, this specifies - // the unit test target as the only allowable client. - .unsafeFlags(["-Xfrontend", "-allowable-client", "-Xfrontend", "TestingMacrosTests"]), - ] - ), - - // "Support" targets: These contain C family code and are used exclusively - // by other targets above, not directly included in product libraries. - .target( - name: "_TestingInternals", - exclude: ["CMakeLists.txt"], - cxxSettings: .packageSettings - ), - - // Cross-module overlays (unsupported) - .target( - name: "_Testing_Foundation", - dependencies: [ - "Testing", - ], - swiftSettings: .packageSettings - ), - ], - - cxxLanguageStandard: .cxx20 -) - -// BUG: swift-package-manager-#6367 -#if !os(Windows) -package.targets.append(contentsOf: [ - .testTarget( - name: "TestingMacrosTests", - dependencies: [ - "Testing", - "TestingMacros", - ], - swiftSettings: .packageSettings - ) -]) -#endif - -extension Array where Element == PackageDescription.SwiftSetting { - /// Settings intended to be applied to every Swift target in this package. - /// Analogous to project-level build settings in an Xcode project. - static var packageSettings: Self { - availabilityMacroSettings + [ - .unsafeFlags(["-require-explicit-sendable"]), - .enableExperimentalFeature("StrictConcurrency"), - .enableUpcomingFeature("ExistentialAny"), - - .enableExperimentalFeature("AccessLevelOnImport"), - .enableUpcomingFeature("InternalImportsByDefault"), - - .define("SWT_TARGET_OS_APPLE", .when(platforms: [.macOS, .iOS, .macCatalyst, .watchOS, .tvOS, .visionOS])), - - .define("SWT_NO_FILE_IO", .when(platforms: [.wasi])), - .define("SWT_NO_EXIT_TESTS", .when(platforms: [.iOS, .watchOS, .tvOS, .visionOS, .wasi])), - ] - } - - /// Settings which define commonly-used OS availability macros. - /// - /// These leverage a pseudo-experimental feature in the Swift compiler for - /// setting availability definitions, which was added in - /// [apple/swift#65218](https://github.com/apple/swift/pull/65218). - private static var availabilityMacroSettings: Self { - [ - .enableExperimentalFeature("AvailabilityMacro=_mangledTypeNameAPI:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0"), - .enableExperimentalFeature("AvailabilityMacro=_backtraceAsyncAPI:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0"), - .enableExperimentalFeature("AvailabilityMacro=_clockAPI:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0"), - .enableExperimentalFeature("AvailabilityMacro=_regexAPI:macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0"), - .enableExperimentalFeature("AvailabilityMacro=_swiftVersionAPI:macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0"), - - .enableExperimentalFeature("AvailabilityMacro=_distantFuture:macOS 99.0, iOS 99.0, watchOS 99.0, tvOS 99.0"), - ] - } -} - -extension Array where Element == PackageDescription.CXXSetting { - /// Settings intended to be applied to every C++ target in this package. - /// Analogous to project-level build settings in an Xcode project. - static var packageSettings: Self { - var result = Self() - - // Capture the testing library's version as a C++ string constant. - if let git = Context.gitInformation { - let testingLibraryVersion = if let tag = git.currentTag { - tag - } else if git.hasUncommittedChanges { - "\(git.currentCommit) (modified)" - } else { - git.currentCommit - } - result.append(.define("_SWT_TESTING_LIBRARY_VERSION", to: #""\#(testingLibraryVersion)""#)) - } - - return result - } -} diff --git a/README.md b/README.md index 20bf086d1..041877bc3 100644 --- a/README.md +++ b/README.md @@ -93,15 +93,15 @@ very best ideas, from anywhere, can help shape the future of testing in Swift. The table below describes the current level of support that Swift Testing has for various platforms: -| **Platform** | **CI Status (5.10)** | **CI Status (6.0)** | **CI Status (main)** | **Support Status** | -|---|:-:|:-:|:-:|---| -| **macOS** | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-5.10-macos)](https://ci.swift.org/job/swift-testing-main-swift-5.10-macos/) | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-6.0-macos)](https://ci.swift.org/job/swift-testing-main-swift-6.0-macos/) | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-main-macos)](https://ci.swift.org/view/Swift%20Packages/job/swift-testing-main-swift-main-macos/) | Supported | -| **iOS** | | | | Supported | -| **watchOS** | | | | Supported | -| **tvOS** | | | | Supported | -| **visionOS** | | | | Supported | -| **Ubuntu 22.04** | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-5.10-linux)](https://ci.swift.org/job/swift-testing-main-swift-5.10-linux/) | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-6.0-linux)](https://ci.swift.org/job/swift-testing-main-swift-6.0-linux/) | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-main-linux)](https://ci.swift.org/view/Swift%20Packages/job/swift-testing-main-swift-main-linux/) | Supported | -| **Windows** | [![Build Status](https://ci-external.swift.org/buildStatus/icon?job=swift-testing-main-swift-5.10-windows)](https://ci-external.swift.org/job/swift-testing-main-swift-5.10-windows/) | | [![Build Status](https://ci-external.swift.org/buildStatus/icon?job=swift-testing-main-swift-main-windows)](https://ci-external.swift.org/job/swift-testing-main-swift-main-windows/) | Supported | +| **Platform** | **CI Status (6.0)** | **CI Status (main)** | **Support Status** | +|---|:-:|:-:|---| +| **macOS** | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-6.0-macos)](https://ci.swift.org/job/swift-testing-main-swift-6.0-macos/) | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-main-macos)](https://ci.swift.org/view/Swift%20Packages/job/swift-testing-main-swift-main-macos/) | Supported | +| **iOS** | | | Supported | +| **watchOS** | | | Supported | +| **tvOS** | | | Supported | +| **visionOS** | | | Supported | +| **Ubuntu 22.04** | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-6.0-linux)](https://ci.swift.org/job/swift-testing-main-swift-6.0-linux/) | [![Build Status](https://ci.swift.org/buildStatus/icon?job=swift-testing-main-swift-main-linux)](https://ci.swift.org/view/Swift%20Packages/job/swift-testing-main-swift-main-linux/) | Supported | +| **Windows** | | [![Build Status](https://ci-external.swift.org/buildStatus/icon?job=swift-testing-main-swift-main-windows)](https://ci-external.swift.org/job/swift-testing-main-swift-main-windows/) | Supported | ### Works with XCTest diff --git a/Sources/Testing/CMakeLists.txt b/Sources/Testing/CMakeLists.txt index 08a8c447a..494812996 100644 --- a/Sources/Testing/CMakeLists.txt +++ b/Sources/Testing/CMakeLists.txt @@ -18,7 +18,6 @@ add_library(Testing EntryPoints/ABIv0/Encoded/ABIv0.EncodedTest.swift EntryPoints/EntryPoint.swift EntryPoints/SwiftPMEntryPoint.swift - EntryPoints/XCTestScaffold.swift Events/Clock.swift Events/Event.swift Events/Recorder/Event.ConsoleOutputRecorder.swift @@ -61,7 +60,6 @@ add_library(Testing Support/Additions/CommandLineAdditions.swift Support/Additions/NumericAdditions.swift Support/Additions/ResultAdditions.swift - Support/Additions/StringAdditions.swift Support/CartesianProduct.swift Support/CError.swift Support/Environment.swift diff --git a/Sources/Testing/EntryPoints/EntryPoint.swift b/Sources/Testing/EntryPoints/EntryPoint.swift index 8464cc286..a459c4d48 100644 --- a/Sources/Testing/EntryPoints/EntryPoint.swift +++ b/Sources/Testing/EntryPoints/EntryPoint.swift @@ -27,7 +27,7 @@ private import _TestingInternals /// External callers cannot call this function directly. The can use /// ``copyABIEntryPoint_v0()`` to get a reference to an ABI-stable version of /// this function. -func entryPoint(passing args: consuming __CommandLineArguments_v0?, eventHandler: Event.Handler?) async -> CInt { +func entryPoint(passing args: __CommandLineArguments_v0?, eventHandler: Event.Handler?) async -> CInt { let exitCode = Locked(rawValue: EXIT_SUCCESS) do { @@ -239,12 +239,6 @@ public struct __CommandLineArguments_v0: Sendable { /// The value of the `--repeat-until` argument. public var repeatUntil: String? - - /// The identifier of the `XCTestCase` instance hosting the testing library, - /// if ``XCTestScaffold`` is being used. - /// - /// This property is not ABI and will be removed with ``XCTestScaffold``. - var xcTestCaseHostIdentifier: String? } extension __CommandLineArguments_v0: Codable { @@ -264,7 +258,6 @@ extension __CommandLineArguments_v0: Codable { case skip case repetitions case repeatUntil - case xcTestCaseHostIdentifier } } @@ -471,7 +464,7 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr #if !SWT_NO_EXIT_TESTS // Enable exit test handling via __swiftPMEntryPoint(). - configuration.exitTestHandler = ExitTest.handlerForEntryPoint(forXCTestCaseIdentifiedBy: args.xcTestCaseHostIdentifier) + configuration.exitTestHandler = ExitTest.handlerForEntryPoint() #endif return configuration diff --git a/Sources/Testing/EntryPoints/XCTestScaffold.swift b/Sources/Testing/EntryPoints/XCTestScaffold.swift deleted file mode 100644 index 7ffee71ce..000000000 --- a/Sources/Testing/EntryPoints/XCTestScaffold.swift +++ /dev/null @@ -1,192 +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_XCTEST_SCAFFOLDING && canImport(XCTest) - -#if SWT_BUILDING_WITH_CMAKE -@_implementationOnly import _TestingInternals -#else -private import _TestingInternals -#endif - -public import XCTest - -#if SWT_TARGET_OS_APPLE -extension XCTSourceCodeContext { - convenience init(_ sourceContext: SourceContext) { - let addresses = sourceContext.backtrace?.addresses.map { $0 as NSNumber } ?? [] - let sourceLocation = sourceContext.sourceLocation.map { sourceLocation in - XCTSourceCodeLocation( - filePath: sourceLocation._filePath, - lineNumber: sourceLocation.line - ) - } - self.init(callStackAddresses: addresses, location: sourceLocation) - } -} - -extension XCTIssue { - init(_ issue: Issue, processLaunchedByXcode: Bool) { - var error = issue.error - - let issueType: XCTIssue.IssueType - switch issue.kind { - case .expectationFailed, .confirmationMiscounted: - issueType = .assertionFailure - case .errorCaught: - issueType = .thrownError - case let .timeLimitExceeded(timeLimitComponents: timeLimitComponents): - issueType = .thrownError - if error == nil { - error = TimeoutError(timeLimit: TimeValue(timeLimitComponents)) - } - case .unconditional: - issueType = .assertionFailure - case .knownIssueNotRecorded: - issueType = .unmatchedExpectedFailure - case .apiMisused, .system: - issueType = .system - } - - // Only include the description of the specified issue in the value of this - // XCTIssue's `compactDescription` property if the test runner process was - // launched by Xcode. This can be confusing when examining the textual - // output because it causes the description of the issue to be shown twice. - // When the process is launched via Xcode, however, this is needed to show - // a meaningful representation of the issue in Xcode's results UI. - let compactDescription = processLaunchedByXcode ? String(describing: issue) : "" - - self.init( - type: issueType, - compactDescription: compactDescription, - detailedDescription: nil, - sourceCodeContext: XCTSourceCodeContext(issue.sourceContext), - associatedError: error, - attachments: [] - ) - } -} -#endif - -// MARK: - - -/// A type providing temporary tools for integrating the testing library and -/// the XCTest framework. -/// -/// ## See Also -/// -/// - -#if SWIFT_PM_SUPPORTS_SWIFT_TESTING -@available(*, deprecated, message: "This version of Swift Package Manager supports running Swift Testing tests directly. This type will be removed in a future release.") -#else -@available(swift, deprecated: 100000.0, message: "This type is provided temporarily to aid in integrating the testing library with existing tools such as Swift Package Manager. It will be removed in a future release.") -#endif -public enum XCTestScaffold: Sendable { - /// Run all tests found in the current process and write output to the - /// standard error stream. - /// - /// - Parameters: - /// - testCase: An `XCTestCase` instance that hosts tests implemented using - /// the testing library. - /// - /// Output from the testing library is written to the standard error stream. - /// The format of the output is not meant to be machine-readable and is - /// subject to change. - /// - /// ### Configuring output - /// - /// By default, this function uses - /// [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) to - /// colorize output if the environment and platform support them. To disable - /// colorized output, set the [`NO_COLOR`](https://www.no-color.org) - /// environment variable. - /// - /// On macOS, if the SF Symbols app is installed, SF Symbols are - /// assumed to be present in the font used for rendering within the Unicode - /// Private Use Area. To disable the use of SF Symbols on macOS, set the - /// `SWT_SF_SYMBOLS_ENABLED` environment variable to `"false"` or `"0"`. - /// - /// To adjust the verbosity of output, set the `SWT_VERBOSITY` environment - /// variable to an integer value greater or less than `0` (the default level.) - /// ``XCTestScaffold`` does not support the `--verbose`, `--very-verbose`, or - /// `--quiet` command-line arguments passed to `swift test`. - /// - /// ## See Also - /// - /// - -#if SWIFT_PM_SUPPORTS_SWIFT_TESTING - @available(*, deprecated, message: "This version of Swift Package Manager supports running Swift Testing tests directly. This function has no effect and will be removed in a future release.") -#else - @available(swift, deprecated: 100000.0, message: "This function is provided temporarily to aid in integrating the testing library with existing tools such as Swift Package Manager. It will be removed in a future release.") -#endif - public static func runAllTests(hostedBy testCase: XCTestCase, _ functionName: String = #function) async { -#if SWIFT_PM_SUPPORTS_SWIFT_TESTING -#if !SWT_NO_FILE_IO - let message = Event.ConsoleOutputRecorder.warning( - "This version of Swift Package Manager supports running Swift Testing tests directly. Ignoring call to \(#function).", - options: .for(.stderr) - ) -#if SWT_TARGET_OS_APPLE && !SWT_NO_FILE_IO - try? FileHandle.stderr.write(message) -#else - print(message) -#endif -#endif -#else - nonisolated(unsafe) let testCase = testCase -#if SWT_TARGET_OS_APPLE - let isProcessLaunchedByXcode = Environment.variable(named: "XCTestSessionIdentifier") != nil -#endif - - var args = __CommandLineArguments_v0() - args.parallel = false - if let verbosity = Environment.variable(named: "SWT_VERBOSITY").flatMap(Int.init) { - args.verbosity = verbosity - } - - // Specify the hosting XCTestCase instance. This value is currently only - // used for exit tests. - let typeName = String(reflecting: type(of: testCase as Any)) - let functionName = if let parenIndex = functionName.lastIndex(of: "(") { - functionName[..", - atLine: issue.sourceLocation?.line ?? 0, - expected: true) - } -#endif - } -#endif - } -} -#endif diff --git a/Sources/Testing/ExitTests/ExitTest.swift b/Sources/Testing/ExitTests/ExitTest.swift index 89437723f..619656422 100644 --- a/Sources/Testing/ExitTests/ExitTest.swift +++ b/Sources/Testing/ExitTests/ExitTest.swift @@ -223,13 +223,9 @@ extension ExitTest { /// The exit test handler used when integrating with Swift Package Manager via /// the `__swiftPMEntryPoint()` function. /// - /// - Parameters: - /// - xcTestCaseIdentifier: The identifier of the XCTest-based test hosting - /// the testing library (when using ``XCTestScaffold``.) - /// /// For a description of the inputs and outputs of this function, see the /// documentation for ``ExitTest/Handler``. - static func handlerForEntryPoint(forXCTestCaseIdentifiedBy xcTestCaseIdentifier: String? = nil) -> Handler { + static func handlerForEntryPoint() -> Handler { // The environment could change between invocations if a test calls setenv() // or unsetenv(), so we need to recompute the child environment each time. // The executable and XCTest bundle paths should not change over time, so we @@ -239,9 +235,9 @@ extension ExitTest { // We only need to pass arguments when hosted by XCTest. let childArguments: [String] = { var result = [String]() +#if SWT_TARGET_OS_APPLE lazy var xctestTargetPath = Environment.variable(named: "XCTestBundlePath") ?? CommandLine.arguments.dropFirst().last -#if SWT_TARGET_OS_APPLE // If the running executable appears to be the XCTest runner executable in // Xcode, figure out the path to the running XCTest bundle. If we can find // it, then we can re-run the host XCTestCase instance. @@ -263,15 +259,7 @@ extension ExitTest { // test bundle is set, assume we _are_ being hosted and specify a // blank test identifier ("/") to force the xctest command-line tool // to run. - let xcTestCaseIdentifier = xcTestCaseIdentifier ?? "/" - result += ["-XCTest", xcTestCaseIdentifier, xctestTargetPath] - } -#else - if let xcTestCaseIdentifier { - result.append(xcTestCaseIdentifier) - if let xctestTargetPath { - result.append(xctestTargetPath) - } + result += ["-XCTest", "/", xctestTargetPath] } #endif return result diff --git a/Sources/Testing/Support/Additions/StringAdditions.swift b/Sources/Testing/Support/Additions/StringAdditions.swift deleted file mode 100644 index b4cc88652..000000000 --- a/Sources/Testing/Support/Additions/StringAdditions.swift +++ /dev/null @@ -1,25 +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_BUILDING_WITH_CMAKE -@_implementationOnly import _TestingInternals -#else -private import _TestingInternals -#endif - -extension String { - init?(validatingUTF8CString cString: UnsafePointer) { -#if compiler(>=5.11) - self.init(validatingCString: cString) -#else - self.init(validatingUTF8: cString) -#endif - } -} diff --git a/Sources/Testing/Support/Environment.swift b/Sources/Testing/Support/Environment.swift index 3741b2825..c22947e0a 100644 --- a/Sources/Testing/Support/Environment.swift +++ b/Sources/Testing/Support/Environment.swift @@ -61,7 +61,7 @@ enum Environment { break } - if let row = String(validatingUTF8CString: rowp), + if let row = String(validatingCString: rowp), let (key, value) = _splitEnvironmentVariable(row) { result[key] = value } @@ -168,14 +168,14 @@ enum Environment { if let equals = strchr(rowp, CInt(UInt8(ascii: "="))) { let keyLength = UnsafeRawPointer(equals) - UnsafeRawPointer(rowp) if 0 == strncmp(rowp, name, keyLength) { - return String(validatingUTF8CString: equals + 1) + return String(validatingCString: equals + 1) } } } return nil } #elseif SWT_TARGET_OS_APPLE || os(Linux) || os(WASI) - getenv(name).flatMap { String(validatingUTF8CString: $0) } + getenv(name).flatMap { String(validatingCString: $0) } #elseif os(Windows) name.withCString(encodedAs: UTF16.self) { name in func getVariable(maxCount: Int) -> String? { diff --git a/Sources/Testing/Support/Versions.swift b/Sources/Testing/Support/Versions.swift index 8d34f4037..89e65f97a 100644 --- a/Sources/Testing/Support/Versions.swift +++ b/Sources/Testing/Support/Versions.swift @@ -18,7 +18,7 @@ private import _TestingInternals /// /// This value's format is platform-specific and is not meant to be /// machine-readable. It is added to the output of a test run when using -/// ``XCTestScaffold`` or an event writer. +/// an event writer. /// /// This value is not part of the public interface of the testing library. let operatingSystemVersion: String = { @@ -40,12 +40,12 @@ let operatingSystemVersion: String = { if 0 == uname(&name) { let release = withUnsafeBytes(of: name.release) { release in release.withMemoryRebound(to: CChar.self) { release in - String(validatingUTF8CString: release.baseAddress!) ?? "" + String(validatingCString: release.baseAddress!) ?? "" } } let version = withUnsafeBytes(of: name.version) { version in version.withMemoryRebound(to: CChar.self) { version in - String(validatingUTF8CString: version.baseAddress!) ?? "" + String(validatingCString: version.baseAddress!) ?? "" } } switch (release, version) { @@ -98,7 +98,7 @@ let operatingSystemVersion: String = { /// /// This value's format is platform-specific and is not meant to be /// machine-readable. It is added to the output of a test run when using -/// ``XCTestScaffold`` or an event writer. +/// an event writer. /// /// This value is not part of the public interface of the testing library. let simulatorVersion: String = { @@ -121,7 +121,7 @@ let simulatorVersion: String = { /// /// This value's format is platform-specific and is not meant to be /// machine-readable. It is added to the output of a test run when using -/// ``XCTestScaffold`` or an event writer. +/// an event writer. /// /// This value is not part of the public interface of the testing library. var testingLibraryVersion: String { @@ -132,7 +132,7 @@ var testingLibraryVersion: String { /// /// This value's format is platform-specific and is not meant to be /// machine-readable. It is added to the output of a test run when using -/// ``XCTestScaffold`` or an event writer. +/// an event writer. /// /// This value is not part of the public interface of the testing library. let swiftStandardLibraryVersion: String = { @@ -161,7 +161,7 @@ func sysctlbyname(_ name: String, as _: String.Type) -> String? { if 0 == sysctlbyname(name, nil, &szValue, nil, 0) { return withUnsafeTemporaryAllocation(of: CChar.self, capacity: szValue) { buffer in if 0 == sysctlbyname(name, buffer.baseAddress!, &szValue, nil, 0) { - return String(validatingUTF8CString: buffer.baseAddress!) + return String(validatingCString: buffer.baseAddress!) } return nil } diff --git a/Sources/Testing/Testing.docc/TemporaryGettingStarted.md b/Sources/Testing/Testing.docc/TemporaryGettingStarted.md index 5823406e6..2369af3b5 100644 --- a/Sources/Testing/Testing.docc/TemporaryGettingStarted.md +++ b/Sources/Testing/Testing.docc/TemporaryGettingStarted.md @@ -144,7 +144,3 @@ using Xcode 16 Beta. See the [Test Explorer](https://www.swift.org/documentation/articles/getting-started-with-vscode-swift.html#test-explorer) section of [Getting Started with Swift in VS Code](https://www.swift.org/documentation/articles/getting-started-with-vscode-swift.html). - -## Topics - -- ``XCTestScaffold`` diff --git a/Sources/Testing/Traits/Tags/Tag.Color+Loading.swift b/Sources/Testing/Traits/Tags/Tag.Color+Loading.swift index 8f5aa4404..137e059eb 100644 --- a/Sources/Testing/Traits/Tags/Tag.Color+Loading.swift +++ b/Sources/Testing/Traits/Tags/Tag.Color+Loading.swift @@ -26,7 +26,7 @@ private var _homeDirectoryPath: String? { return if let homeVariable = Environment.variable(named: "HOME") { homeVariable } else if let pwd = getpwuid(geteuid()) { - String(validatingUTF8CString: pwd.pointee.pw_dir) + String(validatingCString: pwd.pointee.pw_dir) } else { nil } diff --git a/Sources/Testing/Traits/TimeLimitTrait.swift b/Sources/Testing/Traits/TimeLimitTrait.swift index 3aa00bc6e..8828a703a 100644 --- a/Sources/Testing/Traits/TimeLimitTrait.swift +++ b/Sources/Testing/Traits/TimeLimitTrait.swift @@ -237,7 +237,7 @@ extension Test { // MARK: - -/// An error that is reported by ``XCTestScaffold`` when a test times out. +/// An error that is reported when a test times out. /// /// This type is not part of the public interface of the testing library. struct TimeoutError: Error, CustomStringConvertible { diff --git a/Sources/TestingMacros/Support/Additions/DeclGroupSyntaxAdditions.swift b/Sources/TestingMacros/Support/Additions/DeclGroupSyntaxAdditions.swift index b2ddcbb6f..36322c58b 100644 --- a/Sources/TestingMacros/Support/Additions/DeclGroupSyntaxAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/DeclGroupSyntaxAdditions.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif extension DeclGroupSyntax { /// The type declared or extended by this instance. diff --git a/Sources/TestingMacros/Support/Additions/EditorPlaceholderExprSyntaxAdditions.swift b/Sources/TestingMacros/Support/Additions/EditorPlaceholderExprSyntaxAdditions.swift index db718ee3e..b6a918ea5 100644 --- a/Sources/TestingMacros/Support/Additions/EditorPlaceholderExprSyntaxAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/EditorPlaceholderExprSyntaxAdditions.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif extension EditorPlaceholderExprSyntax { /// Initialize an instance of this type with the given placeholder string. diff --git a/Sources/TestingMacros/Support/Additions/FunctionDeclSyntaxAdditions.swift b/Sources/TestingMacros/Support/Additions/FunctionDeclSyntaxAdditions.swift index e049704d6..70c4f7baf 100644 --- a/Sources/TestingMacros/Support/Additions/FunctionDeclSyntaxAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/FunctionDeclSyntaxAdditions.swift @@ -8,13 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif extension FunctionDeclSyntax { /// Whether or not this function a `static` or `class` function. diff --git a/Sources/TestingMacros/Support/Additions/MacroExpansionContextAdditions.swift b/Sources/TestingMacros/Support/Additions/MacroExpansionContextAdditions.swift index f6dad97ae..eaee7b685 100644 --- a/Sources/TestingMacros/Support/Additions/MacroExpansionContextAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/MacroExpansionContextAdditions.swift @@ -8,13 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif import SwiftDiagnostics extension MacroExpansionContext { @@ -28,12 +23,7 @@ extension MacroExpansionContext { /// /// If the lexical context includes functions, closures, or some other /// non-type scope, the value of this property is `nil`. - /// - /// When using the Swift 6 or newer compiler, `node` is ignored. The argument - /// can be removed once the testing library is updated to require the Swift 6 - /// compiler. - func typeOfLexicalContext(containing node: some WithAttributesSyntax) -> TypeSyntax? { -#if compiler(>=5.11) + var typeOfLexicalContext: TypeSyntax? { var typeNames = [String]() for lexicalContext in lexicalContext.reversed() { guard let decl = lexicalContext.asProtocol((any DeclGroupSyntax).self) else { @@ -46,42 +36,6 @@ extension MacroExpansionContext { } return "\(raw: typeNames.joined(separator: "."))" -#else - // Find the beginning of the first attribute on the declaration, including - // those embedded in #if statements, to account for patterns like - // `@MainActor @Test func` where there's a space ahead of @Test, but the - // whole function is still at the top level. - func firstAttribute(in attributes: AttributeListSyntax) -> AttributeSyntax? { - attributes.lazy - .compactMap { attribute in - switch (attribute as AttributeListSyntax.Element?) { - case let .ifConfigDecl(ifConfigDecl): - ifConfigDecl.clauses.lazy - .compactMap { clause in - if case let .attributes(attributes) = clause.elements { - return firstAttribute(in: attributes) - } - return nil - }.first - case let .attribute(attribute): - attribute - default: - nil - } - }.first - } - let firstAttribute = firstAttribute(in: node.attributes)! - - // HACK: If the test function appears to be indented, assume it is nested in - // a type. Use `Self` as the presumptive name of the type. - // - // This hack works around rdar://105470382. - if let lastLeadingTrivia = firstAttribute.leadingTrivia.pieces.last, - lastLeadingTrivia.isWhitespace && !lastLeadingTrivia.isNewline { - return TypeSyntax(IdentifierTypeSyntax(name: .keyword(.Self))) - } - return nil -#endif } } diff --git a/Sources/TestingMacros/Support/Additions/TokenSyntaxAdditions.swift b/Sources/TestingMacros/Support/Additions/TokenSyntaxAdditions.swift index dd1f5d071..07dead4ef 100644 --- a/Sources/TestingMacros/Support/Additions/TokenSyntaxAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/TokenSyntaxAdditions.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif extension TokenSyntax { /// The text of this instance with all backticks removed. diff --git a/Sources/TestingMacros/Support/Additions/TriviaPieceAdditions.swift b/Sources/TestingMacros/Support/Additions/TriviaPieceAdditions.swift index 4231ea0de..66f19b724 100644 --- a/Sources/TestingMacros/Support/Additions/TriviaPieceAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/TriviaPieceAdditions.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif extension TriviaPiece { /// The number of newline characters represented by this trivia piece. diff --git a/Sources/TestingMacros/Support/Additions/TypeSyntaxProtocolAdditions.swift b/Sources/TestingMacros/Support/Additions/TypeSyntaxProtocolAdditions.swift index 83b0baf44..e6e381e94 100644 --- a/Sources/TestingMacros/Support/Additions/TypeSyntaxProtocolAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/TypeSyntaxProtocolAdditions.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif extension TypeSyntaxProtocol { /// Whether or not this type is an optional type (`T?`, `Optional`, etc.) diff --git a/Sources/TestingMacros/Support/Additions/VersionTupleSyntaxAdditions.swift b/Sources/TestingMacros/Support/Additions/VersionTupleSyntaxAdditions.swift index 210ad9ccb..b842f0a01 100644 --- a/Sources/TestingMacros/Support/Additions/VersionTupleSyntaxAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/VersionTupleSyntaxAdditions.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif extension VersionTupleSyntax { /// A type describing the major, minor, and patch components of a version diff --git a/Sources/TestingMacros/Support/Additions/WithAttributesSyntaxAdditions.swift b/Sources/TestingMacros/Support/Additions/WithAttributesSyntaxAdditions.swift index 385bd6a70..348566224 100644 --- a/Sources/TestingMacros/Support/Additions/WithAttributesSyntaxAdditions.swift +++ b/Sources/TestingMacros/Support/Additions/WithAttributesSyntaxAdditions.swift @@ -8,13 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif extension WithAttributesSyntax { /// The set of availability attributes on this instance. diff --git a/Sources/TestingMacros/Support/Argument.swift b/Sources/TestingMacros/Support/Argument.swift index 2e6ef7d63..d5cc03000 100644 --- a/Sources/TestingMacros/Support/Argument.swift +++ b/Sources/TestingMacros/Support/Argument.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif /// A type describing an argument to a function, closure, etc. /// diff --git a/Sources/TestingMacros/Support/AttributeDiscovery.swift b/Sources/TestingMacros/Support/AttributeDiscovery.swift index ac38ccb6b..5f98f4fc8 100644 --- a/Sources/TestingMacros/Support/AttributeDiscovery.swift +++ b/Sources/TestingMacros/Support/AttributeDiscovery.swift @@ -8,13 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif /// A syntax rewriter that removes leading `Self.` tokens from member access /// expressions in a syntax tree. diff --git a/Sources/TestingMacros/Support/AvailabilityGuards.swift b/Sources/TestingMacros/Support/AvailabilityGuards.swift index 002b6cc95..1a6fa1f05 100644 --- a/Sources/TestingMacros/Support/AvailabilityGuards.swift +++ b/Sources/TestingMacros/Support/AvailabilityGuards.swift @@ -8,13 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif /// A structure describing a single platform/version pair from an `@available()` /// attribute. diff --git a/Sources/TestingMacros/Support/CommentParsing.swift b/Sources/TestingMacros/Support/CommentParsing.swift index 9bfebde2d..1c16c10b8 100644 --- a/Sources/TestingMacros/Support/CommentParsing.swift +++ b/Sources/TestingMacros/Support/CommentParsing.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif /// Find a common whitespace prefix among all lines in a string and trim it. /// diff --git a/Sources/TestingMacros/Support/ConditionArgumentParsing.swift b/Sources/TestingMacros/Support/ConditionArgumentParsing.swift index ab58ede3a..9afc3b0ee 100644 --- a/Sources/TestingMacros/Support/ConditionArgumentParsing.swift +++ b/Sources/TestingMacros/Support/ConditionArgumentParsing.swift @@ -8,13 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif /// The result of parsing the condition argument passed to `#expect()` or /// `#require()`. diff --git a/Sources/TestingMacros/Support/DiagnosticMessage+Diagnosing.swift b/Sources/TestingMacros/Support/DiagnosticMessage+Diagnosing.swift index 9b02d1a4c..1d9aea328 100644 --- a/Sources/TestingMacros/Support/DiagnosticMessage+Diagnosing.swift +++ b/Sources/TestingMacros/Support/DiagnosticMessage+Diagnosing.swift @@ -9,13 +9,8 @@ // import SwiftDiagnostics -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif extension AttributeInfo { /// Diagnose issues with the traits in a parsed attribute. diff --git a/Sources/TestingMacros/Support/DiagnosticMessage.swift b/Sources/TestingMacros/Support/DiagnosticMessage.swift index fa894c1b3..50a6911cc 100644 --- a/Sources/TestingMacros/Support/DiagnosticMessage.swift +++ b/Sources/TestingMacros/Support/DiagnosticMessage.swift @@ -9,15 +9,9 @@ // import SwiftDiagnostics -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros import SwiftSyntaxMacroExpansion -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -public import SwiftSyntaxMacroExpansion -#endif /// A type describing diagnostic messages emitted by this module's macro during /// evaluation. diff --git a/Sources/TestingMacros/Support/SourceCodeCapturing.swift b/Sources/TestingMacros/Support/SourceCodeCapturing.swift index 9ab6c2c95..9fd687e8f 100644 --- a/Sources/TestingMacros/Support/SourceCodeCapturing.swift +++ b/Sources/TestingMacros/Support/SourceCodeCapturing.swift @@ -8,11 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax -#else -public import SwiftSyntax -#endif /// Get a swift-syntax expression initializing an instance of `__Expression` /// from an arbitrary syntax node. diff --git a/Sources/TestingMacros/Support/SourceLocationGeneration.swift b/Sources/TestingMacros/Support/SourceLocationGeneration.swift index 516c89855..b0002dc2c 100644 --- a/Sources/TestingMacros/Support/SourceLocationGeneration.swift +++ b/Sources/TestingMacros/Support/SourceLocationGeneration.swift @@ -8,13 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) import SwiftSyntax import SwiftSyntaxMacros -#else -public import SwiftSyntax -public import SwiftSyntaxMacros -#endif /// Get an expression initializing an instance of ``SourceLocation`` from an /// arbitrary expression value. diff --git a/Sources/TestingMacros/TagMacro.swift b/Sources/TestingMacros/TagMacro.swift index 67d6bd6fc..921cdad54 100644 --- a/Sources/TestingMacros/TagMacro.swift +++ b/Sources/TestingMacros/TagMacro.swift @@ -40,12 +40,11 @@ public struct TagMacro: PeerMacro, AccessorMacro, Sendable { // Figure out what type the tag is declared on. It must be declared on Tag // or a type nested in Tag. - guard let type = context.typeOfLexicalContext(containing: variableDecl) else { + guard let type = context.typeOfLexicalContext else { context.diagnose(.nonMemberTagDeclarationNotSupported(variableDecl, whenUsing: node)) return _fallbackAccessorDecls } -#if compiler(>=5.11) // Check that the tag is declared within Tag's namespace. let typeNameTokens: [String] = type.tokens(viewMode: .fixedUp).lazy .filter { $0.tokenKind != .period } @@ -75,7 +74,6 @@ public struct TagMacro: PeerMacro, AccessorMacro, Sendable { return _fallbackAccessorDecls } } -#endif // We know the tag is nested in Tag. Now check that it is a static member. guard variableDecl.modifiers.map(\.name.tokenKind).contains(.keyword(.static)) else { diff --git a/Sources/TestingMacros/TestDeclarationMacro.swift b/Sources/TestingMacros/TestDeclarationMacro.swift index 541fad821..18c83123f 100644 --- a/Sources/TestingMacros/TestDeclarationMacro.swift +++ b/Sources/TestingMacros/TestDeclarationMacro.swift @@ -26,7 +26,7 @@ public struct TestDeclarationMacro: PeerMacro, Sendable { } let functionDecl = declaration.cast(FunctionDeclSyntax.self) - let typeName = context.typeOfLexicalContext(containing: functionDecl) + let typeName = context.typeOfLexicalContext return _createTestContainerDecls(for: functionDecl, on: typeName, testAttribute: node, in: context) } @@ -381,36 +381,9 @@ public struct TestDeclarationMacro: PeerMacro, Sendable { ) -> [DeclSyntax] { var result = [DeclSyntax]() -#if compiler(>=5.11) // Get the name of the type containing the function for passing to the test // factory function later. - let typealiasExpr: ExprSyntax = typeName.map { "\($0).self" } ?? "nil" -#else - // We cannot directly refer to Self here because it will end up being - // resolved as the __TestContainer type we generate. Create a uniquely-named - // reference to Self outside the context of the generated type, and use it - // when the generated type needs to refer to the containing type. - // - // To support covariant Self on classes, we embed the reference to Self - // inside a static computed property instead of a typealias (where covariant - // Self is disallowed.) - // - // This "typealias" is not necessary when using the Swift 6 compiler. - var typealiasExpr: ExprSyntax = "nil" - if let typeName { - let typealiasName = context.makeUniqueName(thunking: functionDecl) - result.append( - """ - @available(*, deprecated, message: "This property is an implementation detail of the testing library. Do not use it directly.") - private static nonisolated var \(typealiasName): Any.Type { - \(typeName).self - } - """ - ) - - typealiasExpr = "\(typealiasName)" - } -#endif + let typeNameExpr: ExprSyntax = typeName.map { "\($0).self" } ?? "nil" if typeName != nil, let genericGuardDecl = makeGenericGuardDecl(guardingAgainst: functionDecl, in: context) { result.append(genericGuardDecl) @@ -448,7 +421,7 @@ public struct TestDeclarationMacro: PeerMacro, Sendable { return [ .__function( named: \(literal: functionDecl.completeName), - in: \(typealiasExpr), + in: \(typeNameExpr), xcTestCompatibleSelector: \(selectorExpr ?? "nil"), \(raw: attributeInfo.functionArgumentList(in: context)), parameters: \(raw: functionDecl.testFunctionParameterList), @@ -475,7 +448,7 @@ public struct TestDeclarationMacro: PeerMacro, Sendable { [ .__function( named: \(literal: functionDecl.completeName), - in: \(typealiasExpr), + in: \(typeNameExpr), xcTestCompatibleSelector: \(selectorExpr ?? "nil"), \(raw: attributeInfo.functionArgumentList(in: context)), testFunction: {} diff --git a/Sources/TestingMacros/TestingMacrosMain.swift b/Sources/TestingMacros/TestingMacrosMain.swift index 59d095178..d1b214025 100644 --- a/Sources/TestingMacros/TestingMacrosMain.swift +++ b/Sources/TestingMacros/TestingMacrosMain.swift @@ -10,11 +10,7 @@ #if canImport(SwiftCompilerPlugin) import SwiftCompilerPlugin -#if compiler(>=5.11) import SwiftSyntaxMacros -#else -public import SwiftSyntaxMacros -#endif /// The main entry point for the compiler plugin executable that implements /// macros declared in the `Testing` module. diff --git a/Sources/_Testing_Foundation/ReexportTesting.swift b/Sources/_Testing_Foundation/ReexportTesting.swift index 561769f89..d06def5b8 100644 --- a/Sources/_Testing_Foundation/ReexportTesting.swift +++ b/Sources/_Testing_Foundation/ReexportTesting.swift @@ -8,8 +8,4 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if compiler(>=5.11) @_exported import Testing -#else -@_exported public import Testing -#endif diff --git a/Tests/TestingMacrosTests/TagMacroTests.swift b/Tests/TestingMacrosTests/TagMacroTests.swift index 2d70ccce5..b7916bf7d 100644 --- a/Tests/TestingMacrosTests/TagMacroTests.swift +++ b/Tests/TestingMacrosTests/TagMacroTests.swift @@ -17,13 +17,7 @@ import SwiftSyntax import SwiftSyntaxBuilder import SwiftSyntaxMacros -#if compiler(>=5.11) -private let swift6Compiler = true -#else -private let swift6Compiler = false -#endif - -@Suite("TagMacro Tests", .enabled(if: swift6Compiler, "@Tag tests require lexical context")) +@Suite("TagMacro Tests") struct TagMacroTests { @Test("@Tag macro", arguments: [ diff --git a/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift b/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift index cf8e3ee74..7f6e68f2e 100644 --- a/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift +++ b/Tests/TestingMacrosTests/TestDeclarationMacroTests.swift @@ -17,16 +17,9 @@ import SwiftSyntax import SwiftSyntaxBuilder import SwiftSyntaxMacros -#if compiler(>=5.11) -private let swift6Compiler = true -#else -private let swift6Compiler = false -#endif - @Suite("TestDeclarationMacro Tests") struct TestDeclarationMacroTests { @Test("Error diagnostics emitted on API misuse", - .enabled(if: swift6Compiler, "Some error diagnostics require lexical context"), arguments: [ // Generic declarations "@Suite struct S {}": diff --git a/Tests/TestingMacrosTests/TestSupport/Scaffolding.swift b/Tests/TestingMacrosTests/TestSupport/Scaffolding.swift deleted file mode 100644 index 766a7d614..000000000 --- a/Tests/TestingMacrosTests/TestSupport/Scaffolding.swift +++ /dev/null @@ -1,20 +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_XCTEST_SCAFFOLDING && !SWIFT_PM_SUPPORTS_SWIFT_TESTING && canImport(XCTest) -import XCTest -import Testing - -final class AllTests: XCTestCase { - func testAll() async { - await XCTestScaffold.runAllTests(hostedBy: self) - } -} -#endif diff --git a/Tests/TestingTests/ExitTestTests.swift b/Tests/TestingTests/ExitTestTests.swift index 2857afb73..3d614d134 100644 --- a/Tests/TestingTests/ExitTestTests.swift +++ b/Tests/TestingTests/ExitTestTests.swift @@ -62,7 +62,6 @@ private import _TestingInternals #endif } -#if SWIFT_PM_SUPPORTS_SWIFT_TESTING @Test("Exit tests (failing)") func failing() async { let expectedCount: Int #if os(Windows) @@ -82,7 +81,6 @@ private import _TestingInternals await runTest(for: FailingExitTests.self, configuration: configuration) } } -#endif @Test("Mock exit test handlers (passing)") func passingMockHandler() async { await confirmation("System issue recorded", expectedCount: 0) { issueRecorded in diff --git a/Tests/TestingTests/TestSupport/Scaffolding.swift b/Tests/TestingTests/TestSupport/Scaffolding.swift deleted file mode 100644 index 766a7d614..000000000 --- a/Tests/TestingTests/TestSupport/Scaffolding.swift +++ /dev/null @@ -1,20 +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_XCTEST_SCAFFOLDING && !SWIFT_PM_SUPPORTS_SWIFT_TESTING && canImport(XCTest) -import XCTest -import Testing - -final class AllTests: XCTestCase { - func testAll() async { - await XCTestScaffold.runAllTests(hostedBy: self) - } -} -#endif