Skip to content

Commit

Permalink
Fix ProvisioningContextTest.testFollowHelpsResolve is violating API
Browse files Browse the repository at this point in the history
Currently ProvisioningContextTest.testFollowHelpsResolve() assumes it
can modify the context repositories after using the context but this is
not valid according to API.
  • Loading branch information
laeubi committed Jun 16, 2024
1 parent 60e7ccd commit 85b0b03
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.engine;singleton:=true
Bundle-Version: 2.10.200.qualifier
Bundle-Version: 2.10.300.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.engine.EngineActivator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ private Set<IMetadataRepository> getLoadedMetadataRepositories(IProgressMonitor

// Clear out the list of remembered artifact repositories
referencedArtifactRepositories = new HashMap<>();
for (URI repositorie : repositories) {
loadMetadataRepository(repoManager, repositorie, loadedRepos, shouldFollowReferences(), sub.split(1));
for (URI repository : repositories) {
loadMetadataRepository(repoManager, repository, loadedRepos, shouldFollowReferences(), sub.split(1));
}
}
return new HashSet<>(loadedRepos.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.query.ExpressionMatchQuery;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
Expand Down Expand Up @@ -199,6 +202,12 @@ public void testFollowHelpsResolve() {
context.setArtifactRepositories(new URI[0]);
IProvisioningPlan plan = getPlanner(getAgent()).getProvisioningPlan(request, context, getMonitor());
assertFalse("resolve should fail with missing requirements", plan.getStatus().isOK());
// we need to create a new context as the planner is calling
// ProvisioningContext.getMetadata(IProgressMonitor) and after that call
// repositories are fixed as per API...
context = new ProvisioningContext(getAgent());
context.setMetadataRepositories(new URI[] { repoA.getLocation() });
context.setArtifactRepositories(new URI[0]);
context.setProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES, "true");
plan = getPlanner(getAgent()).getProvisioningPlan(request, context, getMonitor());
assertTrue("resolve should pass", plan.getStatus().isOK());
Expand Down

0 comments on commit 85b0b03

Please sign in to comment.