Skip to content

Commit 41cf90a

Browse files
Added mock XCTContext for Linux builds for unit testing
1 parent bb96917 commit 41cf90a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Tests/ComplexTests/TestingBase.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,44 @@
88
@testable import Complex
99
import XCTest
1010

11+
#if os(Linux)
12+
// MARK: - XCTActivity Definition
13+
14+
internal protocol XCTActivity {
15+
16+
var name: String { get }
17+
func add(_ attachment: Any) { }
18+
}
19+
20+
// MARK: - XCTContext Definition
21+
22+
internal class XCTContext {
23+
24+
// MARK: XCTContext.Activity Definition
25+
26+
private class Activity: XCTActivity {
27+
28+
// MARK: Initialization
29+
30+
fileprivate init(name: String) {
31+
self.name = name
32+
}
33+
34+
// MARK: XCTActivity Protocol Requirements
35+
36+
let name: String
37+
38+
func add(_ attachment: Any) { /* noop */ }
39+
}
40+
41+
// MARK: Internal Methods
42+
43+
internal class func runActivity<Result>(named name: String, block: (XCTActivity) throws -> Result) rethrows -> Result {
44+
return try block(Activity(name: name))
45+
}
46+
}
47+
#endif // #if os(Linux)
48+
1149
// MARK: Internal Methods
1250

1351
internal func CTAssertEqual<T>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> T, _ message: @autoclosure () -> String = "", function: String = #function, file: StaticString = #file, line: UInt = #line) where T: Equatable {

0 commit comments

Comments
 (0)