Skip to content

Commit

Permalink
Remove DispatchShims.swift and replace it with a conditional typealias
Browse files Browse the repository at this point in the history
The use of DispatchQueue in XCTest is now very limited, and it's only used
in a single place in XCTestCase.swift.
  • Loading branch information
kateinoigakukun committed Mar 12, 2024
1 parent 9decbc4 commit 2a46822
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 49 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Expand Up @@ -38,7 +38,6 @@ add_library(XCTest
Sources/XCTest/Private/WaiterManager.swift
Sources/XCTest/Private/IgnoredErrors.swift
Sources/XCTest/Private/XCTestCase.TearDownBlocksState.swift
Sources/XCTest/Private/DispatchShims.swift
Sources/XCTest/Public/XCTestRun.swift
Sources/XCTest/Public/XCTestMain.swift
Sources/XCTest/Public/XCTestCase.swift
Expand Down
47 changes: 0 additions & 47 deletions Sources/XCTest/Private/DispatchShims.swift

This file was deleted.

18 changes: 17 additions & 1 deletion Sources/XCTest/Public/XCTestCase.swift
Expand Up @@ -54,7 +54,23 @@ open class XCTestCase: XCTest {
return 1
}

internal static let subsystemQueue = DispatchQueue(label: "org.swift.XCTestCase")
#if DISABLE_XCTWAITER && os(WASI)
/// Single-threaded queue without any actual queueing
struct SubsystemQueue {
init(label: String) {}

func sync<T>(_ body: () -> T) -> T {
body()
}
func async(_ body: @escaping () -> Void) {
body()
}
}
#else
typealias SubsystemQueue = DispatchQueue
#endif

internal static let subsystemQueue = SubsystemQueue(label: "org.swift.XCTestCase")

#if !DISABLE_XCTWAITER
@MainActor
Expand Down

0 comments on commit 2a46822

Please sign in to comment.