8
8
// UNSUPPORTED: use_os_stdlib
9
9
// UNSUPPORTED: back_deployment_runtime
10
10
11
- // FIXME(distributed): we need to revisit what's going on on windows with distributed actors rdar://84574311
11
+ // FIXME(distributed): we need to revisit what's going on on windows with distributed actors rdar://83859906
12
12
// UNSUPPORTED: OS=windows-msvc
13
13
14
- // Disabled temporarily until we figure out why the test is flaky.
15
- // REQUIRES: rdar84586299
16
-
17
14
import _Distributed
18
15
19
16
enum MyError : Error {
@@ -76,6 +73,9 @@ struct ActorAddress: ActorIdentity {
76
73
}
77
74
}
78
75
76
+ // global to track available IDs
77
+ var nextID : Int = 1
78
+
79
79
@available ( SwiftStdlib 5 . 5 , * )
80
80
struct FakeTransport : ActorTransport {
81
81
func decodeIdentity( from decoder: Decoder ) throws -> AnyActorIdentity {
@@ -89,7 +89,8 @@ struct FakeTransport: ActorTransport {
89
89
90
90
func assignIdentity< Act> ( _ actorType: Act . Type ) -> AnyActorIdentity
91
91
where Act: DistributedActor {
92
- let id = ActorAddress ( parse: " xxx " )
92
+ let id = ActorAddress ( parse: " \( nextID) " )
93
+ nextID += 1
93
94
print ( " assign type: \( actorType) , id: \( id) " )
94
95
return . init( id)
95
96
}
@@ -109,48 +110,47 @@ struct FakeTransport: ActorTransport {
109
110
func test( ) async {
110
111
let transport = FakeTransport ( )
111
112
112
- _ = LocalWorker ( transport: transport)
113
- // CHECK: assign type:LocalWorker, id:ActorAddress(address: "[[ID:.*]]")
114
- // CHECK: ready actor:main.LocalWorker, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
115
- // CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
113
+ // NOTE: All allocated distributed actors should be saved in this array, so
114
+ // that they will be deallocated together at the end of this test!
115
+ // This convention helps ensure that the test is not flaky.
116
+ var test : [ DistributedActor ? ] = [ ]
117
+
118
+ test. append ( LocalWorker ( transport: transport) )
119
+ // CHECK: assign type:LocalWorker, id:ActorAddress(address: "[[ID1:.*]]")
120
+ // CHECK: ready actor:main.LocalWorker, id:AnyActorIdentity(ActorAddress(address: "[[ID1]]"))
116
121
117
- _ = PickATransport1 ( kappa: transport, other: 0 )
118
- // CHECK: assign type:PickATransport1, id:ActorAddress(address: "[[ID:.*]]")
119
- // CHECK: ready actor:main.PickATransport1, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
120
- // CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
122
+ test. append ( PickATransport1 ( kappa: transport, other: 0 ) )
123
+ // CHECK: assign type:PickATransport1, id:ActorAddress(address: "[[ID2:.*]]")
124
+ // CHECK: ready actor:main.PickATransport1, id:AnyActorIdentity(ActorAddress(address: "[[ID2]]"))
121
125
122
- _ = try ? Throwy ( transport: transport, doThrow: false )
123
- // CHECK: assign type:Throwy, id:ActorAddress(address: "[[ID:.*]]")
124
- // CHECK: ready actor:main.Throwy, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
125
- // CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
126
+ test. append ( try ? Throwy ( transport: transport, doThrow: false ) )
127
+ // CHECK: assign type:Throwy, id:ActorAddress(address: "[[ID3:.*]]")
128
+ // CHECK: ready actor:main.Throwy, id:AnyActorIdentity(ActorAddress(address: "[[ID3]]"))
126
129
127
- _ = try ? Throwy ( transport: transport, doThrow: true )
128
- // CHECK: assign type:Throwy, id:ActorAddress(address: "[[ID :.*]]")
130
+ test . append ( try ? Throwy ( transport: transport, doThrow: true ) )
131
+ // CHECK: assign type:Throwy, id:ActorAddress(address: "[[ID4 :.*]]")
129
132
// CHECK-NOT: ready
130
- // CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
131
-
132
- _ = try ? ThrowBeforeFullyInit ( transport: transport, doThrow: true )
133
- // CHECK: assign type:ThrowBeforeFullyInit, id:ActorAddress(address: "[[ID:.*]]")
134
- // FIXME: The two checks below should work, but do not currently, so they're disabled (rdar://84533820).
135
- // MISSING-CHECK-NOT: ready actor:main.ThrowBeforeFullyInit
136
- // MISSING-CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
137
-
138
- _ = await PickATransport2 ( other: 1 , theTransport: transport)
139
- // CHECK: assign type:PickATransport2, id:ActorAddress(address: "[[ID:.*]]")
140
- // CHECK: ready actor:main.PickATransport2, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
141
-
142
- // FIXME: The checks for this initializer should NOT pass, but currently do. (rdar://84533820)
143
- _ = await Bug_CallsReadyTwice ( transport: transport, wantBug: true )
144
- // CHECK: assign type:Bug_CallsReadyTwice, id:ActorAddress(address: "[[ID:.*]]")
145
- // CHECK: ready actor:main.Bug_CallsReadyTwice, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
146
- // CHECK-NEXT: ready actor:main.Bug_CallsReadyTwice, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
147
-
148
- // TODO: it's not obvious why the resigns happen later for the async ones.
149
- // might need to find a way to force the deallocation at a specific point,
150
- // or just use check-dag or something.
151
-
152
- // CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
153
- // CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
133
+
134
+ test. append ( try ? ThrowBeforeFullyInit ( transport: transport, doThrow: true ) )
135
+ // CHECK: assign type:ThrowBeforeFullyInit, id:ActorAddress(address: "[[ID5:.*]]")
136
+ // CHECK-NOT: ready
137
+
138
+ test. append ( await PickATransport2 ( other: 1 , theTransport: transport) )
139
+ // CHECK: assign type:PickATransport2, id:ActorAddress(address: "[[ID6:.*]]")
140
+ // CHECK: ready actor:main.PickATransport2, id:AnyActorIdentity(ActorAddress(address: "[[ID6]]"))
141
+
142
+ test. append ( await Bug_CallsReadyTwice ( transport: transport, wantBug: true ) )
143
+ // CHECK: assign type:Bug_CallsReadyTwice, id:ActorAddress(address: "[[ID7:.*]]")
144
+ // CHECK: ready actor:main.Bug_CallsReadyTwice, id:AnyActorIdentity(ActorAddress(address: "[[ID7]]"))
145
+ // CHECK-NEXT: ready actor:main.Bug_CallsReadyTwice, id:AnyActorIdentity(ActorAddress(address: "[[ID7]]"))
146
+
147
+ // CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID1]]"))
148
+ // CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID2]]"))
149
+ // CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID3]]"))
150
+ // MISSING-CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID4]]")) // FIXME: should eventually work (rdar://84533820).
151
+ // MISSING-CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID5]]")) // FIXME: should eventually work (rdar://84533820).
152
+ // CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID6]]"))
153
+ // CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID7]]"))
154
154
}
155
155
156
156
@available ( SwiftStdlib 5 . 5 , * )
0 commit comments