@@ -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 ,
@@ -158,7 +162,7 @@ final class BuildSystemTests: XCTestCase {
158
162
}
159
163
"""
160
164
161
- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
165
+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
162
166
163
167
let documentManager = await self . testClient. server. _documentManager
164
168
@@ -171,7 +175,7 @@ final class BuildSystemTests: XCTestCase {
171
175
// Modify the build settings and inform the delegate.
172
176
// This should trigger a new publish diagnostics and we should no longer have errors.
173
177
let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
174
- buildSystem. buildSettingsByFile [ doc] = newSettings
178
+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
175
179
176
180
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
177
181
@@ -190,7 +194,7 @@ final class BuildSystemTests: XCTestCase {
190
194
let doc = DocumentURI . for ( . swift)
191
195
let args = FallbackBuildSystem ( buildSetup: . default) . buildSettings ( for: doc, language: . swift) !. compilerArguments
192
196
193
- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
197
+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
194
198
195
199
let text = """
196
200
#if FOO
@@ -210,7 +214,7 @@ final class BuildSystemTests: XCTestCase {
210
214
// Modify the build settings and inform the delegate.
211
215
// This should trigger a new publish diagnostics and we should no longer have errors.
212
216
let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
213
- buildSystem. buildSettingsByFile [ doc] = newSettings
217
+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
214
218
215
219
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
216
220
@@ -244,7 +248,7 @@ final class BuildSystemTests: XCTestCase {
244
248
// Modify the build settings and inform the delegate.
245
249
// This should trigger a new publish diagnostics and we should see a diagnostic.
246
250
let newSettings = FileBuildSettings ( compilerArguments: args)
247
- buildSystem. buildSettingsByFile [ doc] = newSettings
251
+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
248
252
249
253
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
250
254
@@ -279,7 +283,7 @@ final class BuildSystemTests: XCTestCase {
279
283
XCTAssertEqual ( text, try documentManager. latestSnapshot ( doc) . text)
280
284
281
285
// Swap from fallback settings to primary build system settings.
282
- buildSystem. buildSettingsByFile [ doc] = primarySettings
286
+ await buildSystem. setBuildSettings ( for : doc, to : primarySettings)
283
287
284
288
await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
285
289
0 commit comments