@@ -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 ,
@@ -158,7 +162,7 @@ final class BuildSystemTests: XCTestCase {
158162 }
159163 """
160164
161- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
165+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
162166
163167 let documentManager = await self . testClient. server. _documentManager
164168
@@ -171,7 +175,7 @@ final class BuildSystemTests: XCTestCase {
171175 // Modify the build settings and inform the delegate.
172176 // This should trigger a new publish diagnostics and we should no longer have errors.
173177 let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
174- buildSystem. buildSettingsByFile [ doc] = newSettings
178+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
175179
176180 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
177181
@@ -190,7 +194,7 @@ final class BuildSystemTests: XCTestCase {
190194 let doc = DocumentURI . for ( . swift)
191195 let args = FallbackBuildSystem ( buildSetup: . default) . buildSettings ( for: doc, language: . swift) !. compilerArguments
192196
193- buildSystem. buildSettingsByFile [ doc] = FileBuildSettings ( compilerArguments: args)
197+ await buildSystem. setBuildSettings ( for : doc, to : FileBuildSettings ( compilerArguments: args) )
194198
195199 let text = """
196200 #if FOO
@@ -210,7 +214,7 @@ final class BuildSystemTests: XCTestCase {
210214 // Modify the build settings and inform the delegate.
211215 // This should trigger a new publish diagnostics and we should no longer have errors.
212216 let newSettings = FileBuildSettings ( compilerArguments: args + [ " -DFOO " ] )
213- buildSystem. buildSettingsByFile [ doc] = newSettings
217+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
214218
215219 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
216220
@@ -244,7 +248,7 @@ final class BuildSystemTests: XCTestCase {
244248 // Modify the build settings and inform the delegate.
245249 // This should trigger a new publish diagnostics and we should see a diagnostic.
246250 let newSettings = FileBuildSettings ( compilerArguments: args)
247- buildSystem. buildSettingsByFile [ doc] = newSettings
251+ await buildSystem. setBuildSettings ( for : doc, to : newSettings)
248252
249253 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
250254
@@ -279,7 +283,7 @@ final class BuildSystemTests: XCTestCase {
279283 XCTAssertEqual ( text, try documentManager. latestSnapshot ( doc) . text)
280284
281285 // Swap from fallback settings to primary build system settings.
282- buildSystem. buildSettingsByFile [ doc] = primarySettings
286+ await buildSystem. setBuildSettings ( for : doc, to : primarySettings)
283287
284288 await buildSystem. delegate? . fileBuildSettingsChanged ( [ doc] )
285289
0 commit comments