Skip to content

Commit 3e6cd06

Browse files
committed
Move off deprecated function
1 parent df13ad4 commit 3e6cd06

File tree

9 files changed

+52
-50
lines changed

9 files changed

+52
-50
lines changed

Sources/Workspace/Workspace+Delegation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ extension WorkspaceDelegate {
216216
}
217217
}
218218

219-
struct WorkspaceManifestLoaderDelegate: ManifestLoader.Delegate {
219+
struct WorkspaceManifestLoaderDelegate: ManifestLoader.Delegate, @unchecked Sendable {
220220
private weak var workspaceDelegate: Workspace.Delegate?
221221

222222
init(workspaceDelegate: Workspace.Delegate) {
@@ -279,7 +279,7 @@ struct WorkspaceManifestLoaderDelegate: ManifestLoader.Delegate {
279279
}
280280
}
281281

282-
struct WorkspaceRepositoryManagerDelegate: RepositoryManager.Delegate {
282+
struct WorkspaceRepositoryManagerDelegate: RepositoryManager.Delegate, @unchecked Sendable {
283283
private weak var workspaceDelegate: Workspace.Delegate?
284284

285285
init(workspaceDelegate: Workspace.Delegate) {
@@ -335,7 +335,7 @@ struct WorkspaceRepositoryManagerDelegate: RepositoryManager.Delegate {
335335
}
336336
}
337337

338-
struct WorkspaceRegistryDownloadsManagerDelegate: RegistryDownloadsManager.Delegate {
338+
struct WorkspaceRegistryDownloadsManagerDelegate: RegistryDownloadsManager.Delegate, @unchecked Sendable {
339339
private weak var workspaceDelegate: Workspace.Delegate?
340340

341341
init(workspaceDelegate: Workspace.Delegate) {

Sources/_InternalTestSupport/GitRepositoryExtensions.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import SourceControl
1414

1515
import class Basics.AsyncProcess
16+
import class TSCBasic.Process
1617

1718
import enum TSCUtility.Git
1819

@@ -21,7 +22,7 @@ import enum TSCUtility.Git
2122
package extension GitRepository {
2223
/// Create the repository using git init.
2324
func create() throws {
24-
try systemQuietly([Git.tool, "-C", self.path.pathString, "init"])
25+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "init")
2526
}
2627

2728
/// Returns current branch name. If HEAD is on a detached state, this returns HEAD.
@@ -38,36 +39,36 @@ package extension GitRepository {
3839

3940
/// Stage a file.
4041
func stage(file: String) throws {
41-
try systemQuietly([Git.tool, "-C", self.path.pathString, "add", file])
42+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "add", file)
4243
}
4344

4445
/// Stage multiple files.
4546
func stage(files: String...) throws {
46-
try systemQuietly([Git.tool, "-C", self.path.pathString, "add"] + files)
47+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "add", files.joined(separator: " "))
4748
}
4849

4950
/// Stage entire unstaged changes.
5051
func stageEverything() throws {
51-
try systemQuietly([Git.tool, "-C", self.path.pathString, "add", "."])
52+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "add", ".")
5253
}
5354

5455
/// Commit the staged changes. If the message is not provided a dummy message will be used for the commit.
5556
func commit(message: String? = nil) throws {
5657
// FIXME: We don't need to set these every time but we usually only commit once or twice for a test repo.
57-
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "user.email", "[email protected]"])
58-
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "user.name", "Example Example"])
59-
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "commit.gpgsign", "false"])
60-
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "tag.gpgsign", "false"])
61-
try systemQuietly([Git.tool, "-C", self.path.pathString, "commit", "-m", message ?? "Add some files."])
58+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "user.email", "[email protected]")
59+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "user.name", "Example Example")
60+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "commit.gpgsign", "false")
61+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "tag.gpgsign", "false")
62+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "commit", "-m", message ?? "Add some files.")
6263
}
6364

6465
/// Tag the git repo.
6566
func tag(name: String) throws {
66-
try systemQuietly([Git.tool, "-C", self.path.pathString, "tag", name])
67+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "tag", name)
6768
}
6869

6970
/// Push the changes to specified remote and branch.
7071
func push(remote: String, branch: String) throws {
71-
try systemQuietly([Git.tool, "-C", self.path.pathString, "push", remote, branch])
72+
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "push", remote, branch)
7273
}
7374
}

Sources/_InternalTestSupport/InMemoryGitRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ extension InMemoryGitRepository: WorkingCheckout {
396396
extension InMemoryGitRepository: @unchecked Sendable {}
397397

398398
/// This class implement provider for in memory git repository.
399-
public final class InMemoryGitRepositoryProvider: RepositoryProvider {
399+
public final class InMemoryGitRepositoryProvider: RepositoryProvider, @unchecked Sendable {
400400
/// Contains the repository added to this provider.
401401
public var specifierMap = ThreadSafeKeyValueStore<RepositorySpecifier, InMemoryGitRepository>()
402402

Sources/_InternalTestSupport/misc.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ import Testing
3232
import func XCTest.XCTFail
3333
import struct XCTest.XCTSkip
3434

35+
import class TSCBasic.Process
3536
import struct TSCBasic.ByteString
3637
import struct Basics.AsyncProcessResult
3738

3839
import enum TSCUtility.Git
3940

40-
@_exported import func TSCTestSupport.systemQuietly
4141
@_exported import enum TSCTestSupport.StringPattern
4242

4343
@available(*, deprecated, message: "Use CiEnvironment.runningInSmokeTestPipeline")
@@ -193,7 +193,6 @@ public enum TestError: Error {
193193
case platformNotSupported
194194
}
195195

196-
@available(*, deprecated, message: "Migrate test to Swift Testing and use 'fixture' instead")
197196
@discardableResult public func fixtureXCTest<T>(
198197
name: String,
199198
createGitRepo: Bool = true,
@@ -305,7 +304,7 @@ fileprivate func setup(
305304
#if os(Windows)
306305
try localFileSystem.copy(from: srcDir, to: dstDir)
307306
#else
308-
try systemQuietly("cp", "-R", "-H", srcDir.pathString, dstDir.pathString)
307+
try Process.checkNonZeroExit(args: "cp", "-R", "-H", srcDir.pathString, dstDir.pathString)
309308
#endif
310309

311310
// Ensure we get a clean test fixture.
@@ -361,17 +360,17 @@ public func initGitRepo(
361360
try localFileSystem.writeFileContents(file, bytes: "")
362361
}
363362

364-
try systemQuietly([Git.tool, "-C", dir.pathString, "init"])
365-
try systemQuietly([Git.tool, "-C", dir.pathString, "config", "user.email", "[email protected]"])
366-
try systemQuietly([Git.tool, "-C", dir.pathString, "config", "user.name", "Example Example"])
367-
try systemQuietly([Git.tool, "-C", dir.pathString, "config", "commit.gpgsign", "false"])
363+
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "init")
364+
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "config", "user.email", "[email protected]")
365+
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "config", "user.name", "Example Example")
366+
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "config", "commit.gpgsign", "false")
368367
let repo = GitRepository(path: dir)
369368
try repo.stageEverything()
370369
try repo.commit(message: "msg")
371370
for tag in tags {
372371
try repo.tag(name: tag)
373372
}
374-
try systemQuietly([Git.tool, "-C", dir.pathString, "branch", "-m", "main"])
373+
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "branch", "-m", "main")
375374
} catch {
376375
XCTFail("\(error.interpolationDescription)", file: file, line: line)
377376
}

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,11 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
538538
let enumerator = try XCTUnwrap(FileManager.default.enumerator(at: URL(fileURLWithPath: path.pathString), includingPropertiesForKeys: nil), file: file, line: line)
539539

540540
var symbolGraphURL: URL?
541-
for case let url as URL in enumerator where url.lastPathComponent == "Bar.symbols.json" {
542-
symbolGraphURL = url
543-
break
541+
while let object = enumerator.nextObject() {
542+
if let url = object as? URL, url.lastPathComponent == "Bar.symbols.json" {
543+
symbolGraphURL = url
544+
break
545+
}
544546
}
545547

546548
let symbolGraphData: Data

Tests/FunctionalTests/MiscellaneousTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ final class MiscellaneousTestCase: XCTestCase {
277277
// Create a shared library.
278278
let input = systemModule.appending(components: "Sources", "SystemModule.c")
279279
let triple = try UserToolchain.default.targetTriple
280-
let output = systemModule.appending("libSystemModule\(triple.dynamicLibraryExtension)")
281-
try systemQuietly([executableName("clang"), "-shared", input.pathString, "-o", output.pathString])
280+
let output = systemModule.appending("libSystemModule\(triple.dynamicLibraryExtension)")
281+
try await AsyncProcess.checkNonZeroExit(args: executableName("clang"), "-shared", input.pathString, "-o", output.pathString)
282282

283283
let pcFile = fixturePath.appending("libSystemModule.pc")
284284

Tests/FunctionalTests/ModuleMapTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class ModuleMapsTestCase: XCTestCase {
3030
let outdir = fixturePath.appending(components: rootpkg, ".build", triple.platformBuildPathComponent, "debug")
3131
try makeDirectories(outdir)
3232
let output = outdir.appending("libfoo\(triple.dynamicLibraryExtension)")
33-
try systemQuietly([executableName("clang"), "-shared", input.pathString, "-o", output.pathString])
33+
try await AsyncProcess.checkNonZeroExit(args: executableName("clang"), "-shared", input.pathString, "-o", output.pathString)
3434

3535
var Xld = ["-L", outdir.pathString]
3636
#if os(Linux) || os(Android)

Tests/SourceControlTests/GitRepositoryTests.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ class GitRepositoryTests: XCTestCase {
129129
/// In order to be stable, this test uses a static test git repository in
130130
/// `Inputs`, which has known commit hashes. See the `construct.sh` script
131131
/// contained within it for more information.
132-
func testRawRepository() throws {
132+
func testRawRepository() async throws {
133133
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8385: test repository has non-portable file names")
134134
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8564", skipSelfHostedCI: true)
135135

136-
try testWithTemporaryDirectory { path in
136+
try await testWithTemporaryDirectory { path in
137137
// Unarchive the static test repository.
138138
let inputArchivePath = AbsolutePath(#file).parentDirectory.appending(components: "Inputs", "TestRepo.tgz")
139139
#if os(Windows)
140-
try systemQuietly(["tar.exe", "-x", "-v", "-C", path.pathString, "-f", inputArchivePath.pathString])
140+
try await AsyncProcess.checkNonZeroExit(args: "tar.exe", "-x", "-v", "-C", path.pathString, "-f", inputArchivePath.pathString)
141141
#else
142-
try systemQuietly(["tar", "--no-same-owner", "-x", "-v", "-C", path.pathString, "-f", inputArchivePath.pathString])
142+
try await AsyncProcess.checkNonZeroExit(args: "tar", "--no-same-owner", "-x", "-v", "-C", path.pathString, "-f", inputArchivePath.pathString)
143143
#endif
144144
let testRepoPath = path.appending("TestRepo")
145145

@@ -400,7 +400,7 @@ class GitRepositoryTests: XCTestCase {
400400

401401
// Create a bare clone it somewhere because we want to later push into the repo.
402402
let testBareRepoPath = path.appending("test-repo-bare")
403-
try systemQuietly([Git.tool, "clone", "--bare", testRepoPath.pathString, testBareRepoPath.pathString])
403+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "clone", "--bare", testRepoPath.pathString, testBareRepoPath.pathString)
404404

405405
// Clone it somewhere.
406406
let testClonePath = path.appending("clone")
@@ -427,9 +427,9 @@ class GitRepositoryTests: XCTestCase {
427427
}
428428
}
429429

430-
func testSetRemote() throws {
430+
func testSetRemote() async throws {
431431
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8564", skipSelfHostedCI: true)
432-
try testWithTemporaryDirectory { path in
432+
try await testWithTemporaryDirectory { path in
433433
// Create a repo.
434434
let testRepoPath = path.appending("test-repo")
435435
try makeDirectories(testRepoPath)
@@ -440,7 +440,7 @@ class GitRepositoryTests: XCTestCase {
440440
XCTAssert(try repo.remotes().isEmpty)
441441

442442
// Add a remote via git cli.
443-
try systemQuietly([Git.tool, "-C", testRepoPath.pathString, "remote", "add", "origin", "../foo"])
443+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", testRepoPath.pathString, "remote", "add", "origin", "../foo")
444444
// Test if it was added.
445445
XCTAssertEqual(Dictionary(uniqueKeysWithValues: try repo.remotes().map { ($0.0, $0.1) }), ["origin": "../foo"])
446446
// Change remote.
@@ -486,9 +486,9 @@ class GitRepositoryTests: XCTestCase {
486486
}
487487
}
488488

489-
func testBranchOperations() throws {
489+
func testBranchOperations() async throws {
490490
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8564", skipSelfHostedCI: true)
491-
try testWithTemporaryDirectory { path in
491+
try await testWithTemporaryDirectory { path in
492492
// Create a repo.
493493
let testRepoPath = path.appending("test-repo")
494494
try makeDirectories(testRepoPath)
@@ -501,7 +501,7 @@ class GitRepositoryTests: XCTestCase {
501501
// Check a non existent revision.
502502
XCTAssertFalse(repo.exists(revision: Revision(identifier: "nonExistent")))
503503
// Checkout a new branch using command line.
504-
try systemQuietly([Git.tool, "-C", testRepoPath.pathString, "checkout", "-b", "TestBranch1"])
504+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", testRepoPath.pathString, "checkout", "-b", "TestBranch1")
505505
XCTAssertTrue(repo.exists(revision: Revision(identifier: "TestBranch1")))
506506
XCTAssertEqual(try repo.getCurrentRevision(), currentRevision)
507507

@@ -658,7 +658,7 @@ class GitRepositoryTests: XCTestCase {
658658
try bar.commit()
659659

660660
// Update the ref of bar in foo and tag as 1.0.2
661-
try systemQuietly([Git.tool, "-C", fooPath.appending("bar").pathString, "pull"])
661+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", fooPath.appending("bar").pathString, "pull")
662662
try foo.stageEverything()
663663
try foo.commit()
664664
try foo.tag(name: "1.0.2")
@@ -761,10 +761,10 @@ class GitRepositoryTests: XCTestCase {
761761

762762
// Create a `newMain` branch and remove `main`.
763763
try repo.checkout(newBranch: "newMain")
764-
try systemQuietly([Git.tool, "-C", testRepoPath.pathString, "branch", "-D", "main"])
764+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", testRepoPath.pathString, "branch", "-D", "main")
765765

766766
// Change the branch name to something non-existent.
767-
try systemQuietly([Git.tool, "-C", testRepoPath.pathString, "symbolic-ref", "HEAD", "refs/heads/_non_existent_branch_"])
767+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", testRepoPath.pathString, "symbolic-ref", "HEAD", "refs/heads/_non_existent_branch_")
768768

769769
// Clone it somewhere.
770770
let testClonePath = path.appending("clone")
@@ -790,7 +790,7 @@ class GitRepositoryTests: XCTestCase {
790790

791791
func testValidDirectoryLocalRelativeOrigin() async throws {
792792
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8564", skipSelfHostedCI: true)
793-
try testWithTemporaryDirectory { tmpDir in
793+
try await testWithTemporaryDirectory { tmpDir in
794794
// Create a repository.
795795
let packageDir = tmpDir.appending("SomePackage")
796796
try localFileSystem.createDirectory(packageDir)
@@ -813,7 +813,7 @@ class GitRepositoryTests: XCTestCase {
813813

814814
initGitRepo(packageDir)
815815
// Set the remote.
816-
try systemQuietly([Git.tool, "-C", packageDir.pathString, "remote", "add", "origin", customRemote])
816+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", packageDir.pathString, "remote", "add", "origin", customRemote)
817817
XCTAssertTrue(try repositoryManager.isValidDirectory(packageDir))
818818

819819
let customRemoteWithoutPathExtension = (customRemote as NSString).deletingPathExtension
@@ -837,7 +837,7 @@ class GitRepositoryTests: XCTestCase {
837837

838838
func testValidDirectoryLocalAbsoluteOrigin() async throws {
839839
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8564", skipSelfHostedCI: true)
840-
try testWithTemporaryDirectory { tmpDir in
840+
try await testWithTemporaryDirectory { tmpDir in
841841
// Create a repository.
842842
let packageDir = tmpDir.appending("SomePackage")
843843
try localFileSystem.createDirectory(packageDir)
@@ -860,7 +860,7 @@ class GitRepositoryTests: XCTestCase {
860860

861861
initGitRepo(packageDir)
862862
// Set the remote.
863-
try systemQuietly([Git.tool, "-C", packageDir.pathString, "remote", "add", "origin", customRemote.pathString])
863+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", packageDir.pathString, "remote", "add", "origin", customRemote.pathString)
864864
XCTAssertTrue(try repositoryManager.isValidDirectory(packageDir))
865865

866866
let customRemotePath = customRemote.pathString
@@ -888,7 +888,7 @@ class GitRepositoryTests: XCTestCase {
888888

889889
func testValidDirectoryRemoteOrigin() async throws {
890890
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8564", skipSelfHostedCI: true)
891-
try testWithTemporaryDirectory { tmpDir in
891+
try await testWithTemporaryDirectory { tmpDir in
892892
// Create a repository.
893893
let packageDir = tmpDir.appending("SomePackage")
894894
try localFileSystem.createDirectory(packageDir)
@@ -910,7 +910,7 @@ class GitRepositoryTests: XCTestCase {
910910

911911
initGitRepo(packageDir)
912912
// Set the remote.
913-
try systemQuietly([Git.tool, "-C", packageDir.pathString, "remote", "add", "origin", customRemote.absoluteString])
913+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", packageDir.pathString, "remote", "add", "origin", customRemote.absoluteString)
914914
XCTAssertTrue(try repositoryManager.isValidDirectory(packageDir))
915915

916916
XCTAssertTrue(try repositoryManager.isValidDirectory(packageDir, for: RepositorySpecifier(url: SourceControlURL(customRemote))))

Tests/WorkspaceTests/SourceControlPackageContainerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ final class SourceControlPackageContainerTests: XCTestCase {
532532
try packageRepo.tag(name: "1.0.0")
533533

534534
// Rename the `master` branch to `main`.
535-
try systemQuietly([Git.tool, "-C", packageDir.pathString, "branch", "-m", "main"])
535+
try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", packageDir.pathString, "branch", "-m", "main")
536536

537537
// Create a repository manager for it.
538538
let repoProvider = GitRepositoryProvider()

0 commit comments

Comments
 (0)