Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jan 23, 2024
1 parent 9c21097 commit 08b7c11
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Sources/XCTestDynamicOverlay/XCTExpectFailure.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

#if DEBUG && canImport(ObjectiveC)
#if canImport(ObjectiveC)
/// Instructs the test to expect a failure in an upcoming assertion, with options to customize
/// expected failure checking and handling.
///
Expand Down
30 changes: 1 addition & 29 deletions Sources/XCTestDynamicOverlay/XCTFail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public struct XCTFailContext: Sendable {
}
}
return { (message: String, _ file: StaticString, _ line: UInt) in
print(noop(message: message))
print("XCTFail: \(message)")
}
}()
}
Expand All @@ -213,31 +213,3 @@ public struct XCTFailContext: Sendable {
DynamicallyResolved.XCTFail(message, file, line)
}
#endif

private func noop(message: String, file: StaticString? = nil, line: UInt? = nil) -> String {
let fileAndLine: String
if let file = file, let line = line {
fileAndLine = """
:
\(file):\(line)
┃ …
"""
} else {
fileAndLine = "\n"
}

return """
XCTFail: \(message)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┉┅
┃ ⚠︎ Warning: This XCTFail was ignored
┃ XCTFail was invoked in a non-DEBUG environment\(fileAndLine)and so was ignored. Be sure to run tests with
┃ the DEBUG=1 flag set in order to dynamically
┃ load XCTFail.
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┉┅
▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄
"""
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if DEBUG && !os(Linux) && !os(Windows)
#if !os(Linux) && !os(Windows)
import Foundation
import XCTest
import XCTestDynamicOverlay
Expand Down
2 changes: 1 addition & 1 deletion Tests/XCTestDynamicOverlayTests/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ func MyXCTFail(_ message: String) {
XCTFail(message)
}

#if DEBUG && canImport(ObjectiveC)
#if canImport(ObjectiveC)
func MyXCTExpectFailure(
_ failureReason: String,
enabled: Bool = true,
Expand Down
14 changes: 7 additions & 7 deletions Tests/XCTestDynamicOverlayTests/UnimplementedTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if DEBUG && !os(Linux) && !os(Windows)
#if !os(Linux) && !os(Windows)
import XCTest

final class UnimplementedTests: XCTestCase {
Expand All @@ -10,7 +10,7 @@
Unimplemented: f00 …
Defined at:
XCTestDynamicOverlayTests/TestHelpers.swift:70
XCTestDynamicOverlayTests/TestHelpers.swift:98
"""
}

Expand All @@ -21,7 +21,7 @@
Unimplemented: f01 …
Defined at:
XCTestDynamicOverlayTests/TestHelpers.swift:71
XCTestDynamicOverlayTests/TestHelpers.swift:99
Invoked with:
""
Expand All @@ -35,7 +35,7 @@
Unimplemented: f02 …
Defined at:
XCTestDynamicOverlayTests/TestHelpers.swift:72
XCTestDynamicOverlayTests/TestHelpers.swift:100
Invoked with:
("", 42)
Expand All @@ -49,7 +49,7 @@
Unimplemented: f03 …
Defined at:
XCTestDynamicOverlayTests/TestHelpers.swift:73
XCTestDynamicOverlayTests/TestHelpers.swift:101
Invoked with:
("", 42, 1.2)
Expand All @@ -63,7 +63,7 @@
Unimplemented: f04 …
Defined at:
XCTestDynamicOverlayTests/TestHelpers.swift:74
XCTestDynamicOverlayTests/TestHelpers.swift:102
Invoked with:
("", 42, 1.2, [1, 2])
Expand All @@ -79,7 +79,7 @@
Unimplemented: f05 …
Defined at:
XCTestDynamicOverlayTests/TestHelpers.swift:75
XCTestDynamicOverlayTests/TestHelpers.swift:103
Invoked with:
("", 42, 1.2, [1, 2], XCTestDynamicOverlayTests.User(id: DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF))
Expand Down
2 changes: 1 addition & 1 deletion Tests/XCTestDynamicOverlayTests/XCTContextTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if DEBUG && !os(Linux) && !os(Windows)
#if !os(Linux) && !os(Windows)
import XCTest
import XCTestDynamicOverlay

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import XCTest

#if DEBUG && canImport(ObjectiveC)
#if canImport(ObjectiveC)
final class XCTExpectFailureTests: XCTestCase {
func testXCTDynamicOverlayWithBlockShouldFail() async throws {
MyXCTExpectFailure("This is expected to pass.", strict: false) {
Expand Down

0 comments on commit 08b7c11

Please sign in to comment.