This commit is contained in:
@@ -12,8 +12,8 @@ final class DiagnosticsServiceTests: XCTestCase {
|
||||
diagnostics.incrementDatabaseMutation()
|
||||
diagnostics.incrementCachePurge()
|
||||
|
||||
// The counters use a serial async queue for low overhead; sync through reset's queue by reading a snapshot.
|
||||
let snapshot = waitForSnapshot { diagnostics.currentSnapshot() }
|
||||
// The snapshot read synchronizes with the serial diagnostics queue.
|
||||
let snapshot = diagnostics.currentSnapshot()
|
||||
XCTAssertEqual(snapshot.monitorTicks, 1)
|
||||
XCTAssertEqual(snapshot.pasteboardChanges, 1)
|
||||
XCTAssertEqual(snapshot.extractionAttempts, 1)
|
||||
@@ -23,13 +23,4 @@ final class DiagnosticsServiceTests: XCTestCase {
|
||||
diagnostics.reset()
|
||||
XCTAssertEqual(diagnostics.currentSnapshot(), .init(monitorTicks: 0, pasteboardChanges: 0, extractionAttempts: 0, databaseMutations: 0, cachePurges: 0))
|
||||
}
|
||||
|
||||
private func waitForSnapshot(_ snapshot: @escaping () -> DiagnosticsService.Snapshot) -> DiagnosticsService.Snapshot {
|
||||
let expectation = expectation(description: "diagnostics queue")
|
||||
DispatchQueue.global().asyncAfter(deadline: .now() + 0.05) {
|
||||
expectation.fulfill()
|
||||
}
|
||||
wait(for: [expectation], timeout: 1)
|
||||
return snapshot()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user