Skip to content

Commit ebc47e1

Browse files
authored
Merge pull request #3037 from DougGregor/use-tsc-await
Use tsc_await rather than await
2 parents 1c70990 + d5325b3 commit ebc47e1

File tree

7 files changed

+73
-73
lines changed

7 files changed

+73
-73
lines changed

Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ private final class ContainerProvider {
13571357
}
13581358

13591359
// Otherwise, fetch the container synchronously.
1360-
let container = try await { provider.getContainer(for: identifier, skipUpdate: skipUpdate, completion: $0) }
1360+
let container = try tsc_await { provider.getContainer(for: identifier, skipUpdate: skipUpdate, completion: $0) }
13611361
let pubGrubContainer = PubGrubPackageContainer(container, pinsMap: pinsMap)
13621362
self._fetchedContainers[identifier] = .success(pubGrubContainer)
13631363
return pubGrubContainer

Sources/SPMPackageEditor/PackageEditor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final class PackageEditor {
7171
} else {
7272
// Otherwise, first lookup the dependency.
7373
let spec = RepositorySpecifier(url: options.url)
74-
let handle = try await{ context.repositoryManager.lookup(repository: spec, completion: $0) }
74+
let handle = try tsc_await{ context.repositoryManager.lookup(repository: spec, completion: $0) }
7575
let repo = try handle.open()
7676

7777
// Compute the requirement.

Sources/Workspace/Workspace.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ extension Workspace {
803803
// Otherwise, create a checkout at the destination from our repository store.
804804
//
805805
// Get handle to the repository.
806-
let handle = try await {
806+
let handle = try tsc_await {
807807
repositoryManager.lookup(repository: dependency.packageRef.repository, skipUpdate: true, completion: $0)
808808
}
809809
let repo = try handle.open()
@@ -1579,7 +1579,7 @@ extension Workspace {
15791579
// automatically manage the parallelism.
15801580
let pins = pinsStore.pins.map({ $0 })
15811581
DispatchQueue.concurrentPerform(iterations: pins.count) { idx in
1582-
_ = try? await {
1582+
_ = try? tsc_await {
15831583
containerProvider.getContainer(for: pins[idx].packageRef, skipUpdate: true, completion: $0)
15841584
}
15851585
}
@@ -2022,7 +2022,7 @@ extension Workspace {
20222022

20232023
case .revision(let identifier):
20242024
// Get the latest revision from the container.
2025-
let container = try await {
2025+
let container = try tsc_await {
20262026
containerProvider.getContainer(for: packageRef, skipUpdate: true, completion: $0)
20272027
} as! RepositoryPackageContainer
20282028
var revision = try container.getRevision(forIdentifier: identifier)
@@ -2249,7 +2249,7 @@ extension Workspace {
22492249
}
22502250

22512251
// If not, we need to get the repository from the checkouts.
2252-
let handle = try await {
2252+
let handle = try tsc_await {
22532253
repositoryManager.lookup(repository: package.repository, skipUpdate: true, completion: $0)
22542254
}
22552255

@@ -2320,7 +2320,7 @@ extension Workspace {
23202320
// way to get it back out of the resolver which is very
23212321
// annoying. Maybe we should make an SPI on the provider for
23222322
// this?
2323-
let container = try await { containerProvider.getContainer(for: package, skipUpdate: true, completion: $0) } as! RepositoryPackageContainer
2323+
let container = try tsc_await { containerProvider.getContainer(for: package, skipUpdate: true, completion: $0) } as! RepositoryPackageContainer
23242324
guard let tag = container.getTag(for: version) else {
23252325
throw StringError("Internal error: please file a bug at https://bugs.swift.org with this info -- unable to get tag for \(package) \(version); available versions \(container.reversedVersions)")
23262326
}

Tests/PackageCollectionsTests/PackageCollectionsProfileStorageTest.swift

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,43 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
4343
let sources = makeMockSources()
4444

4545
try sources.forEach { source in
46-
_ = try await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
46+
_ = try tsc_await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
4747
}
4848

49-
let profiles = try await { callback in storage.listProfiles(callback: callback) }
49+
let profiles = try tsc_await { callback in storage.listProfiles(callback: callback) }
5050
XCTAssertEqual(profiles.count, 1, "profiles should match")
5151

5252
do {
53-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
53+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
5454
XCTAssertEqual(list.count, sources.count, "collections should match")
5555
}
5656

5757
let remove = sources.enumerated().filter { index, _ in index % 2 == 0 }.map { $1 }
5858
try remove.forEach { source in
59-
_ = try await { callback in storage.remove(source: source, from: .default, callback: callback) }
59+
_ = try tsc_await { callback in storage.remove(source: source, from: .default, callback: callback) }
6060
}
6161

6262
do {
63-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
63+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
6464
XCTAssertEqual(list.count, sources.count - remove.count, "collections should match")
6565
}
6666

6767
let remaining = sources.filter { !remove.contains($0) }
6868
try sources.forEach { source in
69-
XCTAssertEqual(try await { callback in storage.exists(source: source, in: .default, callback: callback) }, remaining.contains(source))
70-
XCTAssertEqual(try await { callback in storage.exists(source: source, in: nil, callback: callback) }, remaining.contains(source))
69+
XCTAssertEqual(try tsc_await { callback in storage.exists(source: source, in: .default, callback: callback) }, remaining.contains(source))
70+
XCTAssertEqual(try tsc_await { callback in storage.exists(source: source, in: nil, callback: callback) }, remaining.contains(source))
7171
}
7272

7373
do {
74-
_ = try await { callback in storage.move(source: remaining.last!, to: 0, in: .default, callback: callback) }
75-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
74+
_ = try tsc_await { callback in storage.move(source: remaining.last!, to: 0, in: .default, callback: callback) }
75+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
7676
XCTAssertEqual(list.count, remaining.count, "collections should match")
7777
XCTAssertEqual(list.first, remaining.last, "item should match")
7878
}
7979

8080
do {
81-
_ = try await { callback in storage.move(source: remaining.last!, to: remaining.count - 1, in: .default, callback: callback) }
82-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
81+
_ = try tsc_await { callback in storage.move(source: remaining.last!, to: remaining.count - 1, in: .default, callback: callback) }
82+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
8383
XCTAssertEqual(list.count, remaining.count, "collections should match")
8484
XCTAssertEqual(list.last, remaining.last, "item should match")
8585
}
@@ -92,19 +92,19 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
9292
let sources = makeMockSources()
9393

9494
try sources.forEach { source in
95-
_ = try await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
95+
_ = try tsc_await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
9696
}
9797

9898
do {
99-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
99+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
100100
XCTAssertEqual(list.count, sources.count, "collections should match")
101101
}
102102

103103
try mockFileSystem.removeFileTree(storage.path)
104104
XCTAssertFalse(mockFileSystem.exists(storage.path), "expected file to be deleted")
105105

106106
do {
107-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
107+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
108108
XCTAssertEqual(list.count, 0, "collections should match")
109109
}
110110
}
@@ -116,11 +116,11 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
116116
let sources = makeMockSources()
117117

118118
try sources.forEach { source in
119-
_ = try await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
119+
_ = try tsc_await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
120120
}
121121

122122
do {
123-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
123+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
124124
XCTAssertEqual(list.count, sources.count, "collections should match")
125125
}
126126

@@ -129,7 +129,7 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
129129
XCTAssertEqual(buffer.count, 0, "expected file to be empty")
130130

131131
do {
132-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
132+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
133133
XCTAssertEqual(list.count, 0, "collections should match")
134134
}
135135
}
@@ -141,10 +141,10 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
141141
let sources = makeMockSources()
142142

143143
try sources.forEach { source in
144-
_ = try await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
144+
_ = try tsc_await { callback in storage.add(source: source, order: nil, to: .default, callback: callback) }
145145
}
146146

147-
let list = try await { callback in storage.listSources(in: .default, callback: callback) }
147+
let list = try tsc_await { callback in storage.listSources(in: .default, callback: callback) }
148148
XCTAssertEqual(list.count, sources.count, "collections should match")
149149

150150
try mockFileSystem.writeFileContents(storage.path, bytes: ByteString("{".utf8))
@@ -153,7 +153,7 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
153153
XCTAssertNotEqual(buffer.count, 0, "expected file to be written")
154154
print(buffer)
155155

156-
XCTAssertThrowsError(try await { callback in storage.listSources(in: .default, callback: callback) }, "expected an error", { error in
156+
XCTAssertThrowsError(try tsc_await { callback in storage.listSources(in: .default, callback: callback) }, "expected an error", { error in
157157
XCTAssert(error is DecodingError, "expected error to match")
158158
})
159159
}
@@ -166,30 +166,30 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
166166
let sources = makeMockSources()
167167

168168
try sources.forEach { source in
169-
_ = try await { callback in storage.add(source: source, order: nil, to: profile, callback: callback) }
169+
_ = try tsc_await { callback in storage.add(source: source, order: nil, to: profile, callback: callback) }
170170
}
171171

172-
let profiles = try await { callback in storage.listProfiles(callback: callback) }
172+
let profiles = try tsc_await { callback in storage.listProfiles(callback: callback) }
173173
XCTAssertEqual(profiles.count, 1, "profiles should match")
174174

175175
do {
176-
let list = try await { callback in storage.listSources(in: profile, callback: callback) }
176+
let list = try tsc_await { callback in storage.listSources(in: profile, callback: callback) }
177177
XCTAssertEqual(list.count, sources.count, "sources should match")
178178
}
179179

180180
let remove = sources.enumerated().filter { index, _ in index % 2 == 0 }.map { $1 }
181181
try remove.forEach { source in
182-
_ = try await { callback in storage.remove(source: source, from: profile, callback: callback) }
182+
_ = try tsc_await { callback in storage.remove(source: source, from: profile, callback: callback) }
183183
}
184184

185185
do {
186-
let list = try await { callback in storage.listSources(in: profile, callback: callback) }
186+
let list = try tsc_await { callback in storage.listSources(in: profile, callback: callback) }
187187
XCTAssertEqual(list.count, sources.count - remove.count, "sources should match")
188188
}
189189

190190
try sources.forEach { source in
191-
XCTAssertEqual(try await { callback in storage.exists(source: source, in: profile, callback: callback) }, !remove.contains(source))
192-
XCTAssertEqual(try await { callback in storage.exists(source: source, in: nil, callback: callback) }, !remove.contains(source))
191+
XCTAssertEqual(try tsc_await { callback in storage.exists(source: source, in: profile, callback: callback) }, !remove.contains(source))
192+
XCTAssertEqual(try tsc_await { callback in storage.exists(source: source, in: nil, callback: callback) }, !remove.contains(source))
193193
}
194194

195195
let buffer = try mockFileSystem.readFileContents(storage.path)
@@ -207,15 +207,15 @@ final class PackageCollectionProfileStorageTest: XCTestCase {
207207

208208
try sources.enumerated().forEach { index, source in
209209
let profile = index % 2 == 0 ? Array(profiles.keys)[0] : Array(profiles.keys)[1]
210-
_ = try await { callback in storage.add(source: source, order: nil, to: profile, callback: callback) }
210+
_ = try tsc_await { callback in storage.add(source: source, order: nil, to: profile, callback: callback) }
211211
profiles[profile]?.append(source)
212212
}
213213

214-
let list = try await { callback in storage.listProfiles(callback: callback) }
214+
let list = try tsc_await { callback in storage.listProfiles(callback: callback) }
215215
XCTAssertEqual(list.count, profiles.count, "list count should match")
216216

217217
try profiles.forEach { profile, profileCollections in
218-
let list = try await { callback in storage.listSources(in: profile, callback: callback) }
218+
let list = try tsc_await { callback in storage.listSources(in: profile, callback: callback) }
219219
XCTAssertEqual(list.count, profileCollections.count, "list count should match")
220220
}
221221

0 commit comments

Comments
 (0)