Automated refactor of Label.parseAbsolute() to always pass a repository mapping
RELNOTES: None
PiperOrigin-RevId: 202360925
diff --git a/src/test/java/com/google/devtools/build/lib/packages/AttributeTest.java b/src/test/java/com/google/devtools/build/lib/packages/AttributeTest.java
index 2244ca5..077ee3f 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/AttributeTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/AttributeTest.java
@@ -24,6 +24,7 @@
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.analysis.config.transitions.SplitTransition;
@@ -149,7 +150,7 @@
assertDefaultValue("foo",
attr("x", STRING).value("foo").build());
- Label label = Label.parseAbsolute("//foo:bar");
+ Label label = Label.parseAbsolute("//foo:bar", ImmutableMap.of());
assertDefaultValue(null,
attr("x", LABEL).legacyAllowAnyFileType().build());
assertDefaultValue(label,
@@ -161,8 +162,10 @@
assertDefaultValue(slist,
attr("x", STRING_LIST).value(slist).build());
- List<Label> llist = Arrays.asList(Label.parseAbsolute("//foo:bar"),
- Label.parseAbsolute("//foo:wiz"));
+ List<Label> llist =
+ Arrays.asList(
+ Label.parseAbsolute("//foo:bar", ImmutableMap.of()),
+ Label.parseAbsolute("//foo:wiz", ImmutableMap.of()));
assertDefaultValue(Collections.emptyList(),
attr("x", LABEL_LIST).legacyAllowAnyFileType().build());
assertDefaultValue(llist,
@@ -184,7 +187,7 @@
assertType(STRING,
attr("x", STRING).value("foo").build());
- Label label = Label.parseAbsolute("//foo:bar");
+ Label label = Label.parseAbsolute("//foo:bar", ImmutableMap.of());
assertType(LABEL,
attr("x", LABEL).legacyAllowAnyFileType().build());
assertType(LABEL,
@@ -196,8 +199,10 @@
assertType(STRING_LIST,
attr("x", STRING_LIST).value(slist).build());
- List<Label> llist = Arrays.asList(Label.parseAbsolute("//foo:bar"),
- Label.parseAbsolute("//foo:wiz"));
+ List<Label> llist =
+ Arrays.asList(
+ Label.parseAbsolute("//foo:bar", ImmutableMap.of()),
+ Label.parseAbsolute("//foo:wiz", ImmutableMap.of()));
assertType(LABEL_LIST,
attr("x", LABEL_LIST).legacyAllowAnyFileType().build());
assertType(LABEL_LIST,
diff --git a/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java b/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java
index eccc5a5..317b43b 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java
@@ -53,7 +53,7 @@
@Before
public final void setCurrentRule() throws Exception {
- this.currentRule = Label.parseAbsolute("//quux:baz");
+ this.currentRule = Label.parseAbsolute("//quux:baz", ImmutableMap.of());
this.labelConversionContext =
new LabelConversionContext(currentRule, /* repositoryMapping= */ ImmutableMap.of());
}
@@ -76,22 +76,34 @@
@Test
public void testLabelKeyedStringDictConvertsToMapFromLabelToString() throws Exception {
- Map<Object, String> input = new ImmutableMap.Builder<Object, String>()
- .put("//absolute:label", "absolute value")
- .put(":relative", "theory of relativity")
- .put("nocolon", "colonial times")
- .put("//current/package:explicit", "explicit content")
- .put(Label.parseAbsolute("//i/was/already/a/label"), "and that's okay")
- .build();
- Label context = Label.parseAbsolute("//current/package:this");
+ Map<Object, String> input =
+ new ImmutableMap.Builder<Object, String>()
+ .put("//absolute:label", "absolute value")
+ .put(":relative", "theory of relativity")
+ .put("nocolon", "colonial times")
+ .put("//current/package:explicit", "explicit content")
+ .put(
+ Label.parseAbsolute("//i/was/already/a/label", ImmutableMap.of()),
+ "and that's okay")
+ .build();
+ Label context = Label.parseAbsolute("//current/package:this", ImmutableMap.of());
- Map<Label, String> expected = new ImmutableMap.Builder<Label, String>()
- .put(Label.parseAbsolute("//absolute:label"), "absolute value")
- .put(Label.parseAbsolute("//current/package:relative"), "theory of relativity")
- .put(Label.parseAbsolute("//current/package:nocolon"), "colonial times")
- .put(Label.parseAbsolute("//current/package:explicit"), "explicit content")
- .put(Label.parseAbsolute("//i/was/already/a/label"), "and that's okay")
- .build();
+ Map<Label, String> expected =
+ new ImmutableMap.Builder<Label, String>()
+ .put(Label.parseAbsolute("//absolute:label", ImmutableMap.of()), "absolute value")
+ .put(
+ Label.parseAbsolute("//current/package:relative", ImmutableMap.of()),
+ "theory of relativity")
+ .put(
+ Label.parseAbsolute("//current/package:nocolon", ImmutableMap.of()),
+ "colonial times")
+ .put(
+ Label.parseAbsolute("//current/package:explicit", ImmutableMap.of()),
+ "explicit content")
+ .put(
+ Label.parseAbsolute("//i/was/already/a/label", ImmutableMap.of()),
+ "and that's okay")
+ .build();
assertThat(BuildType.LABEL_KEYED_STRING_DICT.convert(input, null, context))
.containsExactlyEntriesIn(expected);
@@ -166,7 +178,7 @@
@Test
public void testLabelKeyedStringDictConvertingMapWithMultipleEquivalentKeysShouldFail()
throws Exception {
- Label context = Label.parseAbsolute("//current/package:this");
+ Label context = Label.parseAbsolute("//current/package:this", ImmutableMap.of());
Map<String, String> input = new ImmutableMap.Builder<String, String>()
.put(":reference", "value1")
.put("//current/package:reference", "value2")
@@ -185,7 +197,7 @@
@Test
public void testLabelKeyedStringDictConvertingMapWithMultipleSetsOfEquivalentKeysShouldFail()
throws Exception {
- Label context = Label.parseAbsolute("//current/rule:sibling");
+ Label context = Label.parseAbsolute("//current/rule:sibling", ImmutableMap.of());
Map<String, String> input = new ImmutableMap.Builder<String, String>()
.put(":rule", "first set")
.put("//current/rule:rule", "also first set")
@@ -211,7 +223,7 @@
@Test
public void testLabelKeyedStringDictErrorConvertingMapWithMultipleEquivalentKeysIncludesContext()
throws Exception {
- Label context = Label.parseAbsolute("//current/package:this");
+ Label context = Label.parseAbsolute("//current/package:this", ImmutableMap.of());
Map<String, String> input = new ImmutableMap.Builder<String, String>()
.put(":reference", "value1")
.put("//current/package:reference", "value2")
@@ -229,21 +241,30 @@
@Test
public void testLabelKeyedStringDictCollectLabels() throws Exception {
- Map<Label, String> input = new ImmutableMap.Builder<Label, String>()
- .put(Label.parseAbsolute("//absolute:label"), "absolute value")
- .put(Label.parseAbsolute("//current/package:relative"), "theory of relativity")
- .put(Label.parseAbsolute("//current/package:nocolon"), "colonial times")
- .put(Label.parseAbsolute("//current/package:explicit"), "explicit content")
- .put(Label.parseAbsolute("//i/was/already/a/label"), "and that's okay")
- .build();
+ Map<Label, String> input =
+ new ImmutableMap.Builder<Label, String>()
+ .put(Label.parseAbsolute("//absolute:label", ImmutableMap.of()), "absolute value")
+ .put(
+ Label.parseAbsolute("//current/package:relative", ImmutableMap.of()),
+ "theory of relativity")
+ .put(
+ Label.parseAbsolute("//current/package:nocolon", ImmutableMap.of()),
+ "colonial times")
+ .put(
+ Label.parseAbsolute("//current/package:explicit", ImmutableMap.of()),
+ "explicit content")
+ .put(
+ Label.parseAbsolute("//i/was/already/a/label", ImmutableMap.of()),
+ "and that's okay")
+ .build();
ImmutableList<Label> expected =
ImmutableList.of(
- Label.parseAbsolute("//absolute:label"),
- Label.parseAbsolute("//current/package:relative"),
- Label.parseAbsolute("//current/package:nocolon"),
- Label.parseAbsolute("//current/package:explicit"),
- Label.parseAbsolute("//i/was/already/a/label"));
+ Label.parseAbsolute("//absolute:label", ImmutableMap.of()),
+ Label.parseAbsolute("//current/package:relative", ImmutableMap.of()),
+ Label.parseAbsolute("//current/package:nocolon", ImmutableMap.of()),
+ Label.parseAbsolute("//current/package:explicit", ImmutableMap.of()),
+ Label.parseAbsolute("//i/was/already/a/label", ImmutableMap.of()));
assertThat(collectLabels(BuildType.LABEL_KEYED_STRING_DICT, input))
.containsExactlyElementsIn(expected);
@@ -298,7 +319,9 @@
ImmutableMap.of(
RepositoryName.create("@orig_repo"), RepositoryName.create("@new_repo")));
Label label = BuildType.LABEL.convert("@orig_repo//foo:bar", null, context);
- assertThat(label).isEquivalentAccordingToCompareTo(Label.parseAbsolute("@new_repo//foo:bar"));
+ assertThat(label)
+ .isEquivalentAccordingToCompareTo(
+ Label.parseAbsolute("@new_repo//foo:bar", ImmutableMap.of()));
}
/**
@@ -313,10 +336,12 @@
Selector<Label> selector = new Selector<>(input, null, labelConversionContext, BuildType.LABEL);
assertThat(selector.getOriginalType()).isEqualTo(BuildType.LABEL);
- Map<Label, Label> expectedMap = ImmutableMap.of(
- Label.parseAbsolute("//conditions:a"), Label.create("@//a", "a"),
- Label.parseAbsolute("//conditions:b"), Label.create("@//b", "b"),
- Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY), Label.create("@//d", "d"));
+ Map<Label, Label> expectedMap =
+ ImmutableMap.of(
+ Label.parseAbsolute("//conditions:a", ImmutableMap.of()), Label.create("@//a", "a"),
+ Label.parseAbsolute("//conditions:b", ImmutableMap.of()), Label.create("@//b", "b"),
+ Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY, ImmutableMap.of()),
+ Label.create("@//d", "d"));
assertThat(selector.getEntries().entrySet()).containsExactlyElementsIn(expectedMap.entrySet());
}
@@ -382,23 +407,27 @@
assertThat(selectorList.getOriginalType()).isEqualTo(BuildType.LABEL_LIST);
assertThat(selectorList.getKeyLabels())
.containsExactly(
- Label.parseAbsolute("//conditions:a"),
- Label.parseAbsolute("//conditions:b"),
- Label.parseAbsolute("//conditions:c"),
- Label.parseAbsolute("//conditions:d"));
+ Label.parseAbsolute("//conditions:a", ImmutableMap.of()),
+ Label.parseAbsolute("//conditions:b", ImmutableMap.of()),
+ Label.parseAbsolute("//conditions:c", ImmutableMap.of()),
+ Label.parseAbsolute("//conditions:d", ImmutableMap.of()));
List<Selector<List<Label>>> selectors = selectorList.getSelectors();
assertThat(selectors.get(0).getEntries().entrySet())
.containsExactlyElementsIn(
- ImmutableMap.of(Label.parseAbsolute("//conditions:a"),
- ImmutableList.of(Label.create("@//a", "a")), Label.parseAbsolute("//conditions:b"),
- ImmutableList.of(Label.create("@//b", "b")))
+ ImmutableMap.of(
+ Label.parseAbsolute("//conditions:a", ImmutableMap.of()),
+ ImmutableList.of(Label.create("@//a", "a")),
+ Label.parseAbsolute("//conditions:b", ImmutableMap.of()),
+ ImmutableList.of(Label.create("@//b", "b")))
.entrySet());
assertThat(selectors.get(1).getEntries().entrySet())
.containsExactlyElementsIn(
ImmutableMap.of(
- Label.parseAbsolute("//conditions:c"), ImmutableList.of(Label.create("@//c", "c")),
- Label.parseAbsolute("//conditions:d"), ImmutableList.of(Label.create("@//d", "d")))
+ Label.parseAbsolute("//conditions:c", ImmutableMap.of()),
+ ImmutableList.of(Label.create("@//c", "c")),
+ Label.parseAbsolute("//conditions:d", ImmutableMap.of()),
+ ImmutableList.of(Label.create("@//d", "d")))
.entrySet());
}
@@ -495,9 +524,10 @@
assertThat(((Selector<Label>) selectorList.getSelectors().get(0)).getEntries().entrySet())
.containsExactlyElementsIn(
ImmutableMap.of(
- Label.parseAbsolute("//conditions:a"),
+ Label.parseAbsolute("//conditions:a", ImmutableMap.of()),
expectedLabels,
- Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY),
+ Label.parseAbsolute(
+ BuildType.Selector.DEFAULT_CONDITION_KEY, ImmutableMap.of()),
expectedLabels)
.entrySet());
}
@@ -523,10 +553,13 @@
*/
@Test
public void testReservedKeyLabels() throws Exception {
- assertThat(BuildType.Selector.isReservedLabel(Label.parseAbsolute("//condition:a"))).isFalse();
assertThat(
BuildType.Selector.isReservedLabel(
- Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY)))
+ Label.parseAbsolute("//condition:a", ImmutableMap.of())))
+ .isFalse();
+ assertThat(
+ BuildType.Selector.isReservedLabel(
+ Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY, ImmutableMap.of())))
.isTrue();
}
@@ -565,7 +598,7 @@
private static FilesetEntry makeFilesetEntry() {
try {
return new FilesetEntry(
- /* srcLabel */ Label.parseAbsolute("//foo:bar"),
+ /* srcLabel */ Label.parseAbsolute("//foo:bar", ImmutableMap.of()),
/* files */ ImmutableList.<Label>of(),
/* excludes */ ImmutableSet.of("xyz"),
/* destDir */ null,
@@ -595,7 +628,7 @@
private FilesetEntry createTestFilesetEntry(
FilesetEntry.SymlinkBehavior symlinkBehavior)
throws LabelSyntaxException {
- Label label = Label.parseAbsolute("//x");
+ Label label = Label.parseAbsolute("//x", ImmutableMap.of());
return new FilesetEntry(
/* srcLabel */ label,
/* files */ Arrays.asList(label),
@@ -632,7 +665,7 @@
}
private FilesetEntry createStripPrefixFilesetEntry(String stripPrefix) throws Exception {
- Label label = Label.parseAbsolute("//x");
+ Label label = Label.parseAbsolute("//x", ImmutableMap.of());
return new FilesetEntry(
/* srcLabel */ label,
/* files */ Arrays.asList(label),
@@ -657,23 +690,25 @@
@Test
public void testPrintFilesetEntry() throws Exception {
assertThat(
- Printer.repr(
- new FilesetEntry(
- /* srcLabel */ Label.parseAbsolute("//foo:BUILD"),
- /* files */ ImmutableList.of(Label.parseAbsolute("//foo:bar")),
- /* excludes */ ImmutableSet.of("baz"),
- /* destDir */ "qux",
- /* symlinkBehavior */ FilesetEntry.SymlinkBehavior.DEREFERENCE,
- /* stripPrefix */ "blah")))
+ Printer.repr(
+ new FilesetEntry(
+ /* srcLabel */ Label.parseAbsolute("//foo:BUILD", ImmutableMap.of()),
+ /* files */ ImmutableList.of(
+ Label.parseAbsolute("//foo:bar", ImmutableMap.of())),
+ /* excludes */ ImmutableSet.of("baz"),
+ /* destDir */ "qux",
+ /* symlinkBehavior */ FilesetEntry.SymlinkBehavior.DEREFERENCE,
+ /* stripPrefix */ "blah")))
.isEqualTo(
- Joiner.on(" ").join(
- ImmutableList.of(
- "FilesetEntry(srcdir = \"//foo:BUILD\",",
- "files = [\"//foo:bar\"],",
- "excludes = [\"baz\"],",
- "destdir = \"qux\",",
- "strip_prefix = \"blah\",",
- "symlinks = \"dereference\")")));
+ Joiner.on(" ")
+ .join(
+ ImmutableList.of(
+ "FilesetEntry(srcdir = \"//foo:BUILD\",",
+ "files = [\"//foo:bar\"],",
+ "excludes = [\"baz\"],",
+ "destdir = \"qux\",",
+ "strip_prefix = \"blah\",",
+ "symlinks = \"dereference\")")));
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/packages/EnvironmentGroupTest.java b/src/test/java/com/google/devtools/build/lib/packages/EnvironmentGroupTest.java
index 7a839a1..b2e4aec 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/EnvironmentGroupTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/EnvironmentGroupTest.java
@@ -15,6 +15,7 @@
import static com.google.common.truth.Truth.assertThat;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
@@ -61,33 +62,42 @@
assertThat(group.getEnvironments())
.isEqualTo(
ImmutableSet.of(
- Label.parseAbsolute("//pkg:foo"),
- Label.parseAbsolute("//pkg:bar"),
- Label.parseAbsolute("//pkg:baz")));
+ Label.parseAbsolute("//pkg:foo", ImmutableMap.of()),
+ Label.parseAbsolute("//pkg:bar", ImmutableMap.of()),
+ Label.parseAbsolute("//pkg:baz", ImmutableMap.of())));
}
@Test
public void defaultsMembership() throws Exception {
- assertThat(group.getDefaults()).isEqualTo(ImmutableSet.of(Label.parseAbsolute("//pkg:foo")));
+ assertThat(group.getDefaults())
+ .isEqualTo(ImmutableSet.of(Label.parseAbsolute("//pkg:foo", ImmutableMap.of())));
}
@Test
public void isDefault() throws Exception {
EnvironmentLabels unpackedGroup = group.getEnvironmentLabels();
- assertThat(unpackedGroup.isDefault(Label.parseAbsolute("//pkg:foo"))).isTrue();
- assertThat(unpackedGroup.isDefault(Label.parseAbsolute("//pkg:bar"))).isFalse();
- assertThat(unpackedGroup.isDefault(Label.parseAbsolute("//pkg:baz"))).isFalse();
- assertThat(unpackedGroup.isDefault(Label.parseAbsolute("//pkg:not_in_group"))).isFalse();
+ assertThat(unpackedGroup.isDefault(Label.parseAbsolute("//pkg:foo", ImmutableMap.of())))
+ .isTrue();
+ assertThat(unpackedGroup.isDefault(Label.parseAbsolute("//pkg:bar", ImmutableMap.of())))
+ .isFalse();
+ assertThat(unpackedGroup.isDefault(Label.parseAbsolute("//pkg:baz", ImmutableMap.of())))
+ .isFalse();
+ assertThat(
+ unpackedGroup.isDefault(Label.parseAbsolute("//pkg:not_in_group", ImmutableMap.of())))
+ .isFalse();
}
@Test
public void fulfillers() throws Exception {
EnvironmentLabels unpackedGroup = group.getEnvironmentLabels();
- assertThat(unpackedGroup.getFulfillers(Label.parseAbsolute("//pkg:baz")))
- .containsExactly(Label.parseAbsolute("//pkg:foo"), Label.parseAbsolute("//pkg:bar"));
- assertThat(unpackedGroup.getFulfillers(Label.parseAbsolute("//pkg:bar")))
- .containsExactly(Label.parseAbsolute("//pkg:foo"));
- assertThat(unpackedGroup.getFulfillers(Label.parseAbsolute("//pkg:foo"))).isEmpty();
+ assertThat(unpackedGroup.getFulfillers(Label.parseAbsolute("//pkg:baz", ImmutableMap.of())))
+ .containsExactly(
+ Label.parseAbsolute("//pkg:foo", ImmutableMap.of()),
+ Label.parseAbsolute("//pkg:bar", ImmutableMap.of()));
+ assertThat(unpackedGroup.getFulfillers(Label.parseAbsolute("//pkg:bar", ImmutableMap.of())))
+ .containsExactly(Label.parseAbsolute("//pkg:foo", ImmutableMap.of()));
+ assertThat(unpackedGroup.getFulfillers(Label.parseAbsolute("//pkg:foo", ImmutableMap.of())))
+ .isEmpty();
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/packages/ExternalPackageTest.java b/src/test/java/com/google/devtools/build/lib/packages/ExternalPackageTest.java
index 2dba95f..eb416f5 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/ExternalPackageTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/ExternalPackageTest.java
@@ -15,6 +15,7 @@
import static com.google.common.truth.Truth.assertThat;
+import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData;
@@ -105,6 +106,6 @@
ConfiguredAttributeMapper configuredAttributeMapper =
getMapperFromConfiguredTargetAndTarget(ctad);
assertThat(configuredAttributeMapper.get("runtime_deps", BuildType.LABEL_LIST))
- .containsExactly(Label.parseAbsolute("//:b"));
+ .containsExactly(Label.parseAbsolute("//:b", ImmutableMap.of()));
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
index 5010375..a5c3557 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.eventbus.EventBus;
@@ -581,7 +582,9 @@
assertThat(attributes(pkg.getRule("t1")).get("$implicit_tests", BuildType.LABEL_LIST))
.containsExactlyElementsIn(
- Sets.newHashSet(Label.parseAbsolute("//x:c"), Label.parseAbsolute("//x:j")));
+ Sets.newHashSet(
+ Label.parseAbsolute("//x:c", ImmutableMap.of()),
+ Label.parseAbsolute("//x:j", ImmutableMap.of())));
assertThat(attributes(pkg.getRule("t2")).get("$implicit_tests", BuildType.LABEL_LIST))
.isEmpty();
assertThat(attributes(pkg.getRule("t3")).get("$implicit_tests", BuildType.LABEL_LIST))
@@ -604,14 +607,16 @@
List<Label> yesFiles = attributes(pkg.getRule("yes")).get("srcs", BuildType.LABEL_LIST);
List<Label> noFiles = attributes(pkg.getRule("no")).get("srcs", BuildType.LABEL_LIST);
- assertThat(yesFiles).containsExactly(
- Label.parseAbsolute("@//fruit:data/apple"),
- Label.parseAbsolute("@//fruit:data/pear"));
+ assertThat(yesFiles)
+ .containsExactly(
+ Label.parseAbsolute("@//fruit:data/apple", ImmutableMap.of()),
+ Label.parseAbsolute("@//fruit:data/pear", ImmutableMap.of()));
- assertThat(noFiles).containsExactly(
- Label.parseAbsolute("@//fruit:data/apple"),
- Label.parseAbsolute("@//fruit:data/pear"),
- Label.parseAbsolute("@//fruit:data/berry"));
+ assertThat(noFiles)
+ .containsExactly(
+ Label.parseAbsolute("@//fruit:data/apple", ImmutableMap.of()),
+ Label.parseAbsolute("@//fruit:data/pear", ImmutableMap.of()),
+ Label.parseAbsolute("@//fruit:data/berry", ImmutableMap.of()));
}
// TODO(bazel-team): This is really a test for GlobCache.
@@ -1032,7 +1037,7 @@
assertThat(pkg.containsErrors()).isFalse();
assertThat(pkg.getRule("e")).isNotNull();
List globList = (List) pkg.getRule("e").getAttributeContainer().getAttr("data");
- assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt"));
+ assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt", ImmutableMap.of()));
}
@Test
@@ -1213,8 +1218,10 @@
" default_compatible_with=['//foo'],",
" default_restricted_to=['//bar'],",
")");
- assertThat(pkg.getDefaultCompatibleWith()).containsExactly(Label.parseAbsolute("//foo"));
- assertThat(pkg.getDefaultRestrictedTo()).containsExactly(Label.parseAbsolute("//bar"));
+ assertThat(pkg.getDefaultCompatibleWith())
+ .containsExactly(Label.parseAbsolute("//foo", ImmutableMap.of()));
+ assertThat(pkg.getDefaultRestrictedTo())
+ .containsExactly(Label.parseAbsolute("//bar", ImmutableMap.of()));
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java b/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java
index 45d332c..384d2f3 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java
@@ -119,7 +119,7 @@
attr("my-label-attr", LABEL)
.mandatory()
.legacyAllowAnyFileType()
- .value(Label.parseAbsolute("//default:label"))
+ .value(Label.parseAbsolute("//default:label", ImmutableMap.of()))
.build(),
attr("my-labellist-attr", LABEL_LIST).mandatory().legacyAllowAnyFileType().build(),
attr("my-integer-attr", INTEGER).value(42).build(),
@@ -188,7 +188,7 @@
// default based on type
assertThat(ruleClassA.getAttribute(0).getDefaultValue(null)).isEqualTo("");
assertThat(ruleClassA.getAttribute(1).getDefaultValue(null))
- .isEqualTo(Label.parseAbsolute("//default:label"));
+ .isEqualTo(Label.parseAbsolute("//default:label", ImmutableMap.of()));
assertThat(ruleClassA.getAttribute(2).getDefaultValue(null)).isEqualTo(Collections.emptyList());
assertThat(ruleClassA.getAttribute(3).getDefaultValue(null)).isEqualTo(42);
// default explicitly specified
@@ -1039,13 +1039,15 @@
.add(attr("tags", STRING_LIST));
ruleClassBuilder.addRequiredToolchains(
- Label.parseAbsolute("//toolchain:tc1"), Label.parseAbsolute("//toolchain:tc2"));
+ Label.parseAbsolute("//toolchain:tc1", ImmutableMap.of()),
+ Label.parseAbsolute("//toolchain:tc2", ImmutableMap.of()));
RuleClass ruleClass = ruleClassBuilder.build();
assertThat(ruleClass.getRequiredToolchains())
.containsExactly(
- Label.parseAbsolute("//toolchain:tc1"), Label.parseAbsolute("//toolchain:tc2"));
+ Label.parseAbsolute("//toolchain:tc1", ImmutableMap.of()),
+ Label.parseAbsolute("//toolchain:tc2", ImmutableMap.of()));
}
@Test
@@ -1057,13 +1059,15 @@
.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_RULE);
ruleClassBuilder.addExecutionPlatformConstraints(
- Label.parseAbsolute("//constraints:cv1"), Label.parseAbsolute("//constraints:cv2"));
+ Label.parseAbsolute("//constraints:cv1", ImmutableMap.of()),
+ Label.parseAbsolute("//constraints:cv2", ImmutableMap.of()));
RuleClass ruleClass = ruleClassBuilder.build();
assertThat(ruleClass.getExecutionPlatformConstraints())
.containsExactly(
- Label.parseAbsolute("//constraints:cv1"), Label.parseAbsolute("//constraints:cv2"));
+ Label.parseAbsolute("//constraints:cv1", ImmutableMap.of()),
+ Label.parseAbsolute("//constraints:cv2", ImmutableMap.of()));
assertThat(ruleClass.hasAttr("exec_compatible_with", LABEL_LIST)).isFalse();
}
@@ -1091,7 +1095,8 @@
.add(attr("tags", STRING_LIST))
.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_RULE)
.addExecutionPlatformConstraints(
- Label.parseAbsolute("//constraints:cv1"), Label.parseAbsolute("//constraints:cv2"))
+ Label.parseAbsolute("//constraints:cv1", ImmutableMap.of()),
+ Label.parseAbsolute("//constraints:cv2", ImmutableMap.of()))
.build();
RuleClass childRuleClass =
@@ -1101,7 +1106,8 @@
assertThat(childRuleClass.getExecutionPlatformConstraints())
.containsExactly(
- Label.parseAbsolute("//constraints:cv1"), Label.parseAbsolute("//constraints:cv2"));
+ Label.parseAbsolute("//constraints:cv1", ImmutableMap.of()),
+ Label.parseAbsolute("//constraints:cv2", ImmutableMap.of()));
assertThat(childRuleClass.hasAttr("exec_compatible_with", LABEL_LIST)).isFalse();
}
@@ -1117,13 +1123,15 @@
.factory(DUMMY_CONFIGURED_TARGET_FACTORY)
.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_RULE)
.addExecutionPlatformConstraints(
- Label.parseAbsolute("//constraints:cv1"), Label.parseAbsolute("//constraints:cv2"));
+ Label.parseAbsolute("//constraints:cv1", ImmutableMap.of()),
+ Label.parseAbsolute("//constraints:cv2", ImmutableMap.of()));
RuleClass childRuleClass = childRuleClassBuilder.build();
assertThat(childRuleClass.getExecutionPlatformConstraints())
.containsExactly(
- Label.parseAbsolute("//constraints:cv1"), Label.parseAbsolute("//constraints:cv2"));
+ Label.parseAbsolute("//constraints:cv1", ImmutableMap.of()),
+ Label.parseAbsolute("//constraints:cv2", ImmutableMap.of()));
assertThat(childRuleClass.hasAttr("exec_compatible_with", LABEL_LIST)).isFalse();
}
diff --git a/src/test/java/com/google/devtools/build/lib/packages/RuleFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/RuleFactoryTest.java
index 3c78b8e..c806d0f 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/RuleFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/RuleFactoryTest.java
@@ -17,6 +17,7 @@
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.fail;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.eventbus.EventBus;
@@ -76,7 +77,7 @@
assertThat(pkg.getTarget("foo")).isSameAs(rule);
- assertThat(rule.getLabel()).isEqualTo(Label.parseAbsolute("//mypkg:foo"));
+ assertThat(rule.getLabel()).isEqualTo(Label.parseAbsolute("//mypkg:foo", ImmutableMap.of()));
assertThat(rule.getName()).isEqualTo("foo");
assertThat(rule.getRuleClass()).isEqualTo("cc_library");
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkProviderTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkProviderTest.java
index a4cb31a..0c81e9b 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkProviderTest.java
@@ -48,7 +48,8 @@
@Test
public void exportedProvider_Accessors() throws Exception {
- SkylarkKey key = new SkylarkKey(Label.parseAbsolute("//foo:bar.bzl"), "prov");
+ SkylarkKey key =
+ new SkylarkKey(Label.parseAbsolute("//foo:bar.bzl", ImmutableMap.of()), "prov");
SkylarkProvider provider = SkylarkProvider.createExportedSchemaless(key, /*location=*/ null);
assertThat(provider.isExported()).isTrue();
assertThat(provider.getName()).isEqualTo("prov");
@@ -93,10 +94,14 @@
@Test
public void providerEquals() throws Exception {
// All permutations of differing label and differing name.
- SkylarkKey keyFooA = new SkylarkKey(Label.parseAbsolute("//foo.bzl"), "provA");
- SkylarkKey keyFooB = new SkylarkKey(Label.parseAbsolute("//foo.bzl"), "provB");
- SkylarkKey keyBarA = new SkylarkKey(Label.parseAbsolute("//bar.bzl"), "provA");
- SkylarkKey keyBarB = new SkylarkKey(Label.parseAbsolute("//bar.bzl"), "provB");
+ SkylarkKey keyFooA =
+ new SkylarkKey(Label.parseAbsolute("//foo.bzl", ImmutableMap.of()), "provA");
+ SkylarkKey keyFooB =
+ new SkylarkKey(Label.parseAbsolute("//foo.bzl", ImmutableMap.of()), "provB");
+ SkylarkKey keyBarA =
+ new SkylarkKey(Label.parseAbsolute("//bar.bzl", ImmutableMap.of()), "provA");
+ SkylarkKey keyBarB =
+ new SkylarkKey(Label.parseAbsolute("//bar.bzl", ImmutableMap.of()), "provB");
// 1 for each key, plus a duplicate for one of the keys, plus 2 that have no key.
SkylarkProvider provFooA1 =
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java
index 58107d0..88a02fb 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java
@@ -207,7 +207,7 @@
protected Target getTarget(String label)
throws NoSuchPackageException, NoSuchTargetException,
LabelSyntaxException, InterruptedException {
- return getTarget(Label.parseAbsolute(label));
+ return getTarget(Label.parseAbsolute(label, ImmutableMap.of()));
}
protected Target getTarget(Label label)
@@ -290,7 +290,7 @@
public static Set<Label> asLabelSet(Iterable<String> strings) throws LabelSyntaxException {
Set<Label> result = Sets.newTreeSet();
for (String s : strings) {
- result.add(Label.parseAbsolute(s));
+ result.add(Label.parseAbsolute(s, ImmutableMap.of()));
}
return result;
}