Skip to content

Commit 808d351

Browse files
authored
Merge branch 'main' into feature/package-collections-2
2 parents 0076c14 + ebc47e1 commit 808d351

29 files changed

+341
-214
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ let package = Package(
201201
.target(
202202
/** SwiftPM test support library */
203203
name: "SPMTestSupport",
204-
dependencies: ["SwiftToolsSupport-auto", "Basics", "TSCTestSupport", "PackageGraph", "PackageLoading", "SourceControl", "Commands", "XCBuildSupport"]),
204+
dependencies: ["SwiftToolsSupport-auto", "Basics", "TSCTestSupport", "PackageGraph", "PackageLoading", "SourceControl", "Workspace", "Xcodeproj", "XCBuildSupport"]),
205205

206206
// MARK: SwiftPM tests
207207

Sources/Build/BuildOperation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
125125
if localFileSystem.exists(oldBuildPath) {
126126
try localFileSystem.removeFileTree(oldBuildPath)
127127
}
128-
try createSymlink(oldBuildPath, pointingAt: buildParameters.buildPath, relative: true)
128+
try localFileSystem.createSymbolicLink(oldBuildPath, pointingAt: buildParameters.buildPath, relative: true)
129129
}
130130

131131
/// Compute the llbuild target name using the given subset.

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/SPMTestSupport/InMemoryGitRepository.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ extension InMemoryGitRepository: FileSystem {
211211
}
212212

213213
public func changeCurrentWorkingDirectory(to path: AbsolutePath) throws {
214-
fatalError("Unsupported")
214+
throw FileSystemError.unsupported
215215
}
216216

217217
public var homeDirectory: AbsolutePath {
@@ -229,6 +229,10 @@ extension InMemoryGitRepository: FileSystem {
229229
public func createDirectory(_ path: AbsolutePath, recursive: Bool) throws {
230230
try head.fileSystem.createDirectory(path, recursive: recursive)
231231
}
232+
233+
public func createSymbolicLink(_ path: AbsolutePath, pointingAt destination: AbsolutePath, relative: Bool) throws {
234+
throw FileSystemError.unsupported
235+
}
232236

233237
public func readFileContents(_ path: AbsolutePath) throws -> ByteString {
234238
return try head.fileSystem.readFileContents(path)

Sources/SPMTestSupport/Resources.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
*/
1010

1111
import TSCBasic
12-
import Build
12+
import SPMBuildCore
1313
import Foundation
14-
import Commands
1514
import PackageLoading
1615
import Workspace
1716

Sources/SPMTestSupport/misc.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
4+
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -12,7 +12,6 @@ import class Foundation.NSDate
1212
import class Foundation.Thread
1313
import func XCTest.XCTFail
1414

15-
import Commands
1615
import PackageGraph
1716
import PackageModel
1817
import SourceControl

Sources/SourceControl/GitRepository.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@ private class GitFileSystemView: FileSystem {
772772
func createDirectory(_ path: AbsolutePath, recursive: Bool) throws {
773773
throw FileSystemError.unsupported
774774
}
775+
776+
func createSymbolicLink(_ path: AbsolutePath, pointingAt destination: AbsolutePath, relative: Bool) throws {
777+
throw FileSystemError.unsupported
778+
}
775779

776780
func writeFileContents(_ path: AbsolutePath, bytes: ByteString) throws {
777781
throw FileSystemError.unsupported

Sources/Workspace/Workspace.swift

Lines changed: 6 additions & 6 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()
@@ -841,7 +841,7 @@ extension Workspace {
841841
// FIXME: We should probably just warn in case we fail to create
842842
// this symlink, which could happen if there is some non-symlink
843843
// entry at this location.
844-
try createSymlink(symLinkPath, pointingAt: path, relative: false)
844+
try fileSystem.createSymbolicLink(symLinkPath, pointingAt: path, relative: false)
845845
}
846846
}
847847

@@ -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/BuildTests/BuildPlanTests.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,22 +2572,6 @@ final class BuildPlanTests: XCTestCase {
25722572
try testBinaryTargets(platform: "macos", arch: "arm64e", destinationTriple: arm64eTriple)
25732573
}
25742574

2575-
func testCreatingSanitizers() throws {
2576-
for sanitizer in Sanitizer.allCases {
2577-
XCTAssertEqual(sanitizer, try Sanitizer(argument: sanitizer.shortName))
2578-
}
2579-
}
2580-
2581-
func testInvalidSanitizer() throws {
2582-
do {
2583-
_ = try Sanitizer(argument: "invalid")
2584-
XCTFail("Should have failed to create Sanitizer")
2585-
} catch let error as ArgumentConversionError {
2586-
XCTAssertEqual(
2587-
error.description, "valid sanitizers: address, thread, undefined, scudo")
2588-
}
2589-
}
2590-
25912575
func testAddressSanitizer() throws {
25922576
try sanitizerTest(.address, expectedName: "address")
25932577
}

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import XCTest
1212

1313
import SPMTestSupport
1414
import TSCBasic
15+
import SPMBuildCore
1516
import Commands
1617
import Workspace
1718

@@ -51,6 +52,22 @@ final class BuildToolTests: XCTestCase {
5152
XCTAssert(try execute(["--version"]).stdout.contains("Swift Package Manager"))
5253
}
5354

55+
func testCreatingSanitizers() throws {
56+
for sanitizer in Sanitizer.allCases {
57+
XCTAssertEqual(sanitizer, try Sanitizer(argument: sanitizer.shortName))
58+
}
59+
}
60+
61+
func testInvalidSanitizer() throws {
62+
do {
63+
_ = try Sanitizer(argument: "invalid")
64+
XCTFail("Should have failed to create Sanitizer")
65+
} catch let error as ArgumentConversionError {
66+
XCTAssertEqual(
67+
error.description, "valid sanitizers: address, thread, undefined, scudo")
68+
}
69+
}
70+
5471
func testBinPathAndSymlink() throws {
5572
fixture(name: "ValidLayouts/SingleModule/ExecutableNew") { path in
5673
let fullPath = resolveSymlinks(path)

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ final class PackageToolTests: XCTestCase {
653653
}
654654

655655
// Create symlink to the dependency.
656-
try createSymlink(depSym, pointingAt: dep)
656+
try fs.createSymbolicLink(depSym, pointingAt: dep, relative: false)
657657

658658
_ = try execute(["resolve"], packagePath: root)
659659
}

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)