Skip to content

Commit fddccdb

Browse files
authored
Merge pull request #71132 from tshortli/distributed-tests
Update some Distributed tests to be less deployment target sensitive
2 parents b8cd7ef + fdc7ebd commit fddccdb

4 files changed

+114
-82
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
@available(SwiftStdlib 5.9, *)
15+
distributed func test(x: Int) throws {
16+
print("executed: \(#function)")
17+
defer {
18+
print("done executed: \(#function)")
19+
}
20+
MainActor.assumeIsolated {
21+
// ignore
22+
}
23+
}
24+
}
25+
26+
@available(SwiftStdlib 5.9, *)
27+
distributed actor FiveNineActor_NothingExecutor {
28+
nonisolated var unownedExecutor: UnownedSerialExecutor {
29+
print("get unowned executor")
30+
return MainActor.sharedUnownedExecutor
31+
}
32+
33+
distributed func test(x: Int) throws {
34+
print("executed: \(#function)")
35+
defer {
36+
print("done executed: \(#function)")
37+
}
38+
MainActor.assumeIsolated {
39+
// ignore
40+
}
41+
}
42+
}
43+
44+
@available(SwiftStdlib 5.7, *)
45+
distributed actor FiveSevenActor_FiveNineExecutor {
46+
@available(SwiftStdlib 5.9, *)
47+
nonisolated var unownedExecutor: UnownedSerialExecutor {
48+
print("get unowned executor")
49+
return MainActor.sharedUnownedExecutor
50+
}
51+
52+
@available(SwiftStdlib 5.9, *)
53+
distributed func test(x: Int) throws {
54+
print("executed: \(#function)")
55+
defer {
56+
print("done executed: \(#function)")
57+
}
58+
MainActor.assumeIsolated {
59+
// ignore
60+
}
61+
}
62+
}

test/Distributed/Runtime/distributed_actor_custom_executor_availability.swift

Lines changed: 5 additions & 80 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 %S/../Inputs/FakeDistributedActorSystems.swift
3-
// RUN: %target-build-swift -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,67 +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-
@available(SwiftStdlib 5.9, *)
32-
distributed func test(x: Int) 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.9, *)
44-
distributed actor FiveNineActor_NothingExecutor {
45-
nonisolated var unownedExecutor: UnownedSerialExecutor {
46-
print("get unowned executor")
47-
return MainActor.sharedUnownedExecutor
48-
}
49-
50-
distributed func test(x: Int) throws {
51-
print("executed: \(#function)")
52-
defer {
53-
print("done executed: \(#function)")
54-
}
55-
MainActor.assumeIsolated {
56-
// ignore
57-
}
58-
}
59-
}
60-
61-
@available(SwiftStdlib 5.7, *)
62-
distributed actor FiveSevenActor_FiveNineExecutor {
63-
@available(SwiftStdlib 5.9, *)
64-
nonisolated var unownedExecutor: UnownedSerialExecutor {
65-
print("get unowned executor")
66-
return MainActor.sharedUnownedExecutor
67-
}
68-
69-
@available(SwiftStdlib 5.9, *)
70-
distributed func test(x: Int) throws {
71-
print("executed: \(#function)")
72-
defer {
73-
print("done executed: \(#function)")
74-
}
75-
MainActor.assumeIsolated {
76-
// ignore
77-
}
78-
}
79-
}
8022

8123
@available(SwiftStdlib 5.7, *)
8224
@main struct Main {
@@ -86,7 +28,6 @@ distributed actor FiveSevenActor_FiveNineExecutor {
8628

8729
let system = LocalTestingDistributedActorSystem()
8830

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

12045
await runAllTestsAsync()
12146
}
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)