Skip to content

Commit 780ee01

Browse files
authored
Fixes warnings in SwiftTestingRunner.swift (#1565)
Fixes #1557. Before: ```sh > bazel build //tools/test_observer INFO: Analyzed target //tools/test_observer:test_observer (0 packages loaded, 0 targets configured). INFO: From Compiling Swift module //tools/test_observer:test_observer: tools/test_observer/SwiftTestingRunner.swift:83:26: warning: result of call to 'withLock' is unused 81 | switch testOrSuite { 82 | case .suite(let suiteID): 83 | discoveredSuites.withLock { $0.insert(suiteID) } | `- warning: result of call to 'withLock' is unused 84 | case .test(let test): 85 | collector.addTest(test) tools/test_observer/SwiftTestingRunner.swift:179:34: warning: trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning 177 | case .string(let testID) = payload["testID"], 178 | // Ignore suites. The xUnit recorder reconstructs the hierarchy. 179 | !discoveredSuites.withLock { $0.contains(testID) }, | `- warning: trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning 180 | case .object(let instantJSON) = payload["instant"], 181 | case .number(let absolute) = instantJSON["absolute"] INFO: Found 1 target... Target //tools/test_observer:test_observer up-to-date: bazel-bin/tools/test_observer/BazelTestObservation.swiftdoc bazel-bin/tools/test_observer/BazelTestObservation.swiftmodule bazel-bin/tools/test_observer/libtest_observer.a INFO: Elapsed time: 4.960s, Critical Path: 4.85s INFO: 3 processes: 1 internal, 1 darwin-sandbox, 1 worker. INFO: Build completed successfully, 3 total actions ``` After: ```sh > bazel build //tools/test_observer INFO: Analyzed target //tools/test_observer:test_observer (0 packages loaded, 0 targets configured). INFO: Found 1 target... Target //tools/test_observer:test_observer up-to-date: bazel-bin/tools/test_observer/BazelTestObservation.swiftdoc bazel-bin/tools/test_observer/BazelTestObservation.swiftmodule bazel-bin/tools/test_observer/libtest_observer.a INFO: Elapsed time: 0.115s, Critical Path: 0.00s INFO: 1 process: 1 internal. INFO: Build completed successfully, 1 total action ```
1 parent 3932bc7 commit 780ee01

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tools/test_observer/Locked.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public struct Locked<Value>: Sendable where Value: Sendable {
6060
///
6161
/// Upon acquiring the lock, the body is passed a mutable copy of the value, which it has
6262
/// exclusive access to for the duration of the body. Mutations will affect the underlying value.
63+
@discardableResult
6364
public nonmutating func withLock<Result>(
6465
_ body: (inout Value) throws -> Result
6566
) rethrows -> Result {

tools/test_observer/SwiftTestingRunner.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public final class SwiftTestingRunner: Sendable {
176176
case .string(let kind) = payload["kind"],
177177
case .string(let testID) = payload["testID"],
178178
// Ignore suites. The xUnit recorder reconstructs the hierarchy.
179-
!discoveredSuites.withLock { $0.contains(testID) },
179+
!discoveredSuites.withLock({ $0.contains(testID) }),
180180
case .object(let instantJSON) = payload["instant"],
181181
case .number(let absolute) = instantJSON["absolute"]
182182
else {

0 commit comments

Comments
 (0)