Skip to content

Distributed: Enabled availability checking in Distributed test #69738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions test/Distributed/Runtime/distributed_actor_assume_executor.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out

Expand All @@ -18,21 +18,25 @@ import StdlibUnittest
import Distributed
import FakeDistributedActorSystems

@available(SwiftStdlib 5.7, *)
typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem

@available(SwiftStdlib 5.9, *)
func checkAssumeLocalDistributedActor(actor: MainDistributedFriend) /* synchronous! */ -> String {
actor.assumeIsolated { dist in
print("gained access to: \(dist.isolatedProperty)")
return dist.isolatedProperty
}
}

@available(SwiftStdlib 5.9, *)
func checkAssumeMainActor(actor: MainDistributedFriend) /* synchronous! */ {
MainActor.assumeIsolated {
print("yay")
}
}

@available(SwiftStdlib 5.9, *)
@MainActor
func check(actor: MainDistributedFriend) {
_ = checkAssumeLocalDistributedActor(actor: actor)
Expand All @@ -58,6 +62,7 @@ distributed actor MainDistributedFriend {

}

@available(SwiftStdlib 5.9, *)
actor OtherMain {
nonisolated var unownedExecutor: UnownedSerialExecutor {
return MainActor.sharedUnownedExecutor
Expand All @@ -71,14 +76,14 @@ actor OtherMain {
}
}

@available(SwiftStdlib 5.7, *)
@main struct Main {
static func main() async {
let tests = TestSuite("AssumeLocalDistributedActorExecutor")

let system = FakeRoundtripActorSystem()
let distLocal = MainDistributedFriend(actorSystem: system)

if #available(SwiftStdlib 5.9, *) {
let tests = TestSuite("AssumeLocalDistributedActorExecutor")

let system = FakeRoundtripActorSystem()
let distLocal = MainDistributedFriend(actorSystem: system)

tests.test("assumeOnLocalDistributedActorExecutor: assume the main executor, inside the DistributedMainDistributedFriend local actor") {
_ = checkAssumeLocalDistributedActor(actor: distLocal)
Expand All @@ -100,9 +105,7 @@ actor OtherMain {
await OtherMain().checkAssumeLocalDistributedActor(actor: remoteRef)
}


await runAllTestsAsync()
}

await runAllTestsAsync()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out

Expand Down Expand Up @@ -76,6 +76,7 @@ distributed actor FiveSevenActor_FiveNineExecutor {
}
}

@available(SwiftStdlib 5.7, *)
@main struct Main {
static func main() async {
if #available(SwiftStdlib 5.9, *) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -module-name main -Xfrontend -enable-experimental-distributed -Xfrontend -disable-availability-checking -j2 -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -module-name main -Xfrontend -enable-experimental-distributed -j2 -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s --color

Expand All @@ -19,6 +19,7 @@
import Distributed
import FakeDistributedActorSystems

@available(SwiftStdlib 5.7, *)
typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem

@available(SwiftStdlib 5.9, *) // because conforming to the protocol... that has this field in 5.9?
Expand All @@ -38,6 +39,7 @@ distributed actor Worker {

}

@available(SwiftStdlib 5.9, *)
@main struct Main {
static func main() async {
let worker = Worker(actorSystem: DefaultDistributedActorSystem())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -module-name main -Xfrontend -enable-experimental-distributed -Xfrontend -disable-availability-checking -j2 -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-build-swift -module-name main -Xfrontend -enable-experimental-distributed -j2 -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s --color

Expand All @@ -21,6 +21,7 @@
import Distributed
import FakeDistributedActorSystems

@available(SwiftStdlib 5.7, *)
typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem

@available(SwiftStdlib 5.9, *)
Expand All @@ -43,12 +44,14 @@ distributed actor Worker {
}
}

@available(SwiftStdlib 5.7, *)
extension DefaultDistributedActorSystem.ActorID {
var executorPreference: UnownedSerialExecutor? {
MainActor.sharedUnownedExecutor
}
}

@available(SwiftStdlib 5.9, *)
@main struct Main {
static func main() async {
let worker = Worker(actorSystem: DefaultDistributedActorSystem())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-swift-frontend -module-name default_deinit -primary-file %s -emit-sil -verify -disable-availability-checking -I %t | %FileCheck %s --enable-var-scope
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-swift-frontend -module-name default_deinit -primary-file %s -emit-sil -verify -I %t | %FileCheck %s --enable-var-scope
// REQUIRES: concurrency
// REQUIRES: distributed

Expand All @@ -9,6 +9,7 @@
import Distributed
import FakeDistributedActorSystems

@available(SwiftStdlib 5.7, *)
typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem

// ==== ----------------------------------------------------------------------------------------------------------------
Expand Down