@@ -39,6 +39,14 @@ public class XCTestCase: XCTest {
39
39
/// https://bugs.swift.org/browse/SR-1129 for details.
40
40
public var _name : String
41
41
42
+ /// The set of expectations made upon this test case.
43
+ /// - Note: FIXME: This is meant to be a `private var`, but is marked as
44
+ /// `public` here to work around a Swift compiler bug on Linux. To ensure
45
+ /// compatibility of tests between swift-corelibs-xctest and Apple XCTest,
46
+ /// this property should not be modified. See
47
+ /// https://bugs.swift.org/browse/SR-1129 for details.
48
+ public var _allExpectations = [ XCTestExpectation] ( )
49
+
42
50
public required override init ( ) {
43
51
_name = " \( self . dynamicType) .<unknown> "
44
52
}
@@ -62,12 +70,6 @@ private func test<T: XCTestCase>(testFunc: T -> () throws -> Void) -> XCTestCase
62
70
}
63
71
}
64
72
65
- // FIXME: Expectations should be stored in an instance variable defined on
66
- // `XCTestCase`, but when so defined Linux tests fail with "hidden symbol
67
- // isn't defined". Use a global for the time being, as this seems to
68
- // appease the Linux compiler.
69
- private var XCTAllExpectations = [ XCTestExpectation] ( )
70
-
71
73
extension XCTestCase {
72
74
73
75
public var continueAfterFailure : Bool {
@@ -124,8 +126,7 @@ extension XCTestCase {
124
126
}
125
127
126
128
testCase. tearDown ( )
127
- testCase. failIfExpectationsNotWaitedFor ( XCTAllExpectations)
128
- XCTAllExpectations = [ ]
129
+ testCase. failIfExpectationsNotWaitedFor ( testCase. _allExpectations)
129
130
130
131
observationCenter. testCaseDidFinish ( testCase)
131
132
@@ -195,7 +196,7 @@ extension XCTestCase {
195
196
file: file,
196
197
line: line,
197
198
testCase: self )
198
- XCTAllExpectations . append ( expectation)
199
+ _allExpectations . append ( expectation)
199
200
return expectation
200
201
}
201
202
@@ -232,7 +233,7 @@ extension XCTestCase {
232
233
// the test to stop cold. swift-corelibs-xctest does not stop,
233
234
// and executes the rest of the test. This discrepancy should be
234
235
// fixed.
235
- if XCTAllExpectations . count == 0 {
236
+ if _allExpectations . count == 0 {
236
237
let failure = XCTFailure (
237
238
message: " call made to wait without any expectations having been set. " ,
238
239
failureDescription: " API violation " ,
@@ -261,7 +262,7 @@ extension XCTestCase {
261
262
let timeoutDate = NSDate ( timeIntervalSinceNow: timeout)
262
263
repeat {
263
264
unfulfilledDescriptions = [ ]
264
- for expectation in XCTAllExpectations {
265
+ for expectation in _allExpectations {
265
266
if !expectation. fulfilled {
266
267
unfulfilledDescriptions. append ( expectation. description)
267
268
}
@@ -294,7 +295,7 @@ extension XCTestCase {
294
295
295
296
// We've recorded all the failures; clear the expectations that
296
297
// were set for this test case.
297
- XCTAllExpectations = [ ]
298
+ _allExpectations = [ ]
298
299
299
300
// The handler is invoked regardless of whether the test passed.
300
301
if let completionHandler = handler {
0 commit comments