|
| 1 | +// RUN: %empty-directory(%t/src) |
| 2 | +// RUN: split-file %s %t/src |
| 3 | + |
| 4 | +/// Build the fake actor systems lib |
| 5 | +// RUN: %target-build-swift \ |
| 6 | +// RUN: -Xfrontend -disable-availability-checking \ |
| 7 | +// RUN: -parse-as-library -emit-library \ |
| 8 | +// RUN: -emit-module-path %t/FakeDistributedActorSystems.swiftmodule \ |
| 9 | +// RUN: -module-name FakeDistributedActorSystems \ |
| 10 | +// RUN: %S/../Inputs/FakeDistributedActorSystems.swift \ |
| 11 | +// RUN: -enable-library-evolution \ |
| 12 | +// RUN: -o %t/%target-library-name(FakeDistributedActorSystems) |
| 13 | + |
| 14 | +/// Build the Lib |
| 15 | +// RUN: %target-build-swift \ |
| 16 | +// RUN: -Xfrontend -disable-availability-checking \ |
| 17 | +// RUN: -parse-as-library -emit-library \ |
| 18 | +// RUN: -emit-module-path %t/ResilientLib.swiftmodule \ |
| 19 | +// RUN: -module-name ResilientLib \ |
| 20 | +// RUN: -I %t \ |
| 21 | +// RUN: -L %t \ |
| 22 | +// RUN: %t/src/ResilientLib.swift \ |
| 23 | +// RUN: -enable-library-evolution \ |
| 24 | +// RUN: -o %t/%target-library-name(ResilientLib) |
| 25 | + |
| 26 | +/// Build the ActorLib |
| 27 | +// RUN: %target-build-swift \ |
| 28 | +// RUN: -Xfrontend -disable-availability-checking \ |
| 29 | +// RUN: -parse-as-library -emit-library \ |
| 30 | +// RUN: -emit-module-path %t/ResilientActorLib.swiftmodule \ |
| 31 | +// RUN: -module-name ResilientActorLib \ |
| 32 | +// RUN: -I %t \ |
| 33 | +// RUN: -L %t \ |
| 34 | +// RUN: %t/src/ResilientActorLib.swift \ |
| 35 | +// RUN: -lFakeDistributedActorSystems \ |
| 36 | +// RUN: -lResilientLib \ |
| 37 | +// RUN: -enable-library-evolution \ |
| 38 | +// RUN: -o %t/%target-library-name(ResilientActorLib) |
| 39 | + |
| 40 | +/// Build the client |
| 41 | +// RUN: %target-build-swift \ |
| 42 | +// RUN: -Xfrontend -disable-availability-checking \ |
| 43 | +// RUN: -parse-as-library \ |
| 44 | +// RUN: -lFakeDistributedActorSystems \ |
| 45 | +// RUN: -lResilientLib \ |
| 46 | +// RUN: -lResilientActorLib \ |
| 47 | +// RUN: -module-name main \ |
| 48 | +// RUN: -I %t \ |
| 49 | +// RUN: -L %t \ |
| 50 | +// RUN: %s \ |
| 51 | +// RUN: -enable-library-evolution \ |
| 52 | +// RUN: -o %t/a.out |
| 53 | + |
| 54 | +// RUN: %target-codesign %t/a.out |
| 55 | +// RUN: %target-run %t/a.out | %FileCheck %s |
| 56 | + |
| 57 | +// REQUIRES: executable_test |
| 58 | +// REQUIRES: concurrency |
| 59 | +// REQUIRES: distributed |
| 60 | + |
| 61 | +// UNSUPPORTED: use_os_stdlib |
| 62 | +// UNSUPPORTED: back_deployment_runtime |
| 63 | + |
| 64 | +//--- ResilientLib.swift |
| 65 | + |
| 66 | +import Distributed |
| 67 | + |
| 68 | +public protocol SomeProtocol { |
| 69 | + func function() async throws -> String |
| 70 | +} |
| 71 | + |
| 72 | +//--- ResilientActorLib.swift |
| 73 | + |
| 74 | +import ResilientLib |
| 75 | + |
| 76 | +import Distributed |
| 77 | +import FakeDistributedActorSystems |
| 78 | + |
| 79 | +public distributed actor Impl: SomeProtocol { |
| 80 | + public typealias ActorSystem = FakeActorSystem |
| 81 | + |
| 82 | + public distributed func function() async throws -> String { |
| 83 | + "Success!" |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | + |
| 88 | +//--- Main.swift |
| 89 | + |
| 90 | +import ResilientLib |
| 91 | +import ResilientActorLib |
| 92 | + |
| 93 | +import Distributed |
| 94 | +import FakeDistributedActorSystems |
| 95 | + |
| 96 | +@main struct Main { |
| 97 | + static func main() async { |
| 98 | + let system = FakeActorSystem() |
| 99 | + let act: some SomeProtocol = Impl(actorSystem: system) |
| 100 | + let anyAct: any SomeProtocol = Impl(actorSystem: system) |
| 101 | + |
| 102 | + print("start") |
| 103 | + |
| 104 | + let reply = try! await act.function() |
| 105 | + print("reply = \(reply)") // CHECK: reply = Success! |
| 106 | + |
| 107 | + let anyReply = try! await anyAct.function() |
| 108 | + print("any reply = \(anyReply)") // CHECK: any reply = Success! |
| 109 | + |
| 110 | + print("done") |
| 111 | + } |
| 112 | +} |
0 commit comments