Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions Sources/InlineSnapshotTesting/AssertInlineSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,24 +340,15 @@ public struct InlineSnapshotSyntaxDescriptor: Hashable {
writeInlineSnapshots()
}
}
DispatchQueue.mainSync {
if Thread.isMainThread {
XCTestObservationCenter.shared.addTestObserver(InlineSnapshotObserver())
} else {
DispatchQueue.main.sync {
XCTestObservationCenter.shared.addTestObserver(InlineSnapshotObserver())
}
}
}()

extension DispatchQueue {
private static let key = DispatchSpecificKey<UInt8>()
private static let value: UInt8 = 0

fileprivate static func mainSync<R>(execute block: () -> R) -> R {
Self.main.setSpecific(key: key, value: value)
if getSpecific(key: key) == value {
return block()
} else {
return main.sync(execute: block)
}
}
}

@_spi(Internals) public struct File: Hashable {
public let path: StaticString
Expand Down