@@ -14,6 +14,8 @@ import SourceKitD
14
14
import SKCore
15
15
import TSCBasic
16
16
import TSCUtility
17
+ import ISDBTibs
18
+ import ISDBTestSupport
17
19
import XCTest
18
20
19
21
final class SourceKitDTests : XCTestCase {
@@ -31,26 +33,38 @@ final class SourceKitDTests: XCTestCase {
31
33
}
32
34
33
35
func testMultipleNotificationHandlers( ) {
36
+ let ws = try ! mutableTibsTestWorkspace ( name: " proj1 " ) !
34
37
let sourcekitd = try ! SourceKitDImpl . getOrCreate ( dylibPath: SourceKitDTests . sourcekitdPath)
35
38
let keys = sourcekitd. keys
39
+ let path : String = ws. testLoc ( " c " ) . url. path
40
+
41
+ let isExpectedNotification = { ( response: SKDResponse ) -> Bool in
42
+ if let notification: sourcekitd_uid_t = response. value ? [ keys. notification] ,
43
+ let name: String = response. value ? [ keys. name]
44
+ {
45
+ return name == path && notification == sourcekitd. values. notification_documentupdate
46
+ }
47
+ return false
48
+ }
36
49
37
50
let expectation1 = expectation ( description: " handler 1 " )
38
51
let handler1 = ClosureNotificationHandler { response in
39
- XCTAssertEqual ( response. value ? [ keys. notification] , sourcekitd. values. notification_documentupdate)
40
- expectation1. fulfill ( )
52
+ if isExpectedNotification ( response) {
53
+ expectation1. fulfill ( )
54
+ }
41
55
}
42
56
sourcekitd. addNotificationHandler ( handler1)
43
57
44
58
let expectation2 = expectation ( description: " handler 2 " )
45
59
let handler2 = ClosureNotificationHandler { response in
46
- XCTAssertEqual ( response. value ? [ keys. notification] , sourcekitd. values. notification_documentupdate)
47
- expectation2. fulfill ( )
60
+ if isExpectedNotification ( response) {
61
+ expectation2. fulfill ( )
62
+ }
48
63
}
49
64
sourcekitd. addNotificationHandler ( handler2)
50
65
51
66
let req = SKDRequestDictionary ( sourcekitd: sourcekitd)
52
67
req [ keys. request] = sourcekitd. requests. editor_open
53
- let path : String = #file
54
68
req [ keys. name] = path
55
69
req [ keys. sourcetext] = """
56
70
func foo() {}
0 commit comments