Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit test failure with bazel@head #6188

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.google.common.truth.Truth.assertThat;
import static com.google.idea.blaze.qsync.QuerySyncTestUtils.REPOSITORY_MAPPED_LABEL_CORRESPONDENCE;
import static com.google.idea.blaze.qsync.QuerySyncTestUtils.LabelIgnoringCanonicalFormat;
import static org.mockito.Mockito.when;

import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -81,10 +82,9 @@ public void getPendingExternalDeps_followJavaDeps_allBuilt() throws Exception {
blazeProject.setCurrent(context, snapshot);
DependencyTrackerImpl dt =
new DependencyTrackerImpl(blazeProject, dependencyBuilder, artifactTracker);
// This version of rules_jvm_external here has to exactly match the version in MODULE.bazel
// Otherwise, this test will fail
String guava = "@@rules_jvm_external~6.0~maven~com_google_guava_guava//jar:jar";
when(artifactTracker.getLiveCachedTargets()).thenReturn(ImmutableSet.of(Label.of(guava)));
LabelIgnoringCanonicalFormat guava = new LabelIgnoringCanonicalFormat("@com_google_guava_guava//jar:jar");
when(artifactTracker.getLiveCachedTargets()).thenReturn(ImmutableSet.of(guava));

assertThat(
dt.getPendingExternalDeps(
ImmutableSet.copyOf(TestData.JAVA_LIBRARY_EXTERNAL_DEP_QUERY.getAssumedLabels())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ public static PathPackage of(String path, String pkg) {
}
}

public static class LabelIgnoringCanonicalFormat extends Label {
public LabelIgnoringCanonicalFormat(String label) {
super(label);
}

@Override
public boolean equals(Object that) {
if (!(that instanceof Label)) {
return false;
}
return cleanLabel(this.toString()).equals(cleanLabel(that.toString()));
}
}

/**
* Creates a dummy source jar at the specified destination with a package structure defined by
* {@code pathPackages}
Expand Down
Loading