-
-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathJavaScriptEventLoopTestSupport.swift
More file actions
33 lines (28 loc) · 981 Bytes
/
JavaScriptEventLoopTestSupport.swift
File metadata and controls
33 lines (28 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/// If you need to execute Swift async functions that can be resumed by JS
/// event loop in your XCTest suites, please add `JavaScriptEventLoopTestSupport`
/// to your test target dependencies.
///
/// ```diff
/// .testTarget(
/// name: "MyAppTests",
/// dependencies: [
/// "MyApp",
/// + "JavaScriptEventLoopTestSupport",
/// ]
/// )
/// ```
///
/// Linking this module automatically activates JS event loop based global
/// executor by calling `JavaScriptEventLoop.installGlobalExecutor()`
import JavaScriptEventLoop
// This module just expose 'JavaScriptEventLoop.installGlobalExecutor' to C ABI
// See _CJavaScriptEventLoopTestSupport.c for why this is needed
#if compiler(>=5.5)
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
@_cdecl("swift_javascriptkit_activate_js_executor_impl")
func swift_javascriptkit_activate_js_executor_impl() {
MainActor.assumeIsolated {
JavaScriptEventLoop.installGlobalExecutor()
}
}
#endif