Skip to content

Commit 4785620

Browse files
authored
Merge pull request #71133 from tshortli/distributed-tests-5.10
[5.10] Update some Distributed tests to be less deployment target sensitive
2 parents 9f4a569 + ffeaba4 commit 4785620

4 files changed

+112
-80
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Distributed
2+
import FakeDistributedActorSystems
3+
4+
@available(SwiftStdlib 5.7, *)
5+
typealias DefaultDistributedActorSystem = LocalTestingDistributedActorSystem
6+
7+
@available(SwiftStdlib 5.7, *)
8+
distributed actor FiveSevenActor_NothingExecutor {
9+
nonisolated var unownedExecutor: UnownedSerialExecutor {
10+
print("get unowned executor")
11+
return MainActor.sharedUnownedExecutor
12+
}
13+
14+
distributed func test(x: Int) async throws {
15+
print("executed: \(#function)")
16+
defer {
17+
print("done executed: \(#function)")
18+
}
19+
MainActor.assumeIsolated {
20+
// ignore
21+
}
22+
}
23+
}
24+
25+
@available(SwiftStdlib 5.9, *)
26+
distributed actor FiveNineActor_NothingExecutor {
27+
nonisolated var unownedExecutor: UnownedSerialExecutor {
28+
print("get unowned executor")
29+
return MainActor.sharedUnownedExecutor
30+
}
31+
32+
distributed func test(x: Int) async throws {
33+
print("executed: \(#function)")
34+
defer {
35+
print("done executed: \(#function)")
36+
}
37+
MainActor.assumeIsolated {
38+
// ignore
39+
}
40+
}
41+
}
42+
43+
@available(SwiftStdlib 5.7, *)
44+
distributed actor FiveSevenActor_FiveNineExecutor {
45+
@available(SwiftStdlib 5.9, *)
46+
nonisolated var unownedExecutor: UnownedSerialExecutor {
47+
print("get unowned executor")
48+
return MainActor.sharedUnownedExecutor
49+
}
50+
51+
distributed func test(x: Int) async throws {
52+
print("executed: \(#function)")
53+
defer {
54+
print("done executed: \(#function)")
55+
}
56+
MainActor.assumeIsolated {
57+
// ignore
58+
}
59+
}
60+
}

test/Distributed/Runtime/distributed_actor_custom_executor_availability.swift

Lines changed: 5 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
3-
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
3+
// RUN: %target-build-swift -parse-as-library -target %target-swift-abi-5.7-triple -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift %S/../Inputs/CustomSerialExecutorAvailability.swift -o %t/a.out
44
// RUN: %target-codesign %t/a.out
5-
// RUN: %target-run %t/a.out
5+
// RUN: %target-run %t/a.out
6+
7+
// These are the only platforms for which compiling a Swift 5.7 aligned deployment target is possible.
8+
// REQUIRES: OS=macosx || OS=ios || OS=watchos || OS=tvos
69

710
// REQUIRES: executable_test
811
// REQUIRES: concurrency
@@ -16,65 +19,6 @@
1619

1720
import StdlibUnittest
1821
import Distributed
19-
import FakeDistributedActorSystems
20-
21-
@available(SwiftStdlib 5.7, *)
22-
typealias DefaultDistributedActorSystem = LocalTestingDistributedActorSystem
23-
24-
@available(SwiftStdlib 5.7, *)
25-
distributed actor FiveSevenActor_NothingExecutor {
26-
nonisolated var unownedExecutor: UnownedSerialExecutor {
27-
print("get unowned executor")
28-
return MainActor.sharedUnownedExecutor
29-
}
30-
31-
distributed func test(x: Int) async throws {
32-
print("executed: \(#function)")
33-
defer {
34-
print("done executed: \(#function)")
35-
}
36-
MainActor.assumeIsolated {
37-
// ignore
38-
}
39-
}
40-
}
41-
42-
@available(SwiftStdlib 5.9, *)
43-
distributed actor FiveNineActor_NothingExecutor {
44-
nonisolated var unownedExecutor: UnownedSerialExecutor {
45-
print("get unowned executor")
46-
return MainActor.sharedUnownedExecutor
47-
}
48-
49-
distributed func test(x: Int) async throws {
50-
print("executed: \(#function)")
51-
defer {
52-
print("done executed: \(#function)")
53-
}
54-
MainActor.assumeIsolated {
55-
// ignore
56-
}
57-
}
58-
}
59-
60-
@available(SwiftStdlib 5.7, *)
61-
distributed actor FiveSevenActor_FiveNineExecutor {
62-
@available(SwiftStdlib 5.9, *)
63-
nonisolated var unownedExecutor: UnownedSerialExecutor {
64-
print("get unowned executor")
65-
return MainActor.sharedUnownedExecutor
66-
}
67-
68-
distributed func test(x: Int) async throws {
69-
print("executed: \(#function)")
70-
defer {
71-
print("done executed: \(#function)")
72-
}
73-
MainActor.assumeIsolated {
74-
// ignore
75-
}
76-
}
77-
}
7822

7923
@main struct Main {
8024
static func main() async {
@@ -83,7 +27,6 @@ distributed actor FiveSevenActor_FiveNineExecutor {
8327

8428
let system = LocalTestingDistributedActorSystem()
8529

86-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
8730
tests.test("5.7 actor, no availability executor property => no custom executor") {
8831
expectCrashLater(withMessage: "Fatal error: Incorrect actor executor assumption; Expected 'MainActor' executor.")
8932
try! await FiveSevenActor_NothingExecutor(actorSystem: system).test(x: 42)
@@ -97,22 +40,6 @@ distributed actor FiveSevenActor_FiveNineExecutor {
9740
expectCrashLater(withMessage: "Fatal error: Incorrect actor executor assumption; Expected 'MainActor' executor.")
9841
try! await FiveSevenActor_FiveNineExecutor(actorSystem: system).test(x: 42)
9942
}
100-
#else
101-
// On non-apple platforms the SDK comes with the toolchains,
102-
// so the feature works because we're executing in a 5.9 context already,
103-
// which otherwise could not have been compiled
104-
tests.test("non apple platform: 5.7 actor, no availability executor property => no custom executor") {
105-
try! await FiveSevenActor_NothingExecutor(actorSystem: system).test(x: 42)
106-
}
107-
108-
tests.test("non apple platform: 5.9 actor, no availability executor property => custom executor") {
109-
try! await FiveNineActor_NothingExecutor(actorSystem: system).test(x: 42)
110-
}
111-
112-
tests.test("non apple platform: 5.7 actor, 5.9 executor property => no custom executor") {
113-
try! await FiveSevenActor_FiveNineExecutor(actorSystem: system).test(x: 42)
114-
}
115-
#endif
11643

11744
await runAllTestsAsync()
11845
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
3+
// RUN: %target-build-swift -parse-as-library -target %target-swift-abi-5.9-triple -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift %S/../Inputs/CustomSerialExecutorAvailability.swift -o %t/a.out
4+
// RUN: %target-codesign %t/a.out
5+
// RUN: %target-run %t/a.out
6+
7+
// REQUIRES: executable_test
8+
// REQUIRES: concurrency
9+
// REQUIRES: distributed
10+
// REQUIRES: concurrency_runtime
11+
// UNSUPPORTED: back_deployment_runtime
12+
13+
// UNSUPPORTED: back_deploy_concurrency
14+
// UNSUPPORTED: use_os_stdlib
15+
// UNSUPPORTED: freestanding
16+
17+
import StdlibUnittest
18+
import Distributed
19+
20+
@main struct Main {
21+
static func main() async {
22+
if #available(SwiftStdlib 5.9, *) {
23+
let tests = TestSuite("DistributedActorExecutorAvailabilitySwift59")
24+
25+
let system = LocalTestingDistributedActorSystem()
26+
27+
// On non-apple platforms the SDK comes with the toolchains,
28+
// so the feature works because we're executing in a 5.9 context already,
29+
// which otherwise could not have been compiled
30+
tests.test("non apple platform: 5.7 actor, no availability executor property => no custom executor") {
31+
try! await FiveSevenActor_NothingExecutor(actorSystem: system).test(x: 42)
32+
}
33+
34+
tests.test("non apple platform: 5.9 actor, no availability executor property => custom executor") {
35+
try! await FiveNineActor_NothingExecutor(actorSystem: system).test(x: 42)
36+
}
37+
38+
tests.test("non apple platform: 5.7 actor, 5.9 executor property => no custom executor") {
39+
try! await FiveSevenActor_FiveNineExecutor(actorSystem: system).test(x: 42)
40+
}
41+
42+
await runAllTestsAsync()
43+
}
44+
}
45+
}

test/Distributed/distributed_actor_accessor_thunks_64bit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ public distributed actor MyOtherActor {
104104
// CHECK: [[ARG_0_SIZE_ADJ:%.*]] = add i64 %size, 15
105105
// CHECK-NEXT: [[ARG_0_SIZE:%.*]] = and i64 [[ARG_0_SIZE_ADJ]], -16
106106
// CHECK-NEXT: [[ARG_0_VALUE_BUF:%.*]] = call swiftcc ptr @swift_task_alloc(i64 [[ARG_0_SIZE]])
107-
// CHECK-NEXT: [[ENCODABLE_WITNESS:%.*]] = call ptr @swift_conformsToProtocol(ptr %arg_type, ptr @"$sSeMp")
107+
// CHECK-NEXT: [[ENCODABLE_WITNESS:%.*]] = call ptr @swift_conformsToProtocol{{(2)?}}(ptr %arg_type, ptr @"$sSeMp")
108108
// CHECK-NEXT: [[IS_NULL:%.*]] = icmp eq ptr [[ENCODABLE_WITNESS]], null
109109
// CHECK-NEXT: br i1 [[IS_NULL]], label %missing-witness, label [[CONT:%.*]]
110110
// CHECK: missing-witness:
111111
// CHECK-NEXT: call void @llvm.trap()
112112
// CHECK-NEXT: unreachable
113-
// CHECK: [[DECODABLE_WITNESS:%.*]] = call ptr @swift_conformsToProtocol(ptr %arg_type, ptr @"$sSEMp")
113+
// CHECK: [[DECODABLE_WITNESS:%.*]] = call ptr @swift_conformsToProtocol{{(2)?}}(ptr %arg_type, ptr @"$sSEMp")
114114
// CHECK-NEXT: [[IS_NULL:%.*]] = icmp eq ptr [[DECODABLE_WITNESS]], null
115115
// CHECK-NEXT: br i1 [[IS_NULL]], label %missing-witness1, label [[CONT:%.*]]
116116
// CHECK: missing-witness1:

0 commit comments

Comments
 (0)