Skip to content

Commit f3b05ce

Browse files
authored
Add more build settings to test targets (#10)
Motivation: The test targets don't set the same Swift as the library targets. There's no reason for them not to. Modifications: - Apply default settings to test targets. - Workaround service-context bug Result: Test targets use Swift 6 language mode, explicit existential any, and internal imports by default
1 parent f5b87e7 commit f3b05ce

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

Package.swift

+8-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ let dependencies: [Package.Dependency] = [
3939
),
4040
.package(
4141
url: "https://github.com/grpc/grpc-swift-protobuf.git",
42-
exact: "1.0.0-alpha.1"
42+
branch: "main"
4343
),
4444
.package(
4545
url: "https://github.com/apple/swift-protobuf.git",
4646
from: "1.28.1"
4747
),
4848
.package(
4949
url: "https://github.com/apple/swift-distributed-tracing.git",
50-
from: "1.0.0"
50+
from: "1.1.2"
5151
),
5252
]
5353

@@ -73,7 +73,8 @@ let targets: [Target] = [
7373
dependencies: [
7474
.target(name: "GRPCHealthService"),
7575
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
76-
]
76+
],
77+
swiftSettings: defaultSwiftSettings
7778
),
7879

7980
// Common interceptors for gRPC.
@@ -91,7 +92,8 @@ let targets: [Target] = [
9192
.target(name: "GRPCInterceptors"),
9293
.product(name: "GRPCCore", package: "grpc-swift"),
9394
.product(name: "Tracing", package: "swift-distributed-tracing")
94-
]
95+
],
96+
swiftSettings: defaultSwiftSettings
9597
),
9698

9799
// gRPC interop test implementation.
@@ -110,7 +112,8 @@ let targets: [Target] = [
110112
.target(name: "GRPCInteropTests"),
111113
.product(name: "GRPCCore", package: "grpc-swift"),
112114
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
113-
]
115+
],
116+
swiftSettings: defaultSwiftSettings
114117
)
115118
]
116119

Sources/GRPCInterceptors/ServerTracingInterceptor.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ public struct ServerTracingInterceptor: ServerInterceptor {
5656
using: self.extractor
5757
)
5858

59-
return try await ServiceContext.withValue(serviceContext) {
59+
// FIXME: use 'ServiceContext.withValue(serviceContext)'
60+
//
61+
// This is blocked on: https://github.com/apple/swift-service-context/pull/46
62+
return try await ServiceContext.$current.withValue(serviceContext) {
6063
try await tracer.withSpan(
6164
context.descriptor.fullyQualifiedMethod,
6265
context: serviceContext,

Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ final class TracingInterceptorTests: XCTestCase {
3232
let (stream, continuation) = AsyncStream<String>.makeStream()
3333
serviceContext.traceID = traceIDString
3434

35-
try await ServiceContext.withValue(serviceContext) {
35+
// FIXME: use 'ServiceContext.withValue(serviceContext)'
36+
//
37+
// This is blocked on: https://github.com/apple/swift-service-context/pull/46
38+
try await ServiceContext.$current.withValue(serviceContext) {
3639
let methodDescriptor = MethodDescriptor(
3740
service: "TracingInterceptorTests",
3841
method: "testClientInterceptor"
@@ -101,7 +104,10 @@ final class TracingInterceptorTests: XCTestCase {
101104
let (stream, continuation) = AsyncStream<String>.makeStream()
102105
serviceContext.traceID = traceIDString
103106

104-
try await ServiceContext.withValue(serviceContext) {
107+
// FIXME: use 'ServiceContext.withValue(serviceContext)'
108+
//
109+
// This is blocked on: https://github.com/apple/swift-service-context/pull/46
110+
try await ServiceContext.$current.withValue(serviceContext) {
105111
let response = try await interceptor.intercept(
106112
request: .init(producer: { writer in
107113
try await writer.write(contentsOf: ["request1"])

0 commit comments

Comments
 (0)