Skip to content

Commit ba4165a

Browse files
authored
[6.0][Concurrency] Avoid using "not" in crash tests; use not.py (swiftlang#75168)
1 parent 6741653 commit ba4165a

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

test/Concurrency/Runtime/actor_assert_precondition_executor_checkIsolated_main_customExecutorOnMain_swift6_mode.swift

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-build-swift -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library %s -o %t/a.out
33
// RUN: %target-codesign %t/a.out
4+
45
// 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
67

78
// REQUIRES: executable_test
89
// REQUIRES: concurrency
@@ -22,6 +23,22 @@
2223
// UNSUPPORTED: single_threaded_concurrency
2324

2425
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
2542

2643
@available(SwiftStdlib 6.0, *)
2744
final class NaiveOnMainQueueExecutor: SerialExecutor {
@@ -67,12 +84,26 @@ actor ActorOnNaiveOnMainQueueExecutor {
6784

6885
@main struct Main {
6986
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+
7095
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+
}
76105
}
106+
107+
await runAllTestsAsync()
77108
}
78109
}

0 commit comments

Comments
 (0)