Skip to content

Commit 99ad1b8

Browse files
committed
[WorkspaceTests] Minor fix in the new testing infra
Don't create a new repository if a package is mentioned again, otherwise we end up losing the previous tags.
1 parent f0f899d commit 99ad1b8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Tests/WorkspaceTests/WorkspaceTests2.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,19 +432,19 @@ private final class TestWorkspace {
432432
func create(package: TestPackage, basePath: AbsolutePath, isRoot: Bool) throws {
433433
let packagePath = basePath.appending(component: package.name)
434434
let sourcesDir = packagePath.appending(component: "Sources")
435-
435+
let url = (isRoot ? packagePath : packagesDir.appending(component: package.name)).asString
436+
let specifier = RepositorySpecifier(url: url)
437+
436438
// Create targets on disk.
437-
let repo = InMemoryGitRepository(path: packagePath, fs: fs as! InMemoryFileSystem)
439+
let repo = repoProvider.specifierMap[specifier] ?? InMemoryGitRepository(path: packagePath, fs: fs as! InMemoryFileSystem)
438440
for target in package.targets {
439441
let targetDir = sourcesDir.appending(component: target.name)
440442
try repo.createDirectory(targetDir, recursive: true)
441443
try repo.writeFileContents(targetDir.appending(component: "file.swift"), bytes: "")
442444
}
443445
repo.commit()
444446

445-
let url = (isRoot ? packagePath : packagesDir.appending(component: package.name)).asString
446447
let versions: [String?] = isRoot ? [nil] : package.versions
447-
448448
for version in versions {
449449
let v = version.flatMap(Version.init(string:))
450450
manifests[.init(url: url, version: v)] = Manifest(
@@ -463,7 +463,7 @@ private final class TestWorkspace {
463463
}
464464
}
465465

466-
repoProvider.add(specifier: RepositorySpecifier(url: url), repository: repo)
466+
repoProvider.add(specifier: specifier, repository: repo)
467467
}
468468

469469
// Create root packages.

0 commit comments

Comments
 (0)