Skip to content

Commit e3721b3

Browse files
authored
Fixup redundant await, unused results, and concurrency warnings in tests (#7963)
Fixes up a few different types of warnings in the tests: - Unused variables are replaced with `_` - Continuation handlers are not passed through directly (follows on from #7961) - Removes unnecessary `await`s from functions that are now synchronous
1 parent 6408317 commit e3721b3

File tree

7 files changed

+24
-14
lines changed

7 files changed

+24
-14
lines changed

Tests/BasicsTests/AsyncProcessTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ final class AsyncProcessTests: XCTestCase {
434434

435435
group.addTask {
436436
var counter = 0
437-
for await output in stderrStream {
437+
for await _ in stderrStream {
438438
counter += 1
439439
}
440440

@@ -477,7 +477,7 @@ final class AsyncProcessTests: XCTestCase {
477477
},
478478
stderr: { stderr in
479479
var counter = 0
480-
for await output in stderr {
480+
for await _ in stderr {
481481
counter += 1
482482
}
483483

Tests/CommandsTests/TestCommandTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ final class TestCommandTests: CommandsTestCase {
139139
try await fixture(name: "Miscellaneous/EmptyTestsPkg") { fixturePath in
140140
let xUnitOutput = fixturePath.appending("result.xml")
141141
// Run tests in parallel with verbose output.
142-
let stdout = try await SwiftPM.Test.execute(["--parallel", "--verbose", "--xunit-output", xUnitOutput.pathString], packagePath: fixturePath).stdout
142+
_ = try await SwiftPM.Test.execute(["--parallel", "--verbose", "--xunit-output", xUnitOutput.pathString], packagePath: fixturePath).stdout
143143

144144
// Check the xUnit output.
145145
XCTAssertFileExists(xUnitOutput)

Tests/FunctionalTests/PluginTests.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ final class PluginTests: XCTestCase {
537537
)
538538

539539
let toolSearchDirectories = [try UserToolchain.default.swiftCompilerPath.parentDirectory]
540-
let success = try await withCheckedThrowingContinuation { plugin.invoke(
540+
let success = try await withCheckedThrowingContinuation { continuation in
541+
plugin.invoke(
541542
action: .performCommand(package: package, arguments: arguments),
542543
buildEnvironment: BuildEnvironment(platform: .macOS, configuration: .debug),
543544
scriptRunner: scriptRunner,
@@ -555,7 +556,10 @@ final class PluginTests: XCTestCase {
555556
observabilityScope: observability.topScope,
556557
callbackQueue: delegateQueue,
557558
delegate: delegate,
558-
completion: $0.resume(with:))
559+
completion: {
560+
continuation.resume(with: $0)
561+
}
562+
)
559563
}
560564
if expectFailure {
561565
XCTAssertFalse(success, "expected command to fail, but it succeeded", file: file, line: line)

Tests/PackageRegistryTests/RegistryClientTests.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -3840,14 +3840,16 @@ extension RegistryClient {
38403840
package: PackageIdentity.RegistryIdentity,
38413841
version: Version
38423842
) async throws -> PackageVersionMetadata {
3843-
return try await withCheckedThrowingContinuation {
3843+
return try await withCheckedThrowingContinuation { continuation in
38443844
self.getPackageVersionMetadata(
38453845
package: package.underlying,
38463846
version: version,
38473847
fileSystem: InMemoryFileSystem(),
38483848
observabilityScope: ObservabilitySystem.NOOP,
38493849
callbackQueue: .sharedConcurrent,
3850-
completion: $0.resume(with:)
3850+
completion: {
3851+
continuation.resume(with: $0)
3852+
}
38513853
)
38523854
}
38533855
}

Tests/SourceControlTests/RepositoryManagerTests.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -698,15 +698,17 @@ extension RepositoryManager {
698698
updateStrategy: RepositoryUpdateStrategy = .always,
699699
observabilityScope: ObservabilityScope
700700
) async throws -> RepositoryHandle {
701-
return try await withCheckedThrowingContinuation {
701+
return try await withCheckedThrowingContinuation { continuation in
702702
self.lookup(
703703
package: .init(url: SourceControlURL(repository.url)),
704704
repository: repository,
705705
updateStrategy: updateStrategy,
706706
observabilityScope: observabilityScope,
707707
delegateQueue: .sharedConcurrent,
708708
callbackQueue: .sharedConcurrent,
709-
completion: $0.resume(with:)
709+
completion: {
710+
continuation.resume(with: $0)
711+
}
710712
)
711713
}
712714
}

Tests/WorkspaceTests/InitTests.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ final class InitTests: XCTestCase {
155155
}
156156

157157
func testInitPackageLibraryWithSwiftTestingOnly() async throws {
158-
try await testWithTemporaryDirectory { tmpPath in
158+
try testWithTemporaryDirectory { tmpPath in
159159
let fs = localFileSystem
160160
let path = tmpPath.appending("Foo")
161161
let name = path.basename
@@ -192,7 +192,7 @@ final class InitTests: XCTestCase {
192192
}
193193

194194
func testInitPackageLibraryWithBothSwiftTestingAndXCTest() async throws {
195-
try await testWithTemporaryDirectory { tmpPath in
195+
try testWithTemporaryDirectory { tmpPath in
196196
let fs = localFileSystem
197197
let path = tmpPath.appending("Foo")
198198
let name = path.basename
@@ -231,7 +231,7 @@ final class InitTests: XCTestCase {
231231
func testInitPackageLibraryWithNoTests() async throws {
232232
try UserToolchain.default.skipUnlessAtLeastSwift6()
233233

234-
try await testWithTemporaryDirectory { tmpPath in
234+
try testWithTemporaryDirectory { tmpPath in
235235
let fs = localFileSystem
236236
let path = tmpPath.appending("Foo")
237237
let name = path.basename

Tests/WorkspaceTests/SourceControlPackageContainerTests.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,15 @@ extension PackageContainerProvider {
728728
for package: PackageReference,
729729
updateStrategy: ContainerUpdateStrategy = .always
730730
) async throws -> PackageContainer {
731-
try await withCheckedThrowingContinuation {
731+
try await withCheckedThrowingContinuation { continuation in
732732
self.getContainer(
733733
for: package,
734734
updateStrategy: updateStrategy,
735735
observabilityScope: ObservabilitySystem.NOOP,
736736
on: .global(),
737-
completion: $0.resume(with:)
737+
completion: {
738+
continuation.resume(with: $0)
739+
}
738740
)
739741
}
740742
}

0 commit comments

Comments
 (0)