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