|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -target %target-swift-5.7-abi-triple %S/../Inputs/FakeDistributedActorSystems.swift |
| 3 | +// RUN: %target-build-swift -module-name main -target %target-swift-5.7-abi-triple -j2 -parse-as-library -plugin-path %swift-plugin-dir -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out |
| 4 | +// RUN: %target-codesign %t/a.out |
| 5 | +// RUN: %target-run %t/a.out | %FileCheck %s |
| 6 | + |
| 7 | +// REQUIRES: executable_test |
| 8 | +// REQUIRES: concurrency |
| 9 | +// REQUIRES: distributed |
| 10 | + |
| 11 | +// rdar://76038845 |
| 12 | +// UNSUPPORTED: use_os_stdlib |
| 13 | +// UNSUPPORTED: back_deployment_runtime |
| 14 | + |
| 15 | +// FIXME(distributed): Distributed actors currently have some issues on windows, isRemote always returns false. rdar://82593574 |
| 16 | +// UNSUPPORTED: OS=windows-msvc |
| 17 | + |
| 18 | +import Distributed |
| 19 | +import FakeDistributedActorSystems |
| 20 | + |
| 21 | +typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem |
| 22 | + |
| 23 | +struct SuperLargeSizeStruct: Codable { |
| 24 | + let i1a: Int = 0 |
| 25 | + let i2a: Int = 0 |
| 26 | + let i3a: Int = 0 |
| 27 | + let i4a: Int = 0 |
| 28 | + let i5a: Int = 0 |
| 29 | + let i6a: Int = 0 |
| 30 | + let i7a: Int = 0 |
| 31 | + let i8a: Int = 0 |
| 32 | +} |
| 33 | + |
| 34 | +@available(SwiftStdlib 6.0, *) |
| 35 | +distributed actor TheWorker { |
| 36 | + typealias ActorSystem = DefaultDistributedActorSystem |
| 37 | + |
| 38 | + distributed func callMeCallMe() async throws -> SuperLargeSizeStruct { |
| 39 | + return .init() |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +@available(SwiftStdlib 6.0, *) |
| 44 | +func test_generic(system: DefaultDistributedActorSystem) async throws { |
| 45 | + let localW = TheWorker(actorSystem: system) |
| 46 | + let remoteW = try! TheWorker.resolve(id: localW.id, using: system) |
| 47 | + |
| 48 | + let target = RemoteCallTarget("$s4main9TheWorkerC010callMeCallE0AA20SuperLargeSizeStructVyYaKFTE") |
| 49 | + var invocation = FakeInvocationEncoder() |
| 50 | + try invocation.recordReturnType(SuperLargeSizeStruct.self) |
| 51 | + try invocation.recordErrorType(Error.self) |
| 52 | + try invocation.doneRecording() |
| 53 | + |
| 54 | + do { |
| 55 | + try await system.remoteCall( |
| 56 | + on: localW, |
| 57 | + target: target, |
| 58 | + invocation: &invocation, |
| 59 | + throwing: Error.self, |
| 60 | + returning: SuperLargeSizeStruct.self |
| 61 | + ) |
| 62 | + // CHECK: >> remoteCall: on:main.TheWorker, target:main.TheWorker.callMeCallMe(), invocation:FakeInvocationEncoder(genericSubs: [], arguments: [], returnType: Optional(main.SuperLargeSizeStruct), errorType: Optional(Swift.Error)), throwing:Swift.Error, returning:main.SuperLargeSizeStruct |
| 63 | + // CHECK: > execute distributed target: main.TheWorker.callMeCallMe(), identifier: $s4main9TheWorkerC010callMeCallE0AA20SuperLargeSizeStructVyYaKFTE |
| 64 | + // CHECK: << remoteCall return: SuperLargeSizeStruct |
| 65 | + } |
| 66 | + print("==== ----------------------------------------------------------------") |
| 67 | +} |
| 68 | + |
| 69 | +@available(SwiftStdlib 6.0, *) |
| 70 | +@main struct Main { |
| 71 | + static func main() async { |
| 72 | + let system = DefaultDistributedActorSystem() |
| 73 | + print("===================================================================") |
| 74 | + try! await test_generic(system: system) |
| 75 | + } |
| 76 | +} |
0 commit comments