Skip to content

Commit 388ec3e

Browse files
authored
Merge pull request swiftlang#270 from benlangmuir/tsan-fix
[test] Fix data race in build system test
2 parents 5892c04 + 233ab60 commit 388ec3e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Tests/SKCoreTests/BuildSystemManagerTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,12 @@ final class BuildSystemManagerTests: XCTestCase {
380380

381381
/// A simple `MainFilesProvider` that wraps a dictionary, for testing.
382382
private final class ManualMainFilesProvider: MainFilesProvider {
383-
var mainFiles: [DocumentURI: Set<DocumentURI>] = [:]
383+
let lock: DispatchQueue = DispatchQueue(label: "\(ManualMainFilesProvider.self)-lock")
384+
private var _mainFiles: [DocumentURI: Set<DocumentURI>] = [:]
385+
var mainFiles: [DocumentURI: Set<DocumentURI>] {
386+
get { lock.sync { _mainFiles } }
387+
set { lock.sync { _mainFiles = newValue } }
388+
}
384389

385390
func mainFilesContainingFile(_ file: DocumentURI) -> Set<DocumentURI> {
386391
if let result = mainFiles[file] {

Utilities/build-script-helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def handle_invocation(swift_exec, args):
114114
if args.sanitize and 'undefined' in args.sanitize:
115115
supp = os.path.join(args.package_path, 'Utilities', 'ubsan_supressions.supp')
116116
env['UBSAN_OPTIONS'] = 'halt_on_error=true,suppressions=%s' % supp
117-
117+
if args.sanitize and 'thread' in args.sanitize:
118+
env['TSAN_OPTIONS'] = 'halt_on_error=true'
118119

119120
if args.action == 'build':
120121
swiftpm('build', swift_exec, swiftpm_args, env)

0 commit comments

Comments
 (0)