Skip to content

Commit a2bf9a2

Browse files
authored
Fix some bugs around SWT_NO_* conditionals. (#386)
1 parent e45efd7 commit a2bf9a2

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

Sources/Testing/EntryPoints/EntryPoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ private func _eventHandlerForStreamingEvents_v0(toFileAtPath path: String) throw
376376
byte == 10 || byte == 13
377377
}
378378

379-
#if DEBUG
379+
#if DEBUG && !SWT_NO_FILE_IO
380380
// We don't actually expect the JSON encoder to produce output containing
381381
// newline characters, so in debug builds we'll log a diagnostic message.
382382
if eventAndContextJSON.contains(where: isASCIINewline) {

Sources/Testing/EntryPoints/XCTestScaffold.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public enum XCTestScaffold: Sendable {
116116
#endif
117117
public static func runAllTests(hostedBy testCase: XCTestCase, _ functionName: String = #function) async {
118118
#if SWIFT_PM_SUPPORTS_SWIFT_TESTING
119+
#if !SWT_NO_FILE_IO
119120
let message = Event.ConsoleOutputRecorder.warning(
120121
"This version of Swift Package Manager supports running swift-testing tests directly. Ignoring call to \(#function).",
121122
options: .for(.stderr)
@@ -125,6 +126,7 @@ public enum XCTestScaffold: Sendable {
125126
#else
126127
print(message)
127128
#endif
129+
#endif
128130
#else
129131
let testCase = UncheckedSendable(rawValue: testCase)
130132
#if SWT_TARGET_OS_APPLE

Tests/TestingMacrosTests/ConditionMacroTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ struct ConditionMacroTests {
331331
#expect(diagnostics.isEmpty)
332332
}
333333

334+
#if !SWT_NO_EXIT_TESTS
334335
@Test("Expectation inside an exit test diagnoses",
335336
arguments: [
336337
"#expectExitTest(exitsWith: .failure) { #expect(1 > 2) }",
@@ -344,6 +345,7 @@ struct ConditionMacroTests {
344345
#expect(diagnostic.message.contains("record an issue"))
345346
#expect(diagnostic.message.contains("(exitsWith:"))
346347
}
348+
#endif
347349

348350
@Test("Macro expansion is performed within a test function")
349351
func macroExpansionInTestFunction() throws {

Tests/TestingTests/_Testing_Foundation/FoundationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if canImport(Foundation)
11+
#if canImport(Foundation) && !SWT_NO_UTC_CLOCK
1212
@testable @_spi(Experimental) @_spi(ForToolsIntegrationOnly) import _Testing_Foundation
1313
@_spi(Experimental) @_spi(ForToolsIntegrationOnly) import Testing
1414
import Foundation

0 commit comments

Comments
 (0)