diff --git a/Sources/Testing/Running/XCTestScaffold.swift b/Sources/Testing/Running/XCTestScaffold.swift index 972581ec3..dd6362a86 100644 --- a/Sources/Testing/Running/XCTestScaffold.swift +++ b/Sources/Testing/Running/XCTestScaffold.swift @@ -8,7 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if !SWT_NO_XCTEST_SCAFFOLDING +#if !SWT_NO_XCTEST_SCAFFOLDING && canImport(XCTest) private import TestingInternals public import XCTest @@ -25,19 +25,6 @@ extension XCTSourceCodeContext { self.init(callStackAddresses: addresses, location: sourceLocation) } } - -/// An error that is reported by ``XCTestScaffold`` when a test times out. -/// -/// This type is not part of the public interface of the testing library. -struct TimeoutError: Error, CustomStringConvertible { - /// The time limit exceeded by the test that timed out. - var timeLimit: TimeValue - - var description: String { - "Timed out after \(timeLimit) seconds." - } -} - extension XCTIssue { init(_ issue: Issue, processLaunchedByXcode: Bool) { var error = issue.error diff --git a/Sources/Testing/Traits/TimeLimitTrait.swift b/Sources/Testing/Traits/TimeLimitTrait.swift index a70c14a3f..153a19bdd 100644 --- a/Sources/Testing/Traits/TimeLimitTrait.swift +++ b/Sources/Testing/Traits/TimeLimitTrait.swift @@ -108,6 +108,18 @@ extension Test { // MARK: - +/// An error that is reported by ``XCTestScaffold`` when a test times out. +/// +/// This type is not part of the public interface of the testing library. +struct TimeoutError: Error, CustomStringConvertible { + /// The time limit exceeded by the test that timed out. + var timeLimit: TimeValue + + var description: String { + "Timed out after \(timeLimit) seconds." + } +} + #if !SWT_NO_UNSTRUCTURED_TASKS /// Invoke a function with a timeout. /// diff --git a/Tests/TestingMacrosTests/TestSupport/Scaffolding.swift b/Tests/TestingMacrosTests/TestSupport/Scaffolding.swift index 813b442aa..766a7d614 100644 --- a/Tests/TestingMacrosTests/TestSupport/Scaffolding.swift +++ b/Tests/TestingMacrosTests/TestSupport/Scaffolding.swift @@ -8,7 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if !SWT_NO_XCTEST_SCAFFOLDING && !SWIFT_PM_SUPPORTS_SWIFT_TESTING +#if !SWT_NO_XCTEST_SCAFFOLDING && !SWIFT_PM_SUPPORTS_SWIFT_TESTING && canImport(XCTest) import XCTest import Testing diff --git a/Tests/TestingTests/IssueTests.swift b/Tests/TestingTests/IssueTests.swift index a17f5c1f8..b0135d85b 100644 --- a/Tests/TestingTests/IssueTests.swift +++ b/Tests/TestingTests/IssueTests.swift @@ -10,6 +10,7 @@ @testable @_spi(Experimental) @_spi(ForToolsIntegrationOnly) import Testing private import TestingInternals +import Foundation #if canImport(XCTest) import XCTest diff --git a/Tests/TestingTests/ObjCInteropTests.swift b/Tests/TestingTests/ObjCInteropTests.swift index eacc601c3..179460af4 100644 --- a/Tests/TestingTests/ObjCInteropTests.swift +++ b/Tests/TestingTests/ObjCInteropTests.swift @@ -8,6 +8,7 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors */ +#if canImport(XCTest) import XCTest @testable @_spi(ForToolsIntegrationOnly) import Testing @@ -106,3 +107,4 @@ struct ObjCAndXCTestInteropTests { } } } +#endif diff --git a/Tests/TestingTests/RunnerTests.swift b/Tests/TestingTests/RunnerTests.swift index 28c811228..9b860b675 100644 --- a/Tests/TestingTests/RunnerTests.swift +++ b/Tests/TestingTests/RunnerTests.swift @@ -10,6 +10,7 @@ #if canImport(XCTest) import XCTest +#endif @testable @_spi(Experimental) @_spi(ForToolsIntegrationOnly) import Testing struct MyError: Error, Equatable { @@ -35,6 +36,7 @@ private let randomNumber = Int.random(in: 0 ..< .max) throw MyParameterizedError(index: i) } +#if canImport(XCTest) @Suite(.hidden, .disabled()) struct NeverRunTests { private static var someCondition: Bool { diff --git a/Tests/TestingTests/TestSupport/Scaffolding.swift b/Tests/TestingTests/TestSupport/Scaffolding.swift index 813b442aa..766a7d614 100644 --- a/Tests/TestingTests/TestSupport/Scaffolding.swift +++ b/Tests/TestingTests/TestSupport/Scaffolding.swift @@ -8,7 +8,7 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if !SWT_NO_XCTEST_SCAFFOLDING && !SWIFT_PM_SUPPORTS_SWIFT_TESTING +#if !SWT_NO_XCTEST_SCAFFOLDING && !SWIFT_PM_SUPPORTS_SWIFT_TESTING && canImport(XCTest) import XCTest import Testing diff --git a/Tests/TestingTests/Traits/TimeLimitTraitTests.swift b/Tests/TestingTests/Traits/TimeLimitTraitTests.swift index d76942f9d..bce00f064 100644 --- a/Tests/TestingTests/Traits/TimeLimitTraitTests.swift +++ b/Tests/TestingTests/Traits/TimeLimitTraitTests.swift @@ -214,13 +214,11 @@ struct TimeLimitTraitTests { } } -#if !SWT_NO_XCTEST_SCAFFOLDING && SWT_TARGET_OS_APPLE @Test("TimeoutError.description property") func timeoutErrorDescription() async throws { let timeLimit = TimeValue((0, 0)) #expect(String(describing: TimeoutError(timeLimit: timeLimit)).contains("0.000")) } -#endif @Test("Issue.Kind.timeLimitExceeded.description property", arguments: [