@@ -21,11 +21,11 @@ import XCTest
2121
2222/// Build system to be used for testing BuildSystem and BuildSystemDelegate functionality with SourceKitLSPServer
2323/// 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 ] = [ ]
2929
3030 weak var delegate : BuildSystemDelegate ?
3131
@@ -34,10 +34,14 @@ final class TestBuildSystem: BuildSystem {
3434 }
3535
3636 /// Build settings by file.
37- var buildSettingsByFile : [ DocumentURI : FileBuildSettings ] = [ : ]
37+ private var buildSettingsByFile : [ DocumentURI : FileBuildSettings ] = [ : ]
3838
3939 /// 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+ }
4145
4246 func buildSettings(
4347 for document: DocumentURI ,
@@ -160,7 +164,7 @@ final class BuildSystemTests: XCTestCase {
160164 }
161165 """
162166
163- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
167+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
164168
165169 let documentManager = await self . testClient. server. _documentManager
166170
@@ -173,7 +177,7 @@ final class BuildSystemTests: XCTestCase {
173177 // Modify the build settings and inform the delegate.
174178 // This should trigger a new publish diagnostics and we should no longer have errors.
175179 let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
176- buildSystem. buildSettingsByFile [ doc] = newSettings
180+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
177181
178182 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
179183
@@ -194,7 +198,7 @@ final class BuildSystemTests: XCTestCase {
194198 . buildSettings ( for: doc, language: . swift) !
195199 . compilerArguments
196200
197- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
201+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
198202
199203 let text = """
200204 #if FOO
@@ -214,7 +218,7 @@ final class BuildSystemTests: XCTestCase {
214218 // Modify the build settings and inform the delegate.
215219 // This should trigger a new publish diagnostics and we should no longer have errors.
216220 let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
217- buildSystem. buildSettingsByFile [ doc] = newSettings
221+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
218222
219223 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
220224
@@ -248,7 +252,7 @@ final class BuildSystemTests: XCTestCase {
248252 // Modify the build settings and inform the delegate.
249253 // This should trigger a new publish diagnostics and we should see a diagnostic.
250254 let newSettings = FileBuildSettings ( compilerArguments: args)
251- buildSystem. buildSettingsByFile [ doc] = newSettings
255+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
252256
253257 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
254258
@@ -283,7 +287,7 @@ final class BuildSystemTests: XCTestCase {
283287 XCTAssertEqual ( text, try documentManager. latestSnapshot ( doc) . text)
284288
285289 // Swap from fallback settings to primary build system settings.
286- buildSystem. buildSettingsByFile [ doc] = primarySettings
290+ await buildSystem. setBuildSettings ( for : doc, to : primarySettings)
287291
288292 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
289293
0 commit comments