1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
// RUN: %empty-directory(%t/src)
// RUN: split-file %s %t/src
/// Build the fake actor systems lib
// RUN: %target-build-swift \
// RUN: -target %target-swift-6.0-abi-triple \
// RUN: -parse-as-library -emit-library \
// RUN: -emit-module-path %t/FakeDistributedActorSystems.swiftmodule \
// RUN: -module-name FakeDistributedActorSystems \
// RUN: -plugin-path %swift-plugin-dir \
// RUN: %S/../Inputs/FakeDistributedActorSystems.swift \
// RUN: -enable-library-evolution \
// RUN: -Xfrontend -validate-tbd-against-ir=all \
// RUN: -o %t/%target-library-name(FakeDistributedActorSystems)
/// Build the ResilientAPILib
// RUN: %target-build-swift \
// RUN: -target %target-swift-6.0-abi-triple \
// RUN: -parse-as-library -emit-library \
// RUN: -emit-module-path %t/ResilientAPILib.swiftmodule \
// RUN: -module-name ResilientAPILib \
// RUN: -I %t \
// RUN: -L %t \
// RUN: -plugin-path %swift-plugin-dir \
// RUN: %t/src/ResilientAPILib.swift \
// RUN: -lFakeDistributedActorSystems \
// RUN: -enable-library-evolution \
// RUN: -Xfrontend -validate-tbd-against-ir=all \
// RUN: -o %t/%target-library-name(ResilientAPILib)
/// Build the ResilientImplLib
// RUN: %target-build-swift \
// RUN: -target %target-swift-6.0-abi-triple \
// RUN: -parse-as-library -emit-library \
// RUN: -emit-module-path %t/ResilientImplLib.swiftmodule \
// RUN: -module-name ResilientImplLib \
// RUN: -I %t \
// RUN: -L %t \
// RUN: -plugin-path %swift-plugin-dir \
// RUN: %t/src/ResilientImplLib.swift \
// RUN: -lFakeDistributedActorSystems \
// RUN: -lResilientAPILib \
// RUN: -enable-library-evolution \
// RUN: -Xfrontend -validate-tbd-against-ir=all \
// RUN: -o %t/%target-library-name(ResilientImplLib)
/// Build the client
// RUN: %target-build-swift \
// RUN: -target %target-swift-6.0-abi-triple \
// RUN: -parse-as-library \
// RUN: -lFakeDistributedActorSystems \
// RUN: -lResilientAPILib \
// RUN: -lResilientImplLib \
// RUN: -module-name main \
// RUN: -I %t \
// RUN: -L %t \
// RUN: -plugin-path %swift-plugin-dir \
// RUN: %s \
// RUN: -enable-library-evolution \
// RUN: -Xfrontend -validate-tbd-against-ir=all \
// RUN: -o %t/a.out
// Sign the main binary and all libraries
// RUN: %target-codesign %t/a.out
// RUN: %target-codesign %t/%target-library-name(FakeDistributedActorSystems)
// RUN: %target-codesign %t/%target-library-name(ResilientAPILib)
// RUN: %target-codesign %t/%target-library-name(ResilientImplLib)
// Run and verify output
// RUN: %env-SWIFT_DUMP_ACCESSIBLE_FUNCTIONS=true %target-run %t/a.out \
// RUN: %t/%target-library-name(FakeDistributedActorSystems) \
// RUN: %t/%target-library-name(ResilientAPILib) \
// RUN: %t/%target-library-name(ResilientImplLib) \
// RUN: 2>&1 \
// RUN: | %FileCheck %s --color --dump-input=always
// REQUIRES: executable_test
// REQUIRES: concurrency
// REQUIRES: distributed
// Locating the built libraries failed on Linux (construction of test case),
// but we primarily care about macOS in this test
// UNSUPPORTED: OS=linux-gnu
// %env does not seem to work on Windows
// UNSUPPORTED: OS=windows-msvc
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
// UNSUPPORTED: remote_run || device_run
//--- ResilientAPILib.swift
import Distributed
import FakeDistributedActorSystems
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
public struct Response: Codable {}
@Resolvable
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
public protocol ServiceProtocol: DistributedActor where ActorSystem == FakeRoundtripActorSystem {
distributed func getArray(a1: [Int], a2: String?) -> [Response]
}
//--- ResilientImplLib.swift
import ResilientAPILib
import Distributed
import FakeDistributedActorSystems
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
public distributed actor ServiceImpl: ServiceProtocol {
public typealias ActorSystem = FakeRoundtripActorSystem
public distributed func getArray(a1: [Int], a2: String?) -> [Response] {
[]
}
}
//--- Main.swift
import ResilientAPILib
import ResilientImplLib
import Distributed
import FakeDistributedActorSystems
@main
struct Main {
static func main() async throws {
if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
let system = FakeRoundtripActorSystem()
let real: any ServiceProtocol = ServiceImpl(actorSystem: system)
let proxy: any ServiceProtocol =
try $ServiceProtocol.resolve(id: real.id, using: system)
// just in order to see if we crash and trigger the accessible funcs printout
_ = try await proxy.getArray(a1: [], a2: "")
// === We expect records for accessible functions from other modules as well,
// and especially we want to see records for the `$` macro generated stubs,
// including
// CHECK: ==== Accessible Function Records ====
// CHECK: Record name: $s16ResilientImplLib07ServiceB0C8getArray2a12a2Say0A6APILib8ResponseVGSaySiG_SSSgtYaKFTE
// CHECK: Demangled: distributed thunk ResilientImplLib.ServiceImpl.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response>
// CHECK: Record name: $s15ResilientAPILib15ServiceProtocolPAA11Distributed01_E9ActorStubRzrlE8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE
// CHECK: Demangled: distributed thunk (extension in ResilientAPILib):ResilientAPILib.ServiceProtocol< where A: Distributed._DistributedActorStub>.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response>
// CHECK: Record name: $s15ResilientAPILib16$ServiceProtocolC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE
// CHECK: Demangled: distributed thunk ResilientAPILib.$ServiceProtocol.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response>
// CHECK: Record name: $s4main15ServiceProtocolPAA11Distributed01_D9ActorStubRzrlE8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE
// CHECK: Demangled: distributed thunk (extension in main):main.ServiceProtocol< where A: Distributed._DistributedActorStub>.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<main.Response>
// CHECK: Record name: $s4main11ServiceImplC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE
// CHECK: Demangled: distributed thunk main.ServiceImpl.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<main.Response>
// CHECK: Record name: $s4main16$ServiceProtocolC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE
// CHECK: Demangled: distributed thunk main.$ServiceProtocol.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<main.Response>
// We expect these to be the exact records we get, no other ones:
// CHECK: Record count: 6
// CHECK: ==== End of Accessible Function Records ====
print("DONE") // CHECK: DONE
}
}
}
|