diff --git a/Sources/SourceControl/RepositoryManager.swift b/Sources/SourceControl/RepositoryManager.swift index fca368c33c8..8d98dd9a0a4 100644 --- a/Sources/SourceControl/RepositoryManager.swift +++ b/Sources/SourceControl/RepositoryManager.swift @@ -40,6 +40,8 @@ public class RepositoryManager: Cancellable { private let concurrencySemaphore: DispatchSemaphore /// OperationQueue to park pending lookups private let lookupQueue: OperationQueue + /// Serial queue to manage order of lookup callbacks + private let lookupCallbackSerialQueue = DispatchQueue(label: "org.swift.swiftpm.repository-manager.serial-callback") /// The filesystem to operate on. private let fileSystem: FileSystem @@ -87,7 +89,7 @@ public class RepositoryManager: Cancellable { // this queue and semaphore is used to limit the amount of concurrent git operations taking place let maxConcurrentOperations = max(1, maxConcurrentOperations ?? 3*Concurrency.maxOperations/4) self.lookupQueue = OperationQueue() - self.lookupQueue.name = "org.swift.swiftpm.repository-manager" + self.lookupQueue.name = "org.swift.swiftpm.repository-manager.concurrent" self.lookupQueue.maxConcurrentOperationCount = maxConcurrentOperations self.concurrencySemaphore = DispatchSemaphore(value: maxConcurrentOperations) } @@ -148,7 +150,8 @@ public class RepositoryManager: Cancellable { if let pendingLookup = self.pendingLookups[repository] { self.pendingLookupsLock.unlock() // chain onto the pending lookup - return pendingLookup.notify(queue: .sharedConcurrent) { + // note the notification is done on a serial queue as the internal lookup assumes no concurrent access + return pendingLookup.notify(queue: self.lookupCallbackSerialQueue) { // at this point the previous lookup should be complete and we can re-lookup completion(.init(catching: { try self.lookup( diff --git a/Tests/BuildTests/BuildPlanTests.swift b/Tests/BuildTests/BuildPlanTests.swift index 45c769e9168..5f452b4d85a 100644 --- a/Tests/BuildTests/BuildPlanTests.swift +++ b/Tests/BuildTests/BuildPlanTests.swift @@ -527,10 +527,9 @@ final class BuildPlanTests: XCTestCase { } func testPackageNameFlag() throws { - try XCTSkipIfCI() // test is disabled because it isn't stable, see rdar://118239206 let isFlagSupportedInDriver = try DriverSupport.checkToolchainDriverFlags(flags: ["package-name"], toolchain: UserToolchain.default, fileSystem: localFileSystem) try fixture(name: "Miscellaneous/PackageNameFlag") { fixturePath in - let (stdout, _) = try executeSwiftBuild(fixturePath.appending("appPkg"), extraArgs: ["-vv"]) + let (stdout, _) = try executeSwiftBuild(fixturePath.appending("appPkg"), extraArgs: ["--vv"]) XCTAssertMatch(stdout, .contains("-module-name Foo")) XCTAssertMatch(stdout, .contains("-module-name Zoo")) XCTAssertMatch(stdout, .contains("-module-name Bar"))