|
1 | 1 | // RUN: %empty-directory(%t)
|
2 | 2 | // RUN: %target-build-swift -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library %s -o %t/a.out
|
3 | 3 | // RUN: %target-codesign %t/a.out
|
| 4 | + |
4 | 5 | // RUN: %env-SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE=swift6 %target-run %t/a.out
|
5 |
| -// RUN: %env-SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE=legacy not --crash %target-run %t/a.out |
| 6 | +// RUN: %env-SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE=legacy %target-run %t/a.out |
6 | 7 |
|
7 | 8 | // REQUIRES: executable_test
|
8 | 9 | // REQUIRES: concurrency
|
|
22 | 23 | // UNSUPPORTED: single_threaded_concurrency
|
23 | 24 |
|
24 | 25 | import Dispatch
|
| 26 | +import StdlibUnittest |
| 27 | + |
| 28 | +#if canImport(Darwin) |
| 29 | +import Darwin |
| 30 | +#elseif canImport(Glibc) |
| 31 | +import Glibc |
| 32 | +#elseif canImport(Musl) |
| 33 | +import Musl |
| 34 | +#elseif canImport(Android) |
| 35 | +import Android |
| 36 | +#elseif os(WASI) |
| 37 | +import WASILibc |
| 38 | +#elseif os(Windows) |
| 39 | +import CRT |
| 40 | +import WinSDK |
| 41 | +#endif |
25 | 42 |
|
26 | 43 | @available(SwiftStdlib 6.0, *)
|
27 | 44 | final class NaiveOnMainQueueExecutor: SerialExecutor {
|
@@ -67,12 +84,26 @@ actor ActorOnNaiveOnMainQueueExecutor {
|
67 | 84 |
|
68 | 85 | @main struct Main {
|
69 | 86 | static func main() async {
|
| 87 | + let tests = TestSuite(#file) |
| 88 | + |
| 89 | + let varName = "SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE" |
| 90 | + guard let _mode = getenv(varName) else { |
| 91 | + fatalError("Env variable required by test was not set: \(varName)") |
| 92 | + } |
| 93 | + let mode = String(validatingCString: _mode)! |
| 94 | + |
70 | 95 | if #available(SwiftStdlib 6.0, *) {
|
71 |
| - let actor = ActorOnNaiveOnMainQueueExecutor() |
72 |
| - await actor.checkPreconditionIsolated() |
73 |
| - // CHECK: Before preconditionIsolated |
74 |
| - // CHECK-NEXT: checkIsolated: pretend it is ok! |
75 |
| - // CHECK-NEXT: After preconditionIsolated |
| 96 | + tests.test("test preconditionIsolated in mode: \(mode)") { |
| 97 | + if (mode == "legacy") { |
| 98 | + expectCrashLater() |
| 99 | + } // else, swift6 mode should not crash |
| 100 | + |
| 101 | + |
| 102 | + let actor = ActorOnNaiveOnMainQueueExecutor() |
| 103 | + await actor.checkPreconditionIsolated() |
| 104 | + } |
76 | 105 | }
|
| 106 | + |
| 107 | + await runAllTestsAsync() |
77 | 108 | }
|
78 | 109 | }
|
0 commit comments