Skip to content

Speedup test by not using StdlibUnittest #39862

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
merged 2 commits into from
Oct 22, 2021
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library -Xfrontend -disable-availability-checking) | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: concurrency
Expand All @@ -12,7 +12,6 @@

import _Distributed

@available(SwiftStdlib 5.5, *)
distributed actor LocalWorker {
init(transport: ActorTransport) {
defer { transport.actorReady(self) } // FIXME(distributed): rdar://81783599 this should be injected automatically
Expand All @@ -27,7 +26,6 @@ distributed actor LocalWorker {
}
}

@available(SwiftStdlib 5.5, *)
extension LocalWorker {
@_dynamicReplacement(for: _remote_function())
// TODO(distributed): @_remoteDynamicReplacement(for: function()) - could be a nicer spelling, hiding that we use dynamic under the covers
Expand All @@ -44,16 +42,13 @@ extension LocalWorker {

// ==== Fake Transport ---------------------------------------------------------


@available(SwiftStdlib 5.5, *)
struct ActorAddress: ActorIdentity {
let address: String
init(parse address : String) {
self.address = address
}
}

@available(SwiftStdlib 5.5, *)
struct FakeTransport: ActorTransport {
func decodeIdentity(from decoder: Decoder) throws -> AnyActorIdentity {
fatalError("not implemented:\(#function)")
Expand Down Expand Up @@ -83,7 +78,6 @@ struct FakeTransport: ActorTransport {

// ==== Execute ----------------------------------------------------------------

@available(SwiftStdlib 5.5, *)
func test_local() async throws {
let transport = FakeTransport()

Expand All @@ -95,7 +89,6 @@ func test_local() async throws {
// CHECK: call: local:
}

@available(SwiftStdlib 5.5, *)
func test_remote() async throws {
let address = ActorAddress(parse: "")
let transport = FakeTransport()
Expand All @@ -110,7 +103,6 @@ func test_remote() async throws {
// CHECK: call: _cluster_remote_echo(name:):Charlie
}

@available(SwiftStdlib 5.5, *)
@main struct Main {
static func main() async {
try! await test_local()
Expand Down
55 changes: 25 additions & 30 deletions test/Distributed/Runtime/distributed_actor_identity.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-run-simple-swift( -Xfrontend -disable-availability-checking -Xfrontend -enable-experimental-distributed -parse-as-library)
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: concurrency
Expand All @@ -8,52 +8,47 @@
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime

import StdlibUnittest
import _Distributed

@available(SwiftStdlib 5.5, *)
struct ActorAddress: ActorIdentity, CustomStringConvertible {
let id: String
var description: Swift.String {
"ActorAddress(id: \(id))"
}
}

@main struct Main {
static func main() async {
if #available(SwiftStdlib 5.5, *) {

let ActorIdentityTests = TestSuite("ActorIdentity")

ActorIdentityTests.test("equality") {
let a = ActorAddress(id: "a")
let b = ActorAddress(id: "b")
func equality() {
let a = ActorAddress(id: "a")
let b = ActorAddress(id: "b")

let anyA = AnyActorIdentity(a)
let anyB = AnyActorIdentity(b)
let anyA = AnyActorIdentity(a)
let anyB = AnyActorIdentity(b)

expectEqual(a, a)
expectEqual(anyA, anyA)
print("\(a == a)") // CHECK: true
print("\(anyA == anyA)") // CHECK: true

expectNotEqual(a, b)
expectNotEqual(anyA, anyB)
}
print("\(a != b)") // CHECK: true
print("\(anyA != anyB)") // CHECK: true
}

ActorIdentityTests.test("hash") {
let a = ActorAddress(id: "a")
let b = ActorAddress(id: "b")
func hash() {
let a = ActorAddress(id: "a")
let b = ActorAddress(id: "b")

let anyA = AnyActorIdentity(a)
let anyB = AnyActorIdentity(b)
let anyA = AnyActorIdentity(a)
let anyB = AnyActorIdentity(b)

expectEqual(a.hashValue, a.hashValue)
expectEqual(anyA.hashValue, anyA.hashValue)
print("\(a.hashValue == a.hashValue)") // CHECK: true
print("\(anyA.hashValue == anyA.hashValue)") // CHECK: true

expectNotEqual(a.hashValue, b.hashValue)
expectNotEqual(anyA.hashValue, anyB.hashValue)
}
}
print("\(a.hashValue != b.hashValue)") // CHECK: true
print("\(anyA.hashValue != anyB.hashValue)") // CHECK: true
}

await runAllTestsAsync()
@main struct Main {
static func main() {
equality()
hash()
}
}