Skip to content

Commit 5ecae9b

Browse files
committed
Fix two concurrency warnings in LoggingTests.swift
1 parent 611f9b5 commit 5ecae9b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Tests/LSPLoggingTests/LoggingTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fileprivate func assertLogging(
2222
file: StaticString = #filePath,
2323
line: UInt = #line
2424
) {
25-
var messages: [String] = []
25+
// nonisolated(unsafe) because calls of `assertLogging` do not log to `logHandler` concurrently.
26+
nonisolated(unsafe) var messages: [String] = []
2627
let logger = NonDarwinLogger(
2728
subsystem: subsystem,
2829
category: "test",
@@ -71,7 +72,8 @@ fileprivate func assertLogging(
7172
final class LoggingTests: XCTestCase {
7273
func testLoggingFormat() async throws {
7374
let expectation = self.expectation(description: "message logged")
74-
var message: String = ""
75+
// nonisolated(unsafe) because we only have a single call to `logger.log` and that cannot race.
76+
nonisolated(unsafe) var message: String = ""
7577
let logger = NonDarwinLogger(
7678
subsystem: subsystem,
7779
category: "test",

0 commit comments

Comments
 (0)