diff --git a/Sources/Testing/Running/XCTestScaffold.swift b/Sources/Testing/Running/XCTestScaffold.swift index 972581ec..dd6362a8 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 a70c14a3..153a19bd 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 813b442a..766a7d61 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 a17f5c1f..b0135d85 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 eacc601c..179460af 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 28c81122..9b860b67 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 813b442a..766a7d61 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