@@ -21,11 +21,11 @@ import XCTest
21
21
22
22
/// Build system to be used for testing BuildSystem and BuildSystemDelegate functionality with SourceKitLSPServer
23
23
/// and other components.
24
- final class TestBuildSystem : BuildSystem {
25
- var projectRoot : AbsolutePath = try ! AbsolutePath ( validating: " / " )
26
- var indexStorePath : AbsolutePath ? = nil
27
- var indexDatabasePath : AbsolutePath ? = nil
28
- var indexPrefixMappings : [ PathPrefixMapping ] = [ ]
24
+ actor TestBuildSystem : BuildSystem {
25
+ let projectRoot : AbsolutePath = try ! AbsolutePath ( validating: " / " )
26
+ let indexStorePath : AbsolutePath ? = nil
27
+ let indexDatabasePath : AbsolutePath ? = nil
28
+ let indexPrefixMappings : [ PathPrefixMapping ] = [ ]
29
29
30
30
weak var delegate : BuildSystemDelegate ?
31
31
@@ -34,10 +34,14 @@ final class TestBuildSystem: BuildSystem {
34
34
}
35
35
36
36
/// Build settings by file.
37
- var buildSettingsByFile : [ DocumentURI : FileBuildSettings ] = [ : ]
37
+ private var buildSettingsByFile : [ DocumentURI : FileBuildSettings ] = [ : ]
38
38
39
39
/// Files currently being watched by our delegate.
40
- var watchedFiles : Set < DocumentURI > = [ ]
40
+ private var watchedFiles : Set < DocumentURI > = [ ]
41
+
42
+ func setBuildSettings( for uri: DocumentURI , to buildSettings: FileBuildSettings ) {
43
+ buildSettingsByFile [ uri] = buildSettings
44
+ }
41
45
42
46
func buildSettings(
43
47
for document: DocumentURI ,
@@ -160,7 +164,7 @@ final class BuildSystemTests: XCTestCase {
160
164
}
161
165
"""
162
166
163
- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
167
+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
164
168
165
169
let documentManager = await self . testClient. server. _documentManager
166
170
@@ -173,7 +177,7 @@ final class BuildSystemTests: XCTestCase {
173
177
// Modify the build settings and inform the delegate.
174
178
// This should trigger a new publish diagnostics and we should no longer have errors.
175
179
let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
176
- buildSystem. buildSettingsByFile [ doc] = newSettings
180
+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
177
181
178
182
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
179
183
@@ -194,7 +198,7 @@ final class BuildSystemTests: XCTestCase {
194
198
. buildSettings ( for: doc, language: . swift) !
195
199
. compilerArguments
196
200
197
- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
201
+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
198
202
199
203
let text = """
200
204
#if FOO
@@ -214,7 +218,7 @@ final class BuildSystemTests: XCTestCase {
214
218
// Modify the build settings and inform the delegate.
215
219
// This should trigger a new publish diagnostics and we should no longer have errors.
216
220
let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
217
- buildSystem. buildSettingsByFile [ doc] = newSettings
221
+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
218
222
219
223
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
220
224
@@ -248,7 +252,7 @@ final class BuildSystemTests: XCTestCase {
248
252
// Modify the build settings and inform the delegate.
249
253
// This should trigger a new publish diagnostics and we should see a diagnostic.
250
254
let newSettings = FileBuildSettings ( compilerArguments: args)
251
- buildSystem. buildSettingsByFile [ doc] = newSettings
255
+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
252
256
253
257
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
254
258
@@ -283,7 +287,7 @@ final class BuildSystemTests: XCTestCase {
283
287
XCTAssertEqual ( text, try documentManager. latestSnapshot ( doc) . text)
284
288
285
289
// Swap from fallback settings to primary build system settings.
286
- buildSystem. buildSettingsByFile [ doc] = primarySettings
290
+ await buildSystem. setBuildSettings ( for : doc, to : primarySettings)
287
291
288
292
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
289
293
0 commit comments