diff options
author | dannark <dannark@google.com> | 2018-06-27 13:35:04 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-27 13:36:25 -0700 |
commit | 90e2b4b5e745fe2de9ca82bc8163c198e5be8ca9 (patch) | |
tree | f827defac036acf55c4253c01f11126e0c502572 /src/test/java/com/google | |
parent | 116971c08caa3f9bd94fc91066cd4cd1e432cafe (diff) |
Automated refactor of Label.parseAbsolute() to always pass a repository mapping
RELNOTES: None
PiperOrigin-RevId: 202360925
Diffstat (limited to 'src/test/java/com/google')
68 files changed, 754 insertions, 494 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java b/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java index 022ecdd124..72c782f476 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java +++ b/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java @@ -19,6 +19,7 @@ import static org.junit.Assert.fail; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; import com.google.devtools.build.lib.actions.Artifact.SpecialArtifactType; import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; @@ -67,7 +68,8 @@ public class CustomCommandLineTest { assertThat(builder().addDynamicString("--arg").build().arguments()) .containsExactly("--arg") .inOrder(); - assertThat(builder().addLabel(Label.parseAbsolute("//a:b")).build().arguments()) + assertThat( + builder().addLabel(Label.parseAbsolute("//a:b", ImmutableMap.of())).build().arguments()) .containsExactly("//a:b") .inOrder(); assertThat(builder().addPath(PathFragment.create("path")).build().arguments()) @@ -93,7 +95,11 @@ public class CustomCommandLineTest { assertThat(builder().add("--arg", "val").build().arguments()) .containsExactly("--arg", "val") .inOrder(); - assertThat(builder().addLabel("--arg", Label.parseAbsolute("//a:b")).build().arguments()) + assertThat( + builder() + .addLabel("--arg", Label.parseAbsolute("//a:b", ImmutableMap.of())) + .build() + .arguments()) .containsExactly("--arg", "//a:b") .inOrder(); assertThat(builder().addPath("--arg", PathFragment.create("path")).build().arguments()) @@ -131,7 +137,10 @@ public class CustomCommandLineTest { .containsExactly("prefix-foo") .inOrder(); assertThat( - builder().addPrefixedLabel("prefix-", Label.parseAbsolute("//a:b")).build().arguments()) + builder() + .addPrefixedLabel("prefix-", Label.parseAbsolute("//a:b", ImmutableMap.of())) + .build() + .arguments()) .containsExactly("prefix-//a:b") .inOrder(); assertThat( diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java index 2c846790fe..acf57fd740 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java @@ -17,6 +17,7 @@ package com.google.devtools.build.lib.analysis; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; import com.google.common.eventbus.Subscribe; @@ -119,7 +120,7 @@ public class AnalysisFailureReportingTest extends AnalysisTestCase { assertThat(collector.events.get(topLevel)) .containsExactly( new LoadingFailedCause( - Label.parseAbsolute("//cycles1"), + Label.parseAbsolute("//cycles1", ImmutableMap.of()), // TODO(ulfjack): Ideally, we'd get an error message about a symlink cycle instead. "Target '//cycles1:cycles1' contains an error and its package is in error")); } @@ -138,10 +139,10 @@ public class AnalysisFailureReportingTest extends AnalysisTestCase { assertThat(collector.events.get(topLevel)) .containsExactly( new AnalysisFailedCause( - Label.parseAbsolute("//foo"), - toId(Iterables - .getOnlyElement(result.getTopLevelTargetsWithConfigs()) - .getConfiguration()), + Label.parseAbsolute("//foo", ImmutableMap.of()), + toId( + Iterables.getOnlyElement(result.getTopLevelTargetsWithConfigs()) + .getConfiguration()), "target '//bar:bar' is not visible from target '//foo:foo'. " + "Check the visibility declaration of the former target if you think the " + "dependency is legitimate")); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapperTest.java index bf0860fd3e..8bb0dee8b3 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapperTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapperTest.java @@ -75,7 +75,7 @@ public class AspectAwareAttributeMapperTest extends BuildViewTestCase { @Test public void getRuleAttributeValue() throws Exception { assertThat(mapper.get("srcs", BuildType.LABEL_LIST)) - .containsExactly(Label.parseAbsolute("//foo:a.cc")); + .containsExactly(Label.parseAbsolute("//foo:a.cc", ImmutableMap.of())); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AspectValueTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AspectValueTest.java index b0cf53bf32..c8dd26210d 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AspectValueTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AspectValueTest.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.analysis; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.testing.EqualsTester; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.util.AnalysisTestCase; @@ -42,9 +43,9 @@ public class AspectValueTest extends AnalysisTestCase { update(); BuildConfiguration c1 = getTargetConfiguration(); BuildConfiguration c2 = getHostConfiguration(); - Label l1 = Label.parseAbsolute("//a:l1"); - Label l1b = Label.parseAbsolute("//a:l1"); - Label l2 = Label.parseAbsolute("//a:l2"); + Label l1 = Label.parseAbsolute("//a:l1", ImmutableMap.of()); + Label l1b = Label.parseAbsolute("//a:l1", ImmutableMap.of()); + Label l2 = Label.parseAbsolute("//a:l2", ImmutableMap.of()); AspectParameters i1 = new AspectParameters.Builder() .addAttribute("foo", "bar") .build(); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java index e336d46a4a..25e0c83f65 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.fail; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -240,7 +241,8 @@ public class BuildViewTest extends BuildViewTestBase { assertThat(recorder.events) .contains( new LoadingFailureEvent( - Label.parseAbsolute("//pkg:foo"), Label.parseAbsolute("//nopackage:missing"))); + Label.parseAbsolute("//pkg:foo", ImmutableMap.of()), + Label.parseAbsolute("//nopackage:missing", ImmutableMap.of()))); assertContainsEvent("missing value for mandatory attribute 'outs'"); assertContainsEvent("no such package 'nopackage'"); // Skyframe correctly reports the other root cause as the genrule itself (since it is @@ -249,7 +251,8 @@ public class BuildViewTest extends BuildViewTestBase { assertThat(recorder.events) .contains( new LoadingFailureEvent( - Label.parseAbsolute("//pkg:foo"), Label.parseAbsolute("//pkg:foo"))); + Label.parseAbsolute("//pkg:foo", ImmutableMap.of()), + Label.parseAbsolute("//pkg:foo", ImmutableMap.of()))); } @Test @@ -279,13 +282,14 @@ public class BuildViewTest extends BuildViewTestBase { .that( recorder.events.contains( new LoadingFailureEvent( - Label.parseAbsolute("//third_party/first"), - Label.parseAbsolute("//third_party/fourth")))) + Label.parseAbsolute("//third_party/first", ImmutableMap.of()), + Label.parseAbsolute("//third_party/fourth", ImmutableMap.of())))) .isTrue(); assertThat(recorder.events) - .contains(new LoadingFailureEvent( - Label.parseAbsolute("//third_party/third"), - Label.parseAbsolute("//third_party/fourth"))); + .contains( + new LoadingFailureEvent( + Label.parseAbsolute("//third_party/third", ImmutableMap.of()), + Label.parseAbsolute("//third_party/fourth", ImmutableMap.of()))); } @Test @@ -305,10 +309,14 @@ public class BuildViewTest extends BuildViewTestBase { assertThat(recorder.events).hasSize(2); assertThat(recorder.events) .contains( - new LoadingFailureEvent(Label.parseAbsolute("//gp"), Label.parseAbsolute("//c1:not"))); + new LoadingFailureEvent( + Label.parseAbsolute("//gp", ImmutableMap.of()), + Label.parseAbsolute("//c1:not", ImmutableMap.of()))); assertThat(recorder.events) .contains( - new LoadingFailureEvent(Label.parseAbsolute("//gp"), Label.parseAbsolute("//c2:not"))); + new LoadingFailureEvent( + Label.parseAbsolute("//gp", ImmutableMap.of()), + Label.parseAbsolute("//c2:not", ImmutableMap.of()))); } /** @@ -348,7 +356,8 @@ public class BuildViewTest extends BuildViewTestBase { Iterable<Label> labels = Iterables.transform(targets, target -> target.getLabel()); assertThat(labels) .containsExactly( - Label.parseAbsolute("//package:inner"), Label.parseAbsolute("//package:file")); + Label.parseAbsolute("//package:inner", ImmutableMap.of()), + Label.parseAbsolute("//package:file", ImmutableMap.of())); } @Test @@ -372,12 +381,11 @@ public class BuildViewTest extends BuildViewTestBase { Dependency innerDependency = Dependency.withTransitionAndAspects( - Label.parseAbsolute("//package:inner"), + Label.parseAbsolute("//package:inner", ImmutableMap.of()), NoTransition.INSTANCE, AspectCollection.EMPTY); Dependency fileDependency = - Dependency.withNullConfiguration( - Label.parseAbsolute("//package:file")); + Dependency.withNullConfiguration(Label.parseAbsolute("//package:file", ImmutableMap.of())); assertThat(targets).containsExactly(innerDependency, fileDependency); } @@ -831,8 +839,12 @@ public class BuildViewTest extends BuildViewTestBase { assertThat(result.hasError()).isTrue(); assertThat(recorder.events) .containsExactly( - new LoadingFailureEvent(Label.parseAbsolute("//gp"), Label.parseAbsolute("//cycles1")), - new LoadingFailureEvent(Label.parseAbsolute("//gp"), Label.parseAbsolute("//cycles2"))); + new LoadingFailureEvent( + Label.parseAbsolute("//gp", ImmutableMap.of()), + Label.parseAbsolute("//cycles1", ImmutableMap.of())), + new LoadingFailureEvent( + Label.parseAbsolute("//gp", ImmutableMap.of()), + Label.parseAbsolute("//cycles2", ImmutableMap.of()))); } /** diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java index 6d4ba5f206..2c905db176 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java @@ -18,6 +18,7 @@ import static com.google.devtools.build.lib.packages.Attribute.attr; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.analysis.config.ConfigurationEnvironment; import com.google.devtools.build.lib.analysis.config.ConfigurationEnvironment.TargetProviderEnvironment; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; @@ -368,22 +369,25 @@ public class ConfigurableAttributesTest extends BuildViewTestCase { // Legal case: assertThat( - RedirectChaser - .followRedirects(env, Label.parseAbsolute("//java/hello:good_base"), "srcs") + RedirectChaser.followRedirects( + env, Label.parseAbsolute("//java/hello:good_base", ImmutableMap.of()), "srcs") .toString()) .isEqualTo("//java/hello:actual_content"); // Legal case: assertThat( - RedirectChaser - .followRedirects(env, Label.parseAbsolute("//java/hello:base_non_filegroup_target"), + RedirectChaser.followRedirects( + env, + Label.parseAbsolute( + "//java/hello:base_non_filegroup_target", ImmutableMap.of()), "srcs") .toString()) .isEqualTo("//java/hello:non_filegroup_target"); // Illegal case: try { - RedirectChaser.followRedirects(env, Label.parseAbsolute("//java/hello:bad_base"), "srcs"); + RedirectChaser.followRedirects( + env, Label.parseAbsolute("//java/hello:bad_base", ImmutableMap.of()), "srcs"); fail("Expected RedirectChaser to fail on a sequence with configurable 'srcs' values"); } catch (InvalidConfigurationException e) { // Expected failure.. @@ -1129,8 +1133,8 @@ public class ConfigurableAttributesTest extends BuildViewTestCase { useConfiguration("--test_arg=a"); ConfiguredTargetAndData ctad = getConfiguredTargetAndData("//foo:rule"); AttributeMap attributes = getMapperFromConfiguredTargetAndTarget(ctad); - assertThat(attributes.get("dep", BuildType.LABEL)).isEqualTo( - Label.parseAbsolute("//foo:default")); + assertThat(attributes.get("dep", BuildType.LABEL)) + .isEqualTo(Label.parseAbsolute("//foo:default", ImmutableMap.of())); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java index 759bdef9e3..3da6225c0a 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java @@ -19,6 +19,7 @@ import static com.google.devtools.build.lib.packages.Attribute.attr; import static com.google.devtools.build.lib.packages.BuildType.LABEL; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.transitions.PatchTransition; @@ -92,9 +93,10 @@ public class ConfigurationsForLateBoundTargetsTest extends AnalysisTestCase { " name = 'latebound_dep')"); update("//foo:foo"); assertThat(getConfiguredTarget("//foo:foo", getTargetConfiguration())).isNotNull(); - ConfiguredTarget dep = Iterables.getOnlyElement( - SkyframeExecutorTestUtils.getExistingConfiguredTargets( - skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep"))); + ConfiguredTarget dep = + Iterables.getOnlyElement( + SkyframeExecutorTestUtils.getExistingConfiguredTargets( + skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep", ImmutableMap.of()))); assertThat(getConfiguration(dep)).isNotEqualTo(getTargetConfiguration()); assertThat(LateBoundSplitUtil.getOptions(getConfiguration(dep)).fooFlag).isEqualTo("PATCHED!"); } @@ -114,9 +116,10 @@ public class ConfigurationsForLateBoundTargetsTest extends AnalysisTestCase { " name = 'latebound_dep')"); update("//foo:gen"); assertThat(getConfiguredTarget("//foo:foo", getHostConfiguration())).isNotNull(); - ConfiguredTarget dep = Iterables.getOnlyElement( - SkyframeExecutorTestUtils.getExistingConfiguredTargets( - skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep"))); + ConfiguredTarget dep = + Iterables.getOnlyElement( + SkyframeExecutorTestUtils.getExistingConfiguredTargets( + skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep", ImmutableMap.of()))); assertThat(getConfiguration(dep)).isEqualTo(getHostConfiguration()); // This is technically redundant, but slightly stronger in sanity checking that the host // configuration doesn't happen to match what the patch would have done. @@ -132,8 +135,9 @@ public class ConfigurationsForLateBoundTargetsTest extends AnalysisTestCase { " name = 'latebound_dep')"); // if the target fails to analyze, this iterable will be empty assertThat(update("//foo:foo").getTargetsToBuild()).isNotEmpty(); - Iterable<ConfiguredTarget> deps = SkyframeExecutorTestUtils.getExistingConfiguredTargets( - skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep")); + Iterable<ConfiguredTarget> deps = + SkyframeExecutorTestUtils.getExistingConfiguredTargets( + skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep", ImmutableMap.of())); assertThat(deps).hasSize(2); assertThat( ImmutableList.of( @@ -157,9 +161,10 @@ public class ConfigurationsForLateBoundTargetsTest extends AnalysisTestCase { " name = 'latebound_dep')"); update("//foo:gen"); assertThat(getConfiguredTarget("//foo:foo", getHostConfiguration())).isNotNull(); - ConfiguredTarget dep = Iterables.getOnlyElement( - SkyframeExecutorTestUtils.getExistingConfiguredTargets( - skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep"))); + ConfiguredTarget dep = + Iterables.getOnlyElement( + SkyframeExecutorTestUtils.getExistingConfiguredTargets( + skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep", ImmutableMap.of()))); assertThat(getConfiguration(dep)).isEqualTo(getHostConfiguration()); // This is technically redundant, but slightly stronger in sanity checking that the host // configuration doesn't happen to match what the split would have done. diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java index 237b1f0c6c..15a90a87a1 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.analysis; import static com.google.common.truth.Truth.assertThat; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.analysis.config.CompilationMode; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.cmdline.Label; @@ -124,21 +125,24 @@ public class ConfiguredAttributeMapperTest extends BuildViewTestCase { } }; - final Label binSrc = Label.parseAbsolute("//a:bin.sh"); + final Label binSrc = Label.parseAbsolute("//a:bin.sh", ImmutableMap.of()); useConfiguration("--define", "mode=a"); getMapper("//a:bin").visitLabels(testVisitor); - assertThat(visitedLabels).containsExactly(binSrc, Label.parseAbsolute("//a:adep")); + assertThat(visitedLabels) + .containsExactly(binSrc, Label.parseAbsolute("//a:adep", ImmutableMap.of())); visitedLabels.clear(); useConfiguration("--define", "mode=b"); getMapper("//a:bin").visitLabels(testVisitor); - assertThat(visitedLabels).containsExactly(binSrc, Label.parseAbsolute("//a:bdep")); + assertThat(visitedLabels) + .containsExactly(binSrc, Label.parseAbsolute("//a:bdep", ImmutableMap.of())); visitedLabels.clear(); useConfiguration("--define", "mode=c"); getMapper("//a:bin").visitLabels(testVisitor); - assertThat(visitedLabels).containsExactly(binSrc, Label.parseAbsolute("//a:defaultdep")); + assertThat(visitedLabels) + .containsExactly(binSrc, Label.parseAbsolute("//a:defaultdep", ImmutableMap.of())); } /** @@ -172,7 +176,7 @@ public class ConfiguredAttributeMapperTest extends BuildViewTestCase { // Target configuration is in dbg mode, so we should match //conditions:b: assertThat(getMapper("//a:gen").get("tools", BuildType.LABEL_LIST)) - .containsExactly(Label.parseAbsolute("//a:bdep")); + .containsExactly(Label.parseAbsolute("//a:bdep", ImmutableMap.of())); // Verify the "tools" dep uses a different configuration that's not also in "dbg": assertThat( @@ -202,7 +206,9 @@ public class ConfiguredAttributeMapperTest extends BuildViewTestCase { ")"); useConfiguration("--define", "foo=a", "--define", "bar=d"); assertThat(getMapper("//hello:gen").get("srcs", BuildType.LABEL_LIST)) - .containsExactly(Label.parseAbsolute("//hello:a.in"), Label.parseAbsolute("//hello:d.in")); + .containsExactly( + Label.parseAbsolute("//hello:a.in", ImmutableMap.of()), + Label.parseAbsolute("//hello:d.in", ImmutableMap.of())); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java b/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java index 9ab7d59fba..26005cfc3d 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java @@ -108,7 +108,8 @@ public class DependencyResolverTest extends AnalysisTestCase { private OrderedSetMultimap<Attribute, Dependency> dependentNodeMap( String targetName, NativeAspectClass aspect) throws Exception { - Target target = packageManager.getTarget(reporter, Label.parseAbsolute(targetName)); + Target target = + packageManager.getTarget(reporter, Label.parseAbsolute(targetName, ImmutableMap.of())); return dependencyResolver.dependentNodeMap( new TargetAndConfiguration(target, getTargetConfiguration()), getHostConfiguration(), diff --git a/src/test/java/com/google/devtools/build/lib/analysis/DependencyTest.java b/src/test/java/com/google/devtools/build/lib/analysis/DependencyTest.java index 57f0e630ad..bf8f9aba4b 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/DependencyTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/DependencyTest.java @@ -40,9 +40,10 @@ import org.junit.runners.JUnit4; public class DependencyTest extends AnalysisTestCase { @Test public void withNullConfiguration_BasicAccessors() throws Exception { - Dependency nullDep = Dependency.withNullConfiguration(Label.parseAbsolute("//a")); + Dependency nullDep = + Dependency.withNullConfiguration(Label.parseAbsolute("//a", ImmutableMap.of())); - assertThat(nullDep.getLabel()).isEqualTo(Label.parseAbsolute("//a")); + assertThat(nullDep.getLabel()).isEqualTo(Label.parseAbsolute("//a", ImmutableMap.of())); assertThat(nullDep.hasExplicitConfiguration()).isTrue(); assertThat(nullDep.getConfiguration()).isNull(); assertThat(nullDep.getAspects().getAllAspects()).isEmpty(); @@ -59,9 +60,10 @@ public class DependencyTest extends AnalysisTestCase { public void withConfiguration_BasicAccessors() throws Exception { update(); Dependency targetDep = - Dependency.withConfiguration(Label.parseAbsolute("//a"), getTargetConfiguration()); + Dependency.withConfiguration( + Label.parseAbsolute("//a", ImmutableMap.of()), getTargetConfiguration()); - assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a")); + assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a", ImmutableMap.of())); assertThat(targetDep.hasExplicitConfiguration()).isTrue(); assertThat(targetDep.getConfiguration()).isEqualTo(getTargetConfiguration()); assertThat(targetDep.getAspects().getAllAspects()).isEmpty(); @@ -83,9 +85,9 @@ public class DependencyTest extends AnalysisTestCase { ImmutableSet.of(simpleAspect, attributeAspect)); Dependency targetDep = Dependency.withConfigurationAndAspects( - Label.parseAbsolute("//a"), getTargetConfiguration(), twoAspects); + Label.parseAbsolute("//a", ImmutableMap.of()), getTargetConfiguration(), twoAspects); - assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a")); + assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a", ImmutableMap.of())); assertThat(targetDep.hasExplicitConfiguration()).isTrue(); assertThat(targetDep.getConfiguration()).isEqualTo(getTargetConfiguration()); assertThat(targetDep.getAspects()).isEqualTo(twoAspects); @@ -110,7 +112,8 @@ public class DependencyTest extends AnalysisTestCase { AspectCollection twoAspects = AspectCollection.createForTests(simpleAspect, attributeAspect); try { - Dependency.withConfigurationAndAspects(Label.parseAbsolute("//a"), null, twoAspects); + Dependency.withConfigurationAndAspects( + Label.parseAbsolute("//a", ImmutableMap.of()), null, twoAspects); fail("should not be allowed to create a dependency with a null configuration"); } catch (NullPointerException expected) { // good. you fell rrrrright into my trap. @@ -122,7 +125,7 @@ public class DependencyTest extends AnalysisTestCase { update(); Dependency dep = Dependency.withConfigurationAndAspects( - Label.parseAbsolute("//a"), + Label.parseAbsolute("//a", ImmutableMap.of()), getTargetConfiguration(), AspectCollection.EMPTY); // Here we're also checking that this doesn't throw an exception. No boom? OK. Good. @@ -140,9 +143,12 @@ public class DependencyTest extends AnalysisTestCase { simpleAspect, getTargetConfiguration(), attributeAspect, getHostConfiguration()); Dependency targetDep = Dependency.withConfiguredAspects( - Label.parseAbsolute("//a"), getTargetConfiguration(), aspects, twoAspectMap); + Label.parseAbsolute("//a", ImmutableMap.of()), + getTargetConfiguration(), + aspects, + twoAspectMap); - assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a")); + assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a", ImmutableMap.of())); assertThat(targetDep.hasExplicitConfiguration()).isTrue(); assertThat(targetDep.getConfiguration()).isEqualTo(getTargetConfiguration()); assertThat(targetDep.getAspects().getAllAspects()) @@ -165,7 +171,8 @@ public class DependencyTest extends AnalysisTestCase { update(); Dependency dep = Dependency.withConfiguredAspects( - Label.parseAbsolute("//a"), getTargetConfiguration(), + Label.parseAbsolute("//a", ImmutableMap.of()), + getTargetConfiguration(), AspectCollection.EMPTY, ImmutableMap.<AspectDescriptor, BuildConfiguration>of()); // Here we're also checking that this doesn't throw an exception. No boom? OK. Good. @@ -180,9 +187,9 @@ public class DependencyTest extends AnalysisTestCase { ImmutableSet.of(simpleAspect, attributeAspect)); Dependency hostDep = Dependency.withTransitionAndAspects( - Label.parseAbsolute("//a"), HostTransition.INSTANCE, twoAspects); + Label.parseAbsolute("//a", ImmutableMap.of()), HostTransition.INSTANCE, twoAspects); - assertThat(hostDep.getLabel()).isEqualTo(Label.parseAbsolute("//a")); + assertThat(hostDep.getLabel()).isEqualTo(Label.parseAbsolute("//a", ImmutableMap.of())); assertThat(hostDep.hasExplicitConfiguration()).isFalse(); assertThat(hostDep.getAspects().getAllAspects()) .containsExactlyElementsIn(twoAspects.getAllAspects()); @@ -217,7 +224,8 @@ public class DependencyTest extends AnalysisTestCase { update(); Dependency dep = Dependency.withTransitionAndAspects( - Label.parseAbsolute("//a"), HostTransition.INSTANCE, + Label.parseAbsolute("//a", ImmutableMap.of()), + HostTransition.INSTANCE, AspectCollection.EMPTY); // Here we're also checking that this doesn't throw an exception. No boom? OK. Good. assertThat(dep.getAspects().getAllAspects()).isEmpty(); @@ -228,7 +236,7 @@ public class DependencyTest extends AnalysisTestCase { update(); new NullPointerTester() - .setDefault(Label.class, Label.parseAbsolute("//a")) + .setDefault(Label.class, Label.parseAbsolute("//a", ImmutableMap.of())) .setDefault(BuildConfiguration.class, getTargetConfiguration()) .testAllPublicStaticMethods(Dependency.class); } @@ -237,9 +245,9 @@ public class DependencyTest extends AnalysisTestCase { public void equalsPassesEqualsTester() throws Exception { update(); - Label a = Label.parseAbsolute("//a"); - Label aExplicit = Label.parseAbsolute("//a:a"); - Label b = Label.parseAbsolute("//b"); + Label a = Label.parseAbsolute("//a", ImmutableMap.of()); + Label aExplicit = Label.parseAbsolute("//a:a", ImmutableMap.of()); + Label b = Label.parseAbsolute("//b", ImmutableMap.of()); BuildConfiguration host = getHostConfiguration(); BuildConfiguration target = getTargetConfiguration(); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java b/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java index 99d577789e..3a6c67183a 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java @@ -500,7 +500,7 @@ public class LicensingTests extends BuildViewTestCase { for (int i = 0; i < strings.length; i += 2) { String labelStr = strings[i]; String licStr = strings[i + 1]; - Label label = Label.parseAbsolute(labelStr); + Label label = Label.parseAbsolute(labelStr, ImmutableMap.of()); List<String> splitLicenses = licStr.isEmpty() ? Arrays.<String>asList() : Arrays.asList(licStr.split(",")); License license = License.parseLicense(splitLicenses); @@ -546,7 +546,7 @@ public class LicensingTests extends BuildViewTestCase { ConfiguredTarget used = getConfiguredTarget("//used"); Map<Label, License> usedActual = Maps.filterKeys(getTransitiveLicenses(used), AnalysisMock.get().ccSupport().labelFilter()); - Label usedLabel = Label.parseAbsolute("//used"); + Label usedLabel = Label.parseAbsolute("//used", ImmutableMap.of()); License license = usedActual.get(usedLabel); license.checkCompatibility(EnumSet.of(DistributionType.CLIENT), getTarget("//user"), usedLabel, reporter, false); @@ -570,7 +570,7 @@ public class LicensingTests extends BuildViewTestCase { ConfiguredTarget used = getConfiguredTarget("//used"); Map<Label, License> usedActual = Maps.filterKeys(getTransitiveLicenses(used), AnalysisMock.get().ccSupport().labelFilter()); - Label usedLabel = Label.parseAbsolute("//used"); + Label usedLabel = Label.parseAbsolute("//used", ImmutableMap.of()); License license = usedActual.get(usedLabel); license.checkCompatibility(EnumSet.of(DistributionType.CLIENT), getTarget("//user"), usedLabel, reporter, false); @@ -652,8 +652,8 @@ public class LicensingTests extends BuildViewTestCase { @Test public void testTargetLicenseEquality() throws Exception { - Label label1 = Label.parseAbsolute("//foo"); - Label label2 = Label.parseAbsolute("//bar"); + Label label1 = Label.parseAbsolute("//foo", ImmutableMap.of()); + Label label2 = Label.parseAbsolute("//bar", ImmutableMap.of()); License restricted = License.parseLicense(ImmutableList.of("restricted")); License unencumbered = License.parseLicense(ImmutableList.of("unencumbered")); new EqualsTester() diff --git a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java index cda90b9eb7..baa2940b1c 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java @@ -17,6 +17,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; @@ -192,12 +193,15 @@ public class BuildConfigurationTest extends ConfigurationTestCase { @Test public void testTargetEnvironment() throws Exception { BuildConfiguration oneEnvConfig = create("--target_environment=//foo"); - assertThat(oneEnvConfig.getTargetEnvironments()).containsExactly(Label.parseAbsolute("//foo")); + assertThat(oneEnvConfig.getTargetEnvironments()) + .containsExactly(Label.parseAbsolute("//foo", ImmutableMap.of())); BuildConfiguration twoEnvsConfig = create("--target_environment=//foo", "--target_environment=//bar"); assertThat(twoEnvsConfig.getTargetEnvironments()) - .containsExactly(Label.parseAbsolute("//foo"), Label.parseAbsolute("//bar")); + .containsExactly( + Label.parseAbsolute("//foo", ImmutableMap.of()), + Label.parseAbsolute("//bar", ImmutableMap.of())); BuildConfiguration noEnvsConfig = create(); assertThat(noEnvsConfig.getTargetEnvironments()).isEmpty(); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java index e1d3045fc3..e5f38cb650 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.analysis.select; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.AttributeMap; @@ -116,9 +117,9 @@ public class RawAttributeMapperTest extends AbstractAttributeMapperTest { RawAttributeMapper rawMapper = RawAttributeMapper.of(setupGenRule()); assertThat(rawMapper.getConfigurabilityKeys("srcs", BuildType.LABEL_LIST)) .containsExactly( - Label.parseAbsolute("//conditions:a"), - Label.parseAbsolute("//conditions:b"), - Label.parseAbsolute("//conditions:default")); + Label.parseAbsolute("//conditions:a", ImmutableMap.of()), + Label.parseAbsolute("//conditions:b", ImmutableMap.of()), + Label.parseAbsolute("//conditions:default", ImmutableMap.of())); assertThat(rawMapper.getConfigurabilityKeys("data", BuildType.LABEL_LIST)).isEmpty(); } @@ -132,10 +133,11 @@ public class RawAttributeMapperTest extends AbstractAttributeMapperTest { " '//conditions:b': ['b.sh', 'c.sh'],", " }))"); RawAttributeMapper rawMapper = RawAttributeMapper.of(rule); - assertThat(rawMapper.getMergedValues("srcs", BuildType.LABEL_LIST)).containsExactly( - Label.parseAbsolute("//x:a.sh"), - Label.parseAbsolute("//x:b.sh"), - Label.parseAbsolute("//x:c.sh")) + assertThat(rawMapper.getMergedValues("srcs", BuildType.LABEL_LIST)) + .containsExactly( + Label.parseAbsolute("//x:a.sh", ImmutableMap.of()), + Label.parseAbsolute("//x:b.sh", ImmutableMap.of()), + Label.parseAbsolute("//x:c.sh", ImmutableMap.of())) .inOrder(); } @@ -152,12 +154,13 @@ public class RawAttributeMapperTest extends AbstractAttributeMapperTest { " '//conditions:b2': ['b2.sh']})", " )"); RawAttributeMapper rawMapper = RawAttributeMapper.of(rule); - assertThat(rawMapper.getMergedValues("srcs", BuildType.LABEL_LIST)).containsExactly( - Label.parseAbsolute("//x:a1.sh"), - Label.parseAbsolute("//x:b1.sh"), - Label.parseAbsolute("//x:another_b1.sh"), - Label.parseAbsolute("//x:a2.sh"), - Label.parseAbsolute("//x:b2.sh")) + assertThat(rawMapper.getMergedValues("srcs", BuildType.LABEL_LIST)) + .containsExactly( + Label.parseAbsolute("//x:a1.sh", ImmutableMap.of()), + Label.parseAbsolute("//x:b1.sh", ImmutableMap.of()), + Label.parseAbsolute("//x:another_b1.sh", ImmutableMap.of()), + Label.parseAbsolute("//x:a2.sh", ImmutableMap.of()), + Label.parseAbsolute("//x:b2.sh", ImmutableMap.of())) .inOrder(); } } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java index 447772460d..949f658abc 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java @@ -407,7 +407,7 @@ public abstract class AnalysisTestCase extends FoundationTestCase { ensureUpdateWasCalled(); Label parsedLabel; try { - parsedLabel = Label.parseAbsolute(label); + parsedLabel = Label.parseAbsolute(label, ImmutableMap.of()); } catch (LabelSyntaxException e) { throw new AssertionError(e); } @@ -416,8 +416,8 @@ public abstract class AnalysisTestCase extends FoundationTestCase { protected Target getTarget(String label) throws InterruptedException { try { - return SkyframeExecutorTestUtils.getExistingTarget(skyframeExecutor, - Label.parseAbsolute(label)); + return SkyframeExecutorTestUtils.getExistingTarget( + skyframeExecutor, Label.parseAbsolute(label, ImmutableMap.of())); } catch (LabelSyntaxException e) { throw new AssertionError(e); } @@ -452,7 +452,7 @@ public abstract class AnalysisTestCase extends FoundationTestCase { String label, BuildConfiguration configuration) { Label parsedLabel; try { - parsedLabel = Label.parseAbsolute(label); + parsedLabel = Label.parseAbsolute(label, ImmutableMap.of()); } catch (LabelSyntaxException e) { throw new AssertionError(e); } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index fa47f7a6c3..b92ae7fb9e 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -357,7 +357,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { 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) @@ -552,7 +552,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { protected final ConfiguredTarget getDirectPrerequisite(ConfiguredTarget target, String label) throws Exception { - Label candidateLabel = Label.parseAbsolute(label); + Label candidateLabel = Label.parseAbsolute(label, ImmutableMap.of()); for (ConfiguredTarget candidate : getDirectPrerequisites(target)) { if (candidate.getLabel().equals(candidateLabel)) { return candidate; @@ -564,7 +564,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { protected final ConfiguredTargetAndData getConfiguredTargetAndDataDirectPrerequisite( ConfiguredTargetAndData ctad, String label) throws Exception { - Label candidateLabel = Label.parseAbsolute(label); + Label candidateLabel = Label.parseAbsolute(label, ImmutableMap.of()); for (ConfiguredTargetAndData candidate : getDirectPrerequisites(ctad)) { if (candidate.getConfiguredTarget().getLabel().equals(candidateLabel)) { return candidate; @@ -829,7 +829,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { */ protected ConfiguredTarget getConfiguredTarget(String label, BuildConfiguration config) throws LabelSyntaxException { - return getConfiguredTarget(Label.parseAbsolute(label), config); + return getConfiguredTarget(Label.parseAbsolute(label, ImmutableMap.of()), config); } /** @@ -861,7 +861,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { */ public ConfiguredTargetAndData getConfiguredTargetAndData(String label) throws LabelSyntaxException { - return getConfiguredTargetAndData(Label.parseAbsolute(label), targetConfig); + return getConfiguredTargetAndData(Label.parseAbsolute(label, ImmutableMap.of()), targetConfig); } /** @@ -1486,7 +1486,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { public static Label makeLabel(String label) { try { - return Label.parseAbsolute(label); + return Label.parseAbsolute(label, ImmutableMap.of()); } catch (LabelSyntaxException e) { throw new IllegalStateException(e); } @@ -1782,7 +1782,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { 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; } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java b/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java index 22220e54e9..d5fe190090 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java @@ -21,6 +21,7 @@ import static com.google.devtools.build.lib.syntax.Type.STRING; import com.google.common.base.Function; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; @@ -421,7 +422,9 @@ public class TestAspects { ImmutableCollection<String> baz = aspectParameters.getAttribute("baz"); if (baz != null) { try { - builder.add(attr("$dep", LABEL).value(Label.parseAbsolute(baz.iterator().next()))); + builder.add( + attr("$dep", LABEL) + .value(Label.parseAbsolute(baz.iterator().next(), ImmutableMap.of()))); } catch (LabelSyntaxException e) { throw new IllegalStateException(); } diff --git a/src/test/java/com/google/devtools/build/lib/cmdline/LabelTest.java b/src/test/java/com/google/devtools/build/lib/cmdline/LabelTest.java index 4465a049f1..17bc1e2912 100644 --- a/src/test/java/com/google/devtools/build/lib/cmdline/LabelTest.java +++ b/src/test/java/com/google/devtools/build/lib/cmdline/LabelTest.java @@ -39,22 +39,22 @@ public class LabelTest { @Test public void testAbsolute() throws Exception { { - Label l = Label.parseAbsolute("//foo/bar:baz"); + Label l = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); assertThat(l.getPackageName()).isEqualTo("foo/bar"); assertThat(l.getName()).isEqualTo("baz"); } { - Label l = Label.parseAbsolute("//foo/bar"); + Label l = Label.parseAbsolute("//foo/bar", ImmutableMap.of()); assertThat(l.getPackageName()).isEqualTo("foo/bar"); assertThat(l.getName()).isEqualTo("bar"); } { - Label l = Label.parseAbsolute("//:bar"); + Label l = Label.parseAbsolute("//:bar", ImmutableMap.of()); assertThat(l.getPackageName()).isEmpty(); assertThat(l.getName()).isEqualTo("bar"); } { - Label l = Label.parseAbsolute("@foo"); + Label l = Label.parseAbsolute("@foo", ImmutableMap.of()); assertThat(l.getPackageIdentifier().getRepository().getName()).isEqualTo("@foo"); assertThat(l.getPackageName()).isEmpty(); assertThat(l.getName()).isEqualTo("foo"); @@ -100,7 +100,7 @@ public class LabelTest { @Test public void testGetRelativeWithAbsoluteLabel() throws Exception { - Label base = Label.parseAbsolute("//foo/bar:baz"); + Label base = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); Label l = base.getRelativeWithRemapping("//p1/p2:target", ImmutableMap.of()); assertThat(l.getPackageName()).isEqualTo("p1/p2"); assertThat(l.getName()).isEqualTo("target"); @@ -108,7 +108,7 @@ public class LabelTest { @Test public void testGetRelativeWithRelativeLabel() throws Exception { - Label base = Label.parseAbsolute("//foo/bar:baz"); + Label base = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); Label l = base.getRelativeWithRemapping(":quux", ImmutableMap.of()); assertThat(l.getPackageName()).isEqualTo("foo/bar"); assertThat(l.getName()).isEqualTo("quux"); @@ -116,7 +116,7 @@ public class LabelTest { @Test public void testGetRelativeWithIllegalLabel() throws Exception { - Label base = Label.parseAbsolute("//foo/bar:baz"); + Label base = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); try { base.getRelativeWithRemapping("/p1/p2:target", ImmutableMap.of()); fail(); @@ -210,10 +210,10 @@ public class LabelTest { @Test public void testGetRepositoryRelative() throws Exception { - Label defaultBase = Label.parseAbsolute("//foo/bar:baz"); - Label repoBase = Label.parseAbsolute("@repo//foo/bar:baz"); - Label mainBase = Label.parseAbsolute("@//foo/bar:baz"); - Label externalTarget = Label.parseAbsolute("//external:target"); + Label defaultBase = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); + Label repoBase = Label.parseAbsolute("@repo//foo/bar:baz", ImmutableMap.of()); + Label mainBase = Label.parseAbsolute("@//foo/bar:baz", ImmutableMap.of()); + Label externalTarget = Label.parseAbsolute("//external:target", ImmutableMap.of()); Label l = defaultBase.resolveRepositoryRelative(externalTarget); assertThat(l.getPackageIdentifier().getRepository().isMain()).isTrue(); assertThat(l.getPackageName()).isEqualTo("external"); @@ -232,9 +232,9 @@ public class LabelTest { @Test public void testIdentities() throws Exception { - Label l1 = Label.parseAbsolute("//foo/bar:baz"); - Label l2 = Label.parseAbsolute("//foo/bar:baz"); - Label l3 = Label.parseAbsolute("//foo/bar:quux"); + Label l1 = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); + Label l2 = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); + Label l3 = Label.parseAbsolute("//foo/bar:quux", ImmutableMap.of()); new EqualsTester() .addEqualityGroup(l1, l2) @@ -246,15 +246,15 @@ public class LabelTest { public void testToString() throws Exception { { String s = "@//foo/bar:baz"; - Label l = Label.parseAbsolute(s); + Label l = Label.parseAbsolute(s, ImmutableMap.of()); assertThat(l.toString()).isEqualTo("//foo/bar:baz"); } { - Label l = Label.parseAbsolute("//foo/bar"); + Label l = Label.parseAbsolute("//foo/bar", ImmutableMap.of()); assertThat(l.toString()).isEqualTo("//foo/bar:bar"); } { - Label l = Label.parseAbsolute("@foo"); + Label l = Label.parseAbsolute("@foo", ImmutableMap.of()); assertThat(l.toString()).isEqualTo("@foo//:foo"); } } @@ -262,26 +262,26 @@ public class LabelTest { @Test public void testToShorthandString() throws Exception { { - Label l = Label.parseAbsolute("//bar/baz:baz"); + Label l = Label.parseAbsolute("//bar/baz:baz", ImmutableMap.of()); assertThat(l.toShorthandString()).isEqualTo("//bar/baz"); } { - Label l = Label.parseAbsolute("//bar/baz:bat"); + Label l = Label.parseAbsolute("//bar/baz:bat", ImmutableMap.of()); assertThat(l.toShorthandString()).isEqualTo("//bar/baz:bat"); } { - Label l = Label.parseAbsolute("@foo//bar/baz:baz"); + Label l = Label.parseAbsolute("@foo//bar/baz:baz", ImmutableMap.of()); assertThat(l.toShorthandString()).isEqualTo("@foo//bar/baz"); } { - Label l = Label.parseAbsolute("@foo//bar/baz:bat"); + Label l = Label.parseAbsolute("@foo//bar/baz:bat", ImmutableMap.of()); assertThat(l.toShorthandString()).isEqualTo("@foo//bar/baz:bat"); } } @Test public void testDotDot() throws Exception { - Label.parseAbsolute("//foo/bar:baz..gif"); + Label.parseAbsolute("//foo/bar:baz..gif", ImmutableMap.of()); } /** @@ -290,7 +290,7 @@ public class LabelTest { */ private static void assertSyntaxError(String expectedError, String label) { try { - Label.parseAbsolute(label); + Label.parseAbsolute(label, ImmutableMap.of()); fail("Label '" + label + "' did not contain a syntax error"); } catch (LabelSyntaxException e) { assertThat(e).hasMessageThat().containsMatch(Pattern.quote(expectedError)); @@ -336,7 +336,8 @@ public class LabelTest { @Test public void testTrailingDotSegment() throws Exception { - assertThat(Label.parseAbsolute("//foo:dir")).isEqualTo(Label.parseAbsolute("//foo:dir/.")); + assertThat(Label.parseAbsolute("//foo:dir", ImmutableMap.of())) + .isEqualTo(Label.parseAbsolute("//foo:dir/.", ImmutableMap.of())); } @Test @@ -350,18 +351,18 @@ public class LabelTest { @Test public void testSomeGoodLabels() throws Exception { - Label.parseAbsolute("//foo:..bar"); - Label.parseAbsolute("//Foo:..bar"); - Label.parseAbsolute("//-Foo:..bar"); - Label.parseAbsolute("//00:..bar"); - Label.parseAbsolute("//package:foo+bar"); - Label.parseAbsolute("//package:foo_bar"); - Label.parseAbsolute("//package:foo=bar"); - Label.parseAbsolute("//package:foo-bar"); - Label.parseAbsolute("//package:foo.bar"); - Label.parseAbsolute("//package:foo@bar"); - Label.parseAbsolute("//package:foo~bar"); - Label.parseAbsolute("//$( ):$( )"); + Label.parseAbsolute("//foo:..bar", ImmutableMap.of()); + Label.parseAbsolute("//Foo:..bar", ImmutableMap.of()); + Label.parseAbsolute("//-Foo:..bar", ImmutableMap.of()); + Label.parseAbsolute("//00:..bar", ImmutableMap.of()); + Label.parseAbsolute("//package:foo+bar", ImmutableMap.of()); + Label.parseAbsolute("//package:foo_bar", ImmutableMap.of()); + Label.parseAbsolute("//package:foo=bar", ImmutableMap.of()); + Label.parseAbsolute("//package:foo-bar", ImmutableMap.of()); + Label.parseAbsolute("//package:foo.bar", ImmutableMap.of()); + Label.parseAbsolute("//package:foo@bar", ImmutableMap.of()); + Label.parseAbsolute("//package:foo~bar", ImmutableMap.of()); + Label.parseAbsolute("//$( ):$( )", ImmutableMap.of()); } /** @@ -417,7 +418,7 @@ public class LabelTest { } private void checkSerialization(String labelString, int expectedSize) throws Exception { - Label a = Label.parseAbsolute(labelString); + Label a = Label.parseAbsolute(labelString, ImmutableMap.of()); byte[] sa = TestUtils.serializeObject(a); assertThat(sa).hasLength(expectedSize); @@ -427,20 +428,20 @@ public class LabelTest { @Test public void testRepoLabel() throws Exception { - Label label = Label.parseAbsolute("@foo//bar/baz:bat/boo"); + Label label = Label.parseAbsolute("@foo//bar/baz:bat/boo", ImmutableMap.of()); assertThat(label.toString()).isEqualTo("@foo//bar/baz:bat/boo"); } @Test public void testNoRepo() throws Exception { - Label label = Label.parseAbsolute("//bar/baz:bat/boo"); + Label label = Label.parseAbsolute("//bar/baz:bat/boo", ImmutableMap.of()); assertThat(label.toString()).isEqualTo("//bar/baz:bat/boo"); } @Test public void testInvalidRepo() throws Exception { try { - Label.parseAbsolute("foo//bar/baz:bat/boo"); + Label.parseAbsolute("foo//bar/baz:bat/boo", ImmutableMap.of()); fail(); } catch (LabelSyntaxException e) { assertThat(e).hasMessage( @@ -450,9 +451,9 @@ public class LabelTest { @Test public void testGetWorkspaceRoot() throws Exception { - Label label = Label.parseAbsolute("//bar/baz"); + Label label = Label.parseAbsolute("//bar/baz", ImmutableMap.of()); assertThat(label.getWorkspaceRoot()).isEmpty(); - label = Label.parseAbsolute("@repo//bar/baz"); + label = Label.parseAbsolute("@repo//bar/baz", ImmutableMap.of()); assertThat(label.getWorkspaceRoot()).isEqualTo("external/repo"); } } 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 2244ca55ba..077ee3f68e 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 static org.junit.Assert.fail; 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 @@ public class AttributeTest { 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 @@ public class AttributeTest { 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 @@ public class AttributeTest { 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 @@ public class AttributeTest { 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 eccc5a5a35..317b43b656 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 @@ public class BuildTypeTest { @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 @@ public class BuildTypeTest { @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<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<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", 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 @@ public class BuildTypeTest { @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 @@ public class BuildTypeTest { @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 @@ public class BuildTypeTest { @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 @@ public class BuildTypeTest { @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 @@ public class BuildTypeTest { 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 @@ public class BuildTypeTest { 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 @@ public class BuildTypeTest { 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 @@ public class BuildTypeTest { 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 @@ public class BuildTypeTest { */ @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 @@ public class BuildTypeTest { 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 @@ public class BuildTypeTest { 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 @@ public class BuildTypeTest { } 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 @@ public class BuildTypeTest { @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 7a839a1df4..b2e4aec679 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 @@ package com.google.devtools.build.lib.packages; 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 @@ public class EnvironmentGroupTest extends PackageLoadingTestCase { 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 2dba95fdf6..eb416f5c30 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 @@ package com.google.devtools.build.lib.packages; 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 @@ public class ExternalPackageTest extends BuildViewTestCase { 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 501037574a..a5c3557bc1 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 com.google.common.truth.Truth.assertThat; 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 @@ public class PackageFactoryTest extends PackageFactoryTestBase { 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 @@ public class PackageFactoryTest extends PackageFactoryTestBase { 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 @@ public class PackageFactoryTest extends PackageFactoryTestBase { 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 @@ public class PackageFactoryTest extends PackageFactoryTestBase { " 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 45d332cc48..384d2f329c 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 @@ public class RuleClassTest extends PackageLoadingTestCase { 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 @@ public class RuleClassTest extends PackageLoadingTestCase { // 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 @@ public class RuleClassTest extends PackageLoadingTestCase { .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 @@ public class RuleClassTest extends PackageLoadingTestCase { .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 @@ public class RuleClassTest extends PackageLoadingTestCase { .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 @@ public class RuleClassTest extends PackageLoadingTestCase { 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 @@ public class RuleClassTest extends PackageLoadingTestCase { .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 3c78b8eb3e..c806d0fbc9 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.assertThat; 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 @@ public class RuleFactoryTest extends PackageLoadingTestCase { 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 a4cb31a093..0c81e9bda9 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 @@ public final class SkylarkProviderTest { @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 @@ public final class SkylarkProviderTest { @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 58107d0b3a..88a02fb400 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 @@ public abstract class PackageLoadingTestCase extends FoundationTestCase { 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 abstract class PackageLoadingTestCase extends FoundationTestCase { 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; } diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/AbstractTargetPatternEvaluatorTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/AbstractTargetPatternEvaluatorTest.java index 85424470f7..1bc74605bb 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/AbstractTargetPatternEvaluatorTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/AbstractTargetPatternEvaluatorTest.java @@ -15,13 +15,13 @@ package com.google.devtools.build.lib.pkgcache; import static com.google.common.truth.Truth.assertThat; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.ResolvedTargets; import com.google.devtools.build.lib.cmdline.TargetParsingException; import com.google.devtools.build.lib.events.DelegatingEventHandler; import com.google.devtools.build.lib.events.ExtendedEventHandler; -import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable; import com.google.devtools.build.lib.packages.ConstantRuleVisibility; import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.packages.util.PackageLoadingTestCase; @@ -109,7 +109,7 @@ public abstract class AbstractTargetPatternEvaluatorTest extends PackageLoadingT protected static Set<Label> labels(String... labelStrings) throws LabelSyntaxException { Set<Label> labels = new HashSet<>(); for (String labelString : labelStrings) { - labels.add(Label.parseAbsolute(labelString)); + labels.add(Label.parseAbsolute(labelString, ImmutableMap.of())); } return labels; } diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java index 3c3a7739a3..a2e6d3d27f 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.pkgcache; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.ResolvedTargets; @@ -67,7 +68,7 @@ public class CompileOneDependencyTransformerTest extends PackageLoadingTestCase private static Set<Label> labels(String... labelStrings) throws LabelSyntaxException { Set<Label> labels = new HashSet<>(); for (String labelString : labelStrings) { - labels.add(Label.parseAbsolute(labelString)); + labels.add(Label.parseAbsolute(labelString, ImmutableMap.of())); } return labels; } diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java index 40324ad625..de8e71b221 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.pkgcache; import static com.google.common.truth.Truth.assertThat; import com.google.common.base.Function; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.clock.BlazeClock; import com.google.devtools.build.lib.cmdline.Label; @@ -107,7 +108,7 @@ public class IOExceptionsTest extends PackageLoadingTestCase { return null; } }; - assertThat(visitTransitively(Label.parseAbsolute("//pkg:x"))).isFalse(); + assertThat(visitTransitively(Label.parseAbsolute("//pkg:x", ImmutableMap.of()))).isFalse(); scratch.overwriteFile("pkg/BUILD", "# another comment to force reload", "sh_library(name = 'x')"); @@ -115,7 +116,7 @@ public class IOExceptionsTest extends PackageLoadingTestCase { syncPackages(); eventCollector.clear(); reporter.addHandler(failFastHandler); - assertThat(visitTransitively(Label.parseAbsolute("//pkg:x"))).isTrue(); + assertThat(visitTransitively(Label.parseAbsolute("//pkg:x", ImmutableMap.of()))).isTrue(); assertNoEvents(); } @@ -136,7 +137,7 @@ public class IOExceptionsTest extends PackageLoadingTestCase { return null; } }; - assertThat(visitTransitively(Label.parseAbsolute("//top:top"))).isFalse(); + assertThat(visitTransitively(Label.parseAbsolute("//top:top", ImmutableMap.of()))).isFalse(); assertContainsEvent("no such package 'pkg'"); // The traditional label visitor does not propagate the original IOException message. // assertContainsEvent("custom crash"); @@ -150,7 +151,7 @@ public class IOExceptionsTest extends PackageLoadingTestCase { syncPackages(); eventCollector.clear(); reporter.addHandler(failFastHandler); - assertThat(visitTransitively(Label.parseAbsolute("//top:top"))).isTrue(); + assertThat(visitTransitively(Label.parseAbsolute("//top:top", ImmutableMap.of()))).isTrue(); assertNoEvents(); } @@ -169,6 +170,6 @@ public class IOExceptionsTest extends PackageLoadingTestCase { return null; } }; - assertThat(visitTransitively(Label.parseAbsolute("//top/pkg:x"))).isFalse(); + assertThat(visitTransitively(Label.parseAbsolute("//top/pkg:x", ImmutableMap.of()))).isFalse(); } } diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java index 32aacdaa9d..866844df31 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java @@ -352,7 +352,7 @@ public class IncrementalLoadingTest { Target target = tester.getTarget("//e:e"); assertThat(((Rule) target).containsErrors()).isFalse(); List<?> globList = (List<?>) ((Rule) target).getAttributeContainer().getAttr("data"); - assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt")); + assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt", ImmutableMap.of())); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java index df3c5c840a..461b21061a 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java @@ -194,7 +194,7 @@ public class PackageCacheTest extends FoundationTestCase { } private Target getTarget(String label) throws Exception { - return getTarget(Label.parseAbsolute(label)); + return getTarget(Label.parseAbsolute(label, ImmutableMap.of())); } private void createPkg1() throws IOException { @@ -245,7 +245,7 @@ public class PackageCacheTest extends FoundationTestCase { @Test public void testGetTarget() throws Exception { createPkg1(); - Label label = Label.parseAbsolute("//pkg1:foo"); + Label label = Label.parseAbsolute("//pkg1:foo", ImmutableMap.of()); Target target = getTarget(label); assertThat(target.getLabel()).isEqualTo(label); } @@ -403,7 +403,7 @@ public class PackageCacheTest extends FoundationTestCase { } private void assertLabelValidity(boolean expected, String labelString) throws Exception { - Label label = Label.parseAbsolute(labelString); + Label label = Label.parseAbsolute(labelString, ImmutableMap.of()); boolean actual = false; String error = null; diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorTest.java index 94029ac5c7..502e90c924 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorTest.java @@ -18,6 +18,7 @@ import static com.google.devtools.build.lib.pkgcache.FilteringPolicies.FILTER_TE import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -484,16 +485,20 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe @Test public void testParsesIterableOfLabels() throws Exception { - Set<Label> labels = Sets.newHashSet(Label.parseAbsolute("//foo/bar:bar1"), - Label.parseAbsolute("//foo:foo1")); + Set<Label> labels = + Sets.newHashSet( + Label.parseAbsolute("//foo/bar:bar1", ImmutableMap.of()), + Label.parseAbsolute("//foo:foo1", ImmutableMap.of())); assertThat(parseList("//foo/bar:bar1", "//foo:foo1")).isEqualTo(labels); parsingListener.assertEmpty(); } @Test public void testParseAbsoluteWithRelativeParser() throws Exception { - Set<Label> labels = Sets.newHashSet(Label.parseAbsolute("//foo/bar:bar1"), - Label.parseAbsolute("//foo:foo1")); + Set<Label> labels = + Sets.newHashSet( + Label.parseAbsolute("//foo/bar:bar1", ImmutableMap.of()), + Label.parseAbsolute("//foo:foo1", ImmutableMap.of())); assertThat(parseListRelative("//foo/bar:bar1", "//foo:foo1")).isEqualTo(labels); parsingListener.assertEmpty(); } @@ -519,7 +524,8 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe scratch.file("x/y/BUILD", "cc_library(name='y')"); scratch.file("x/z/BUILD", "cc_library(name='z')"); setDeletedPackages(Sets.newHashSet(PackageIdentifier.createInMainRepo("x/y"))); - assertThat(parseList("x/...")).isEqualTo(Sets.newHashSet(Label.parseAbsolute("//x/z"))); + assertThat(parseList("x/...")) + .isEqualTo(Sets.newHashSet(Label.parseAbsolute("//x/z", ImmutableMap.of()))); } @Test @@ -529,14 +535,15 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe setDeletedPackages(Sets.newHashSet(PackageIdentifier.createInMainRepo("x/y"))); assertThat( - targetsToLabels(getFailFast( - parseTargetPatternList( - PathFragment.create("x"), - parser, - parsingListener, - ImmutableList.of("..."), - false)))) - .isEqualTo(Sets.newHashSet(Label.parseAbsolute("//x/z"))); + targetsToLabels( + getFailFast( + parseTargetPatternList( + PathFragment.create("x"), + parser, + parsingListener, + ImmutableList.of("..."), + false)))) + .isEqualTo(Sets.newHashSet(Label.parseAbsolute("//x/z", ImmutableMap.of()))); } @Test @@ -544,15 +551,19 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe scratch.file("x/y/BUILD", "cc_library(name='y')"); scratch.file("x/z/BUILD", "cc_library(name='z')"); - assertThat(parseList("x/...")).containsExactly( - Label.parseAbsolute("//x/y"), Label.parseAbsolute("//x/z")); + assertThat(parseList("x/...")) + .containsExactly( + Label.parseAbsolute("//x/y", ImmutableMap.of()), + Label.parseAbsolute("//x/z", ImmutableMap.of())); setDeletedPackages(Sets.newHashSet(PackageIdentifier.createInMainRepo("x/y"))); - assertThat(parseList("x/...")).containsExactly(Label.parseAbsolute("//x/z")); + assertThat(parseList("x/...")).containsExactly(Label.parseAbsolute("//x/z", ImmutableMap.of())); setDeletedPackages(ImmutableSet.<PackageIdentifier>of()); - assertThat(parseList("x/...")).containsExactly( - Label.parseAbsolute("//x/y"), Label.parseAbsolute("//x/z")); + assertThat(parseList("x/...")) + .containsExactly( + Label.parseAbsolute("//x/y", ImmutableMap.of()), + Label.parseAbsolute("//x/z", ImmutableMap.of())); } @Test @@ -648,7 +659,8 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe // We make sure that the parent package is present, so that in the subsequent nokeep_going // build, the pattern parsing will have as many of its deps available as possible, which // exercises more code coverage during error bubbling. - assertThat(parseList("//parent:all")).containsExactly(Label.parseAbsolute("//parent:parent")); + assertThat(parseList("//parent:all")) + .containsExactly(Label.parseAbsolute("//parent:parent", ImmutableMap.of())); try { parseList("//parent/..."); fail(); @@ -821,7 +833,9 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe assertContainsEvent("name 'BROKEN' is not defined"); assertThat(result.first) .containsExactlyElementsIn( - Sets.newHashSet(Label.parseAbsolute("//x/y:a"), Label.parseAbsolute("//x/y:b"))); + Sets.newHashSet( + Label.parseAbsolute("//x/y:a", ImmutableMap.of()), + Label.parseAbsolute("//x/y:b", ImmutableMap.of()))); assertThat(result.second).isFalse(); } @@ -907,7 +921,7 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe "genrule(name='c', outs=['c.out'])"); Pair<Set<Label>, Boolean> result = parseListKeepGoing("//loading:y"); - assertThat(result.first).containsExactly(Label.parseAbsolute("//loading:y")); + assertThat(result.first).containsExactly(Label.parseAbsolute("//loading:y", ImmutableMap.of())); assertContainsEvent("missing value for mandatory attribute"); assertThat(result.second).isFalse(); } @@ -947,8 +961,10 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe .modify(PathFragment.create("h/i/j/BUILD")).build(); invalidate(modifiedFileSet); - assertThat(parseList("//h/...")).containsExactly(Label.parseAbsolute("//h/i/j:j"), - Label.parseAbsolute("//h")); + assertThat(parseList("//h/...")) + .containsExactly( + Label.parseAbsolute("//h/i/j:j", ImmutableMap.of()), + Label.parseAbsolute("//h", ImmutableMap.of())); } @Test @@ -974,7 +990,8 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe invalidate(modifiedFileSet); reporter.addHandler(failFastHandler); Set<Label> nonEmptyResult = parseList("//h/..."); - assertThat(nonEmptyResult).containsExactly(Label.parseAbsolute("//h/i/j/k:l")); + assertThat(nonEmptyResult) + .containsExactly(Label.parseAbsolute("//h/i/j/k:l", ImmutableMap.of())); } @Test @@ -999,8 +1016,10 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe reporter.addHandler(failFastHandler); Set<Label> result = parseList("//t/..."); - assertThat(result).containsExactly(Label.parseAbsolute("//t:t"), - Label.parseAbsolute("//t/u/v:t")); + assertThat(result) + .containsExactly( + Label.parseAbsolute("//t:t", ImmutableMap.of()), + Label.parseAbsolute("//t/u/v:t", ImmutableMap.of())); } @Test @@ -1011,8 +1030,8 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe scratch.file("a/b/BUILD", "filegroup(name='g')"); ResolvedTargets<Target> result = parseTargetPatternList(parser, parsingListener, ImmutableList.of("//a/b/..."), true); - assertThat(targetsToLabels(result.getTargets())).containsExactly( - Label.parseAbsolute("//a/b:g")); + assertThat(targetsToLabels(result.getTargets())) + .containsExactly(Label.parseAbsolute("//a/b:g", ImmutableMap.of())); } @Test @@ -1023,8 +1042,8 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe scratch.file("a/b/BUILD", "filegroup(name='g')"); ResolvedTargets<Target> result = parseTargetPatternList(parser, parsingListener, ImmutableList.of("//a/b/..."), true); - assertThat(targetsToLabels(result.getTargets())).contains( - Label.parseAbsolute("//a/b:g")); + assertThat(targetsToLabels(result.getTargets())) + .contains(Label.parseAbsolute("//a/b:g", ImmutableMap.of())); } @Test @@ -1043,9 +1062,10 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe ac.getChild("symlink").createSymbolicLink(PathFragment.create("../../from-c")); ResolvedTargets<Target> result = parseTargetPatternList(parser, parsingListener, ImmutableList.of("//a/..."), true); - assertThat(targetsToLabels(result.getTargets())).containsExactly( - Label.parseAbsolute("//a/c/symlink:from-c"), - Label.parseAbsolute("//a/b/not-a-symlink:not-a-symlink")); + assertThat(targetsToLabels(result.getTargets())) + .containsExactly( + Label.parseAbsolute("//a/c/symlink:from-c", ImmutableMap.of()), + Label.parseAbsolute("//a/b/not-a-symlink:not-a-symlink", ImmutableMap.of())); } @Test @@ -1057,8 +1077,8 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe d.getChild("c").createSymbolicLink(targetFragment); rootDirectory.getChild("convenience").createSymbolicLink(targetFragment); Set<Label> result = parseList("//..."); - assertThat(result).doesNotContain(Label.parseAbsolute("//convenience:c")); - assertThat(result).doesNotContain(Label.parseAbsolute("//d/c:c")); + assertThat(result).doesNotContain(Label.parseAbsolute("//convenience:c", ImmutableMap.of())); + assertThat(result).doesNotContain(Label.parseAbsolute("//d/c:c", ImmutableMap.of())); } @Test @@ -1069,13 +1089,13 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe @Test public void testTopLevelPackage_Relative_BuildFile() throws Exception { Set<Label> result = parseList("BUILD"); - assertThat(result).containsExactly(Label.parseAbsolute("//:BUILD")); + assertThat(result).containsExactly(Label.parseAbsolute("//:BUILD", ImmutableMap.of())); } @Test public void testTopLevelPackage_Relative_DeclaredTarget() throws Exception { Set<Label> result = parseList("fg"); - assertThat(result).containsExactly(Label.parseAbsolute("//:fg")); + assertThat(result).containsExactly(Label.parseAbsolute("//:fg", ImmutableMap.of())); } @Test @@ -1086,13 +1106,13 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe @Test public void testTopLevelPackage_Relative_ColonAll() throws Exception { Set<Label> result = parseList(":all"); - assertThat(result).containsExactly(Label.parseAbsolute("//:fg")); + assertThat(result).containsExactly(Label.parseAbsolute("//:fg", ImmutableMap.of())); } @Test public void testTopLevelPackage_Relative_InputFile() throws Exception { Set<Label> result = parseList("foo.cc"); - assertThat(result).containsExactly(Label.parseAbsolute("//:foo.cc")); + assertThat(result).containsExactly(Label.parseAbsolute("//:foo.cc", ImmutableMap.of())); } @Test @@ -1103,25 +1123,25 @@ public class TargetPatternEvaluatorTest extends AbstractTargetPatternEvaluatorTe @Test public void testTopLevelPackage_Absolute_BuildFile() throws Exception { Set<Label> result = parseList("//:BUILD"); - assertThat(result).containsExactly(Label.parseAbsolute("//:BUILD")); + assertThat(result).containsExactly(Label.parseAbsolute("//:BUILD", ImmutableMap.of())); } @Test public void testTopLevelPackage_Absolute_DeclaredTarget() throws Exception { Set<Label> result = parseList("//:fg"); - assertThat(result).containsExactly(Label.parseAbsolute("//:fg")); + assertThat(result).containsExactly(Label.parseAbsolute("//:fg", ImmutableMap.of())); } @Test public void testTopLevelPackage_Absolute_All() throws Exception { Set<Label> result = parseList("//:all"); - assertThat(result).containsExactly(Label.parseAbsolute("//:fg")); + assertThat(result).containsExactly(Label.parseAbsolute("//:fg", ImmutableMap.of())); } @Test public void testTopLevelPackage_Absolute_InputFile() throws Exception { Set<Label> result = parseList("//:foo.cc"); - assertThat(result).containsExactly(Label.parseAbsolute("//:foo.cc")); + assertThat(result).containsExactly(Label.parseAbsolute("//:foo.cc", ImmutableMap.of())); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java index e7cd803874..82b9455473 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.android; import static com.google.common.truth.Truth.assertThat; import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; @@ -575,6 +576,8 @@ public class AarImportTest extends BuildViewTestCase { @Test public void testTransitiveExports() throws Exception { assertThat(getConfiguredTarget("//a:bar").get(JavaInfo.PROVIDER).getTransitiveExports()) - .containsExactly(Label.parseAbsolute("//a:foo"), Label.parseAbsolute("//java:baz")); + .containsExactly( + Label.parseAbsolute("//a:foo", ImmutableMap.of()), + Label.parseAbsolute("//java:baz", ImmutableMap.of())); } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java index 4f44f850d1..9e6f5f865b 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java @@ -22,6 +22,7 @@ import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.truth.Truth; @@ -478,9 +479,11 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { ConfiguredTarget target = getConfiguredTarget("//java/com/google/exports:dummy"); List<Label> exports = ImmutableList.copyOf( target.getProvider(JavaExportsProvider.class).getTransitiveExports()); - assertThat(exports).containsExactly(Label.parseAbsolute("//java/com/google/exports:dummy2"), - Label.parseAbsolute("//java/com/google/exports:dummy3"), - Label.parseAbsolute("//java/com/google/exports:dummy4")); + assertThat(exports) + .containsExactly( + Label.parseAbsolute("//java/com/google/exports:dummy2", ImmutableMap.of()), + Label.parseAbsolute("//java/com/google/exports:dummy3", ImmutableMap.of()), + Label.parseAbsolute("//java/com/google/exports:dummy4", ImmutableMap.of())); assertNoEvents(); } @@ -943,22 +946,22 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { Iterables.transform( foo.get(AndroidResourcesInfo.PROVIDER).getTransitiveAndroidResources(), getLabel)) .containsExactly( - Label.parseAbsolute("//java/apps/android:lib"), - Label.parseAbsolute("//java/apps/android:bar")); + Label.parseAbsolute("//java/apps/android:lib", ImmutableMap.of()), + Label.parseAbsolute("//java/apps/android:bar", ImmutableMap.of())); assertThat( Iterables.transform( foo.get(AndroidResourcesInfo.PROVIDER).getDirectAndroidResources(), getLabel)) - .containsExactly(Label.parseAbsolute("//java/apps/android:foo")); + .containsExactly(Label.parseAbsolute("//java/apps/android:foo", ImmutableMap.of())); ConfiguredTarget lib = getConfiguredTarget("//java/apps/android:lib"); assertThat( Iterables.transform( lib.get(AndroidResourcesInfo.PROVIDER).getTransitiveAndroidResources(), getLabel)) - .containsExactly(Label.parseAbsolute("//java/apps/android:bar")); + .containsExactly(Label.parseAbsolute("//java/apps/android:bar", ImmutableMap.of())); assertThat( Iterables.transform( lib.get(AndroidResourcesInfo.PROVIDER).getDirectAndroidResources(), getLabel)) - .containsExactly(Label.parseAbsolute("//java/apps/android:lib")); + .containsExactly(Label.parseAbsolute("//java/apps/android:lib", ImmutableMap.of())); ConfiguredTarget libNeverlink = getConfiguredTarget("//java/apps/android:lib_neverlink"); assertThat(libNeverlink.get(AndroidResourcesInfo.PROVIDER).getTransitiveAndroidResources()) diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java index 85a842f99b..ef53ebd340 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java @@ -17,6 +17,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.actions.SpawnAction; @@ -65,7 +66,7 @@ public class AndroidMultidexBaseTest extends BuildViewTestCase { // Only created in legacy mode: Artifact strippedJar = getFirstArtifactEndingWith(artifacts, "main_dex_intermediate.jar"); Artifact mainDexList = getFirstArtifactEndingWith(artifacts, "main_dex_list.txt"); - String ruleName = Label.parseAbsolute(ruleLabel).getName(); + String ruleName = Label.parseAbsolute(ruleLabel, ImmutableMap.of()).getName(); Artifact mainDexProguardSpec = getFirstArtifactEndingWith( artifacts, "main_dex_" + ruleName + "_proguard.cfg"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagOptionsTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagOptionsTest.java index 2bc8b30f33..a744b6e38d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagOptionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagOptionsTest.java @@ -256,71 +256,88 @@ public final class ConfigFeatureFlagOptionsTest { // Empty with all flags trimmed getOptionsAndTrim(ImmutableMap.of(), ImmutableSet.of()), getOptionsAndTrim( - ImmutableMap.of(Label.parseAbsolute("//a:a"), "a"), ImmutableSet.of()), + ImmutableMap.of(Label.parseAbsolute("//a:a", ImmutableMap.of()), "a"), + ImmutableSet.of()), getOptionsAndTrim( ImmutableMap.of( - Label.parseAbsolute("//a:a"), "a", Label.parseAbsolute("//b:b"), "b"), + Label.parseAbsolute("//a:a", ImmutableMap.of()), + "a", + Label.parseAbsolute("//b:b", ImmutableMap.of()), + "b"), ImmutableSet.of())) .addEqualityGroup( // Only //a:a => a, others default - getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//a:a"), "a")), - getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//a:a"), "a"))) + getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//a:a", ImmutableMap.of()), "a")), + getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//a:a", ImmutableMap.of()), "a"))) .addEqualityGroup( // Error: //a:a is absent - getOptionsAndTrim(ImmutableMap.of(), ImmutableSet.of(Label.parseAbsolute("//a:a"))), getOptionsAndTrim( - ImmutableMap.of(Label.parseAbsolute("//b:b"), "b"), - ImmutableSet.of(Label.parseAbsolute("//a:a")))) + ImmutableMap.of(), + ImmutableSet.of(Label.parseAbsolute("//a:a", ImmutableMap.of()))), + getOptionsAndTrim( + ImmutableMap.of(Label.parseAbsolute("//b:b", ImmutableMap.of()), "b"), + ImmutableSet.of(Label.parseAbsolute("//a:a", ImmutableMap.of())))) .addEqualityGroup( // Only //a:a => a, others trimmed getOptionsAndTrim( - ImmutableMap.of(Label.parseAbsolute("//a:a"), "a"), - ImmutableSet.of(Label.parseAbsolute("//a:a"))), + ImmutableMap.of(Label.parseAbsolute("//a:a", ImmutableMap.of()), "a"), + ImmutableSet.of(Label.parseAbsolute("//a:a", ImmutableMap.of()))), getOptionsAndTrim( ImmutableMap.of( - Label.parseAbsolute("//a:a"), "a", Label.parseAbsolute("//b:b"), "b"), - ImmutableSet.of(Label.parseAbsolute("//a:a")))) + Label.parseAbsolute("//a:a", ImmutableMap.of()), + "a", + Label.parseAbsolute("//b:b", ImmutableMap.of()), + "b"), + ImmutableSet.of(Label.parseAbsolute("//a:a", ImmutableMap.of())))) .addEqualityGroup( // Only //b:b => a, others default - getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//b:b"), "a"))) + getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//b:b", ImmutableMap.of()), "a"))) .addEqualityGroup( // Only //a:a => b, others default - getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//a:a"), "b"))) + getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//a:a", ImmutableMap.of()), "b"))) .addEqualityGroup( // Only //b:b => b, others default - getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//b:b"), "b"))) + getOptionsWith(ImmutableMap.of(Label.parseAbsolute("//b:b", ImmutableMap.of()), "b"))) .addEqualityGroup( // //a:a => b and //b:b => a, others default (order doesn't matter) getOptionsWith( ImmutableMap.of( - Label.parseAbsolute("//a:a"), "b", - Label.parseAbsolute("//b:b"), "a")), + Label.parseAbsolute("//a:a", ImmutableMap.of()), "b", + Label.parseAbsolute("//b:b", ImmutableMap.of()), "a")), getOptionsWith( ImmutableMap.of( - Label.parseAbsolute("//b:b"), "a", - Label.parseAbsolute("//a:a"), "b"))) + Label.parseAbsolute("//b:b", ImmutableMap.of()), "a", + Label.parseAbsolute("//a:a", ImmutableMap.of()), "b"))) .addEqualityGroup( // //a:a => b and //b:b => a, others trimmed (order doesn't matter) getOptionsAndTrim( ImmutableMap.of( - Label.parseAbsolute("//a:a"), "b", - Label.parseAbsolute("//b:b"), "a"), - ImmutableSet.of(Label.parseAbsolute("//a:a"), Label.parseAbsolute("//b:b"))), + Label.parseAbsolute("//a:a", ImmutableMap.of()), "b", + Label.parseAbsolute("//b:b", ImmutableMap.of()), "a"), + ImmutableSet.of( + Label.parseAbsolute("//a:a", ImmutableMap.of()), + Label.parseAbsolute("//b:b", ImmutableMap.of()))), getOptionsAndTrim( ImmutableMap.of( - Label.parseAbsolute("//a:a"), "b", - Label.parseAbsolute("//b:b"), "a"), - ImmutableSet.of(Label.parseAbsolute("//b:b"), Label.parseAbsolute("//a:a"))), + Label.parseAbsolute("//a:a", ImmutableMap.of()), "b", + Label.parseAbsolute("//b:b", ImmutableMap.of()), "a"), + ImmutableSet.of( + Label.parseAbsolute("//b:b", ImmutableMap.of()), + Label.parseAbsolute("//a:a", ImmutableMap.of()))), getOptionsAndTrim( ImmutableMap.of( - Label.parseAbsolute("//b:b"), "a", - Label.parseAbsolute("//a:a"), "b"), - ImmutableSet.of(Label.parseAbsolute("//a:a"), Label.parseAbsolute("//b:b"))), + Label.parseAbsolute("//b:b", ImmutableMap.of()), "a", + Label.parseAbsolute("//a:a", ImmutableMap.of()), "b"), + ImmutableSet.of( + Label.parseAbsolute("//a:a", ImmutableMap.of()), + Label.parseAbsolute("//b:b", ImmutableMap.of()))), getOptionsAndTrim( ImmutableMap.of( - Label.parseAbsolute("//b:b"), "a", - Label.parseAbsolute("//a:a"), "b"), - ImmutableSet.of(Label.parseAbsolute("//b:b"), Label.parseAbsolute("//a:a")))) + Label.parseAbsolute("//b:b", ImmutableMap.of()), "a", + Label.parseAbsolute("//a:a", ImmutableMap.of()), "b"), + ImmutableSet.of( + Label.parseAbsolute("//b:b", ImmutableMap.of()), + Label.parseAbsolute("//a:a", ImmutableMap.of())))) .testEquals(); } @@ -341,7 +358,7 @@ public final class ConfigFeatureFlagOptionsTest { public void parser_doesNotAllowFlagValuesToBeParsed() throws Exception { ConfigFeatureFlagOptions options = Options.getDefaults(ConfigFeatureFlagOptions.class); ImmutableSortedMap<Label, String> testValue = - ImmutableSortedMap.of(Label.parseAbsolute("//what:heck"), "something"); + ImmutableSortedMap.of(Label.parseAbsolute("//what:heck", ImmutableMap.of()), "something"); options.flagValues = testValue; String flagValuesOption = options @@ -363,7 +380,8 @@ public final class ConfigFeatureFlagOptionsTest { @Test public void parser_doesNotAllowKnownDefaultValuesToBeParsed() throws Exception { ConfigFeatureFlagOptions options = Options.getDefaults(ConfigFeatureFlagOptions.class); - ImmutableSortedSet<Label> testValue = ImmutableSortedSet.of(Label.parseAbsolute("//what:heck")); + ImmutableSortedSet<Label> testValue = + ImmutableSortedSet.of(Label.parseAbsolute("//what:heck", ImmutableMap.of())); options.knownDefaultFlags = testValue; String defaultValuesOption = options @@ -385,7 +403,8 @@ public final class ConfigFeatureFlagOptionsTest { @Test public void parser_doesNotAllowUnknownValuesToBeParsed() throws Exception { ConfigFeatureFlagOptions options = Options.getDefaults(ConfigFeatureFlagOptions.class); - ImmutableSortedSet<Label> testValue = ImmutableSortedSet.of(Label.parseAbsolute("//what:heck")); + ImmutableSortedSet<Label> testValue = + ImmutableSortedSet.of(Label.parseAbsolute("//what:heck", ImmutableMap.of())); options.unknownFlags = testValue; String unknownFlagsOption = options diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagTransitionFactoryTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagTransitionFactoryTest.java index 1899d32dbb..362b898a8d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagTransitionFactoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagTransitionFactoryTest.java @@ -120,7 +120,8 @@ public final class ConfigFeatureFlagTransitionFactoryTest extends BuildViewTestC Rule rule = scratchRule("a", "empty", "feature_flag_setter(name = 'empty', flag_values = {})"); PatchTransition transition = new ConfigFeatureFlagTransitionFactory("flag_values").buildTransitionFor(rule); - Map<Label, String> originalFlagMap = ImmutableMap.of(Label.parseAbsolute("//a:flag"), "value"); + Map<Label, String> originalFlagMap = + ImmutableMap.of(Label.parseAbsolute("//a:flag", ImmutableMap.of()), "value"); BuildOptions original = getOptionsWithFlagFragment(originalFlagMap); BuildOptions converted = transition.patch(original); @@ -147,8 +148,10 @@ public final class ConfigFeatureFlagTransitionFactoryTest extends BuildViewTestC " default_value = 'a')"); PatchTransition transition = new ConfigFeatureFlagTransitionFactory("flag_values").buildTransitionFor(rule); - Map<Label, String> originalFlagMap = ImmutableMap.of(Label.parseAbsolute("//a:old"), "value"); - Map<Label, String> expectedFlagMap = ImmutableMap.of(Label.parseAbsolute("//a:flag"), "a"); + Map<Label, String> originalFlagMap = + ImmutableMap.of(Label.parseAbsolute("//a:old", ImmutableMap.of()), "value"); + Map<Label, String> expectedFlagMap = + ImmutableMap.of(Label.parseAbsolute("//a:flag", ImmutableMap.of()), "a"); BuildOptions original = getOptionsWithFlagFragment(originalFlagMap); BuildOptions converted = transition.patch(original); diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java index 46042fdce3..00737cb31b 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java @@ -177,7 +177,7 @@ public class ConfigSettingTest extends BuildViewTestCase { public void labelGetter() throws Exception { writeSimpleExample(); assertThat(getConfigMatchingProvider("//pkg:foo").label()) - .isEqualTo(Label.parseAbsolute("//pkg:foo")); + .isEqualTo(Label.parseAbsolute("//pkg:foo", ImmutableMap.of())); } /** diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/FeatureFlagManualTrimmingTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/FeatureFlagManualTrimmingTest.java index a89c44e5dd..d03118c5e1 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/config/FeatureFlagManualTrimmingTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/config/FeatureFlagManualTrimmingTest.java @@ -18,6 +18,7 @@ import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap; import static com.google.common.truth.Truth.assertThat; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Iterables; import com.google.common.collect.Ordering; @@ -184,7 +185,7 @@ public final class FeatureFlagManualTrimmingTest extends SkylarkTestCase { Artifact targetFlags = Iterables.getOnlyElement(getFilesToBuild(getConfiguredTarget("//test:target")).toList()); - Label usedFlag = Label.parseAbsolute("//test:used_flag"); + Label usedFlag = Label.parseAbsolute("//test:used_flag", ImmutableMap.of()); assertThat(getFlagValuesFromOutputFile(targetFlags)).containsEntry(usedFlag, "configured"); } @@ -269,7 +270,7 @@ public final class FeatureFlagManualTrimmingTest extends SkylarkTestCase { Artifact targetFlags = Iterables.getOnlyElement(getFilesToBuild(getConfiguredTarget("//test:target")).toList()); - Label usedFlag = Label.parseAbsolute("//test:used_flag"); + Label usedFlag = Label.parseAbsolute("//test:used_flag", ImmutableMap.of()); assertThat(getFlagValuesFromOutputFile(targetFlags)).containsEntry(usedFlag, "default"); } @@ -642,7 +643,7 @@ public final class FeatureFlagManualTrimmingTest extends SkylarkTestCase { Artifact targetFlags = Iterables.getOnlyElement(getFilesToBuild(getConfiguredTarget("//test:target")).toList()); - Label usedFlag = Label.parseAbsolute("//test:used_flag"); + Label usedFlag = Label.parseAbsolute("//test:used_flag", ImmutableMap.of()); assertThat(getFlagValuesFromOutputFile(targetFlags)).containsEntry(usedFlag, "default"); } @@ -714,7 +715,7 @@ public final class FeatureFlagManualTrimmingTest extends SkylarkTestCase { Artifact targetFlags = Iterables.getOnlyElement(getFilesToBuild(getConfiguredTarget("//test:reader")).toList()); - Label usedFlag = Label.parseAbsolute("//test:used_flag"); + Label usedFlag = Label.parseAbsolute("//test:used_flag", ImmutableMap.of()); assertThat(getFlagValuesFromOutputFile(targetFlags)).containsEntry(usedFlag, "default"); } @@ -764,7 +765,7 @@ public final class FeatureFlagManualTrimmingTest extends SkylarkTestCase { Artifact targetFlags = Iterables.getOnlyElement(getFilesToBuild(getConfiguredTarget("//test:toplevel")).toList()); - Label usedFlag = Label.parseAbsolute("//test:used_flag"); + Label usedFlag = Label.parseAbsolute("//test:used_flag", ImmutableMap.of()); assertThat(getFlagValuesFromOutputFile(targetFlags)).containsEntry(usedFlag, "configured"); } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java index 18f661b953..49b14ea565 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java @@ -574,7 +574,7 @@ public class CcCommonTest extends BuildViewTestCase { "cc_library(name = 'lib',", " srcs = ['foo.cc'],", " includes = ['./'])"); - Label label = Label.parseAbsolute("@pkg//bar:lib"); + Label label = Label.parseAbsolute("@pkg//bar:lib", ImmutableMap.of()); ConfiguredTarget target = view.getConfiguredTargetForTesting(reporter, label, targetConfig); assertThat(view.hasErrors(target)).isFalse(); assertNoEvents(); diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java index 2f72860c2b..75071f359b 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java @@ -17,6 +17,7 @@ package com.google.devtools.build.lib.rules.cpp; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; @@ -67,7 +68,7 @@ public class CcToolchainSelectionTest extends BuildViewTestCase { (CcToolchainProvider) getRuleContext(target) .getToolchainContext() - .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); + .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE, ImmutableMap.of())); assertThat(Iterables.getOnlyElement(toolchain.getCompile()).getExecPathString()) .endsWith("piii"); } @@ -103,7 +104,7 @@ public class CcToolchainSelectionTest extends BuildViewTestCase { (CcToolchainProvider) getRuleContext(target) .getToolchainContext() - .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); + .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE, ImmutableMap.of())); assertThat(toolchain.getToolchainIdentifier()).endsWith("piii"); } @@ -164,7 +165,7 @@ public class CcToolchainSelectionTest extends BuildViewTestCase { (CcToolchainProvider) getRuleContext(target) .getToolchainContext() - .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); + .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE, ImmutableMap.of())); assertThat(toolchain.getToolPathFragment(CppConfiguration.Tool.LD).toString()) .contains("piii-ld"); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoSkylarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoSkylarkApiTest.java index 6fcd099d7d..55229e8f0a 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoSkylarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoSkylarkApiTest.java @@ -17,6 +17,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.prettyArtifactNames; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Streams; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; @@ -506,9 +507,8 @@ public class JavaInfoSkylarkApiTest extends BuildViewTestCase { JavaExportsProvider exportsProvider = javaInfo.getProvider(JavaExportsProvider.class); - assertThat( - exportsProvider.getTransitiveExports()) - .containsExactly(Label.parseAbsolute("//foo:my_java_lib_b")); + assertThat(exportsProvider.getTransitiveExports()) + .containsExactly(Label.parseAbsolute("//foo:my_java_lib_b", ImmutableMap.of())); JavaCompilationArgsProvider javaCompilationArgsProvider = javaInfo.getProvider(JavaCompilationArgsProvider.class); @@ -577,9 +577,8 @@ public class JavaInfoSkylarkApiTest extends BuildViewTestCase { JavaExportsProvider exportsProvider = javaInfo.getProvider(JavaExportsProvider.class); - assertThat( - exportsProvider.getTransitiveExports()) - .containsExactly(Label.parseAbsolute("//foo:my_java_lib_b")); + assertThat(exportsProvider.getTransitiveExports()) + .containsExactly(Label.parseAbsolute("//foo:my_java_lib_b", ImmutableMap.of())); JavaCompilationArgsProvider javaCompilationArgsProvider = javaInfo.getProvider(JavaCompilationArgsProvider.class); @@ -879,7 +878,9 @@ public class JavaInfoSkylarkApiTest extends BuildViewTestCase { private JavaInfo fetchJavaInfo() throws Exception { ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); Info info = - myRuleTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); @SuppressWarnings("unchecked") JavaInfo javaInfo = (JavaInfo) info.getValue("property"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoTest.java index 58cbf5f7cd..c1c44d7567 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoTest.java @@ -17,6 +17,7 @@ package com.google.devtools.build.lib.rules.java; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.collect.nestedset.NestedSet; @@ -73,11 +74,11 @@ public class JavaInfoTest { assertThat(labels) .containsExactly( - Label.parseAbsolute("//foo:foo0.bzl"), - Label.parseAbsolute("//foo:foo1.bzl"), - Label.parseAbsolute("//bar:bar0.bzl"), - Label.parseAbsolute("//bar:bar1.bzl"), - Label.parseAbsolute("//bar:bar2.bzl")) + Label.parseAbsolute("//foo:foo0.bzl", ImmutableMap.of()), + Label.parseAbsolute("//foo:foo1.bzl", ImmutableMap.of()), + Label.parseAbsolute("//bar:bar0.bzl", ImmutableMap.of()), + Label.parseAbsolute("//bar:bar1.bzl", ImmutableMap.of()), + Label.parseAbsolute("//bar:bar2.bzl", ImmutableMap.of())) .inOrder(); } @@ -86,7 +87,7 @@ public class JavaInfoTest { NestedSetBuilder<Label> builder = NestedSetBuilder.stableOrder(); for (int i = 0; i < count; i++) { String absName = String.format("//%s:%s%d.bzl", prefix, prefix, i); - Label label = Label.parseAbsolute(absName); + Label label = Label.parseAbsolute(absName, ImmutableMap.of()); builder.add(label); } // TODO(dbabkin): refactor to use NestedSetCollector whe it will be ready. return new JavaExportsProvider(builder.build()); diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java index 47036d774c..c5956c0021 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.java; import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.prettyArtifactNames; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; @@ -198,7 +199,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { ConfiguredTarget configuredTarget = getConfiguredTarget("//java/test:my"); Info info = configuredTarget.get( - new SkylarkKey(Label.parseAbsolute("//java/test:extension.bzl"), "result")); + new SkylarkKey( + Label.parseAbsolute("//java/test:extension.bzl", ImmutableMap.of()), "result")); SkylarkNestedSet transitiveRuntimeJars = ((SkylarkNestedSet) info.getValue("transitive_runtime_jars")); @@ -295,7 +297,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { ConfiguredTarget configuredTarget = getConfiguredTarget("//java/test:my"); Info info = configuredTarget.get( - new SkylarkKey(Label.parseAbsolute("//java/test:extension.bzl"), "result")); + new SkylarkKey( + Label.parseAbsolute("//java/test:extension.bzl", ImmutableMap.of()), "result")); JavaRuleOutputJarsProvider outputs = ((JavaRuleOutputJarsProvider) info.getValue("outputs")); assertThat(outputs.getOutputJars()).hasSize(1); @@ -717,7 +720,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { ConfiguredTarget configuredTarget = getConfiguredTarget("//java/test:my"); Info info = configuredTarget.get( - new SkylarkKey(Label.parseAbsolute("//java/test:extension.bzl"), "result")); + new SkylarkKey( + Label.parseAbsolute("//java/test:extension.bzl", ImmutableMap.of()), "result")); SkylarkNestedSet sourceJars = ((SkylarkNestedSet) info.getValue("source_jars")); SkylarkNestedSet transitiveDeps = ((SkylarkNestedSet) info.getValue("transitive_deps")); @@ -815,7 +819,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { ConfiguredTarget configuredTarget = getConfiguredTarget("//java/test:my"); Info info = configuredTarget.get( - new SkylarkKey(Label.parseAbsolute("//java/test:extension.bzl"), "result")); + new SkylarkKey( + Label.parseAbsolute("//java/test:extension.bzl", ImmutableMap.of()), "result")); assertThat(info.getValue("enabled")).isEqualTo(Boolean.TRUE); assertThat(info.getValue("class_jar")).isNotNull(); @@ -874,7 +879,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { // Extract out the information from skylark rule Info info = myConfiguredTarget.get( - new SkylarkKey(Label.parseAbsolute("//java/test:extension.bzl"), "result")); + new SkylarkKey( + Label.parseAbsolute("//java/test:extension.bzl", ImmutableMap.of()), "result")); SkylarkNestedSet rawMyCompileJars = (SkylarkNestedSet) (info.getValue("compile_jars")); SkylarkNestedSet rawMyTransitiveRuntimeJars = @@ -1164,7 +1170,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:r"); ConfiguredTarget javaLibraryTarget = getConfiguredTarget("//foo:jl"); SkylarkKey myProviderKey = - new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "my_provider"); + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "my_provider"); Info declaredProvider = myRuleTarget.get(myProviderKey); Object javaProvider = declaredProvider.getValue("p"); assertThat(javaProvider).isInstanceOf(JavaInfo.class); @@ -1314,8 +1321,10 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { "my_rule(name = 'my_skylark_rule', dep = ':my_java_lib_a')"); assertNoEvents(); ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); - Info info = myRuleTarget.get( - new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + Info info = + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); @SuppressWarnings("unchecked") SkylarkList<Artifact> sourceJars = (SkylarkList<Artifact>) (info.getValue("source_jars")); assertThat(prettyArtifactNames(sourceJars)).containsExactly("foo/libmy_java_lib_a-src.jar"); @@ -1342,7 +1351,9 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { assertNoEvents(); ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); Info info = - myRuleTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); @SuppressWarnings("unchecked") SkylarkNestedSet sourceJars = (SkylarkNestedSet) info.getValue("property"); @@ -1373,7 +1384,9 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { assertNoEvents(); ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); Info info = - myRuleTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); @SuppressWarnings("unchecked") SkylarkNestedSet sourceJars = (SkylarkNestedSet) info.getValue("property"); @@ -1404,7 +1417,9 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { assertNoEvents(); ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); Info info = - myRuleTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); @SuppressWarnings("unchecked") SkylarkNestedSet sourceJars = (SkylarkNestedSet) info.getValue("property"); @@ -1435,14 +1450,16 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { "my_rule(name = 'my_skylark_rule', dep = ':my_java_lib_a')"); assertNoEvents(); ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); - Info info = myRuleTarget.get( - new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + Info info = + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); @SuppressWarnings("unchecked") SkylarkNestedSet exports = (SkylarkNestedSet) (info.getValue("property")); assertThat(exports.getSet(Label.class)) - .containsExactly(Label.parseAbsolute("//foo:my_java_lib_b")); + .containsExactly(Label.parseAbsolute("//foo:my_java_lib_b", ImmutableMap.of())); } @@ -1463,8 +1480,10 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { "my_rule(name = 'my_skylark_rule', dep = ':my_java_lib_a')"); assertNoEvents(); ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); - Info info = myRuleTarget.get( - new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + Info info = + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); JavaGenJarsProvider javaGenJarsProvider = (JavaGenJarsProvider) info.getValue("property"); @@ -1491,8 +1510,10 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { "my_rule(name = 'my_skylark_rule', dep = ':my_java_lib_a')"); assertNoEvents(); ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_skylark_rule"); - Info info = myRuleTarget.get( - new SkylarkKey(Label.parseAbsolute("//foo:extension.bzl"), "result")); + Info info = + myRuleTarget.get( + new SkylarkKey( + Label.parseAbsolute("//foo:extension.bzl", ImmutableMap.of()), "result")); JavaCompilationInfoProvider javaCompilationInfoProvider = (JavaCompilationInfoProvider) info.getValue("property"); @@ -1649,7 +1670,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { ); ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:myrule"); Info info = - configuredTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl"), "result")); + configuredTarget.get( + new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl", ImmutableMap.of()), "result")); assertThat(((String) info.getValue("strict_java_deps"))).isEqualTo("default"); } @@ -1673,7 +1695,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { useConfiguration("--strict_java_deps=ERROR"); ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:myrule"); Info info = - configuredTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl"), "result")); + configuredTarget.get( + new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl", ImmutableMap.of()), "result")); assertThat(((String) info.getValue("strict_java_deps"))).isEqualTo("error"); } @@ -1699,7 +1722,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { ); ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:myrule"); Info info = - configuredTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl"), "result")); + configuredTarget.get( + new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl", ImmutableMap.of()), "result")); Label javaToolchainLabel = ((Label) info.getValue("java_toolchain_label")); assertThat(javaToolchainLabel.toString()).endsWith("jdk:toolchain"); } @@ -1727,7 +1751,8 @@ public class JavaSkylarkApiTest extends BuildViewTestCase { useConfiguration("--java_toolchain=//java/com/google/test:toolchain"); ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:myrule"); Info info = - configuredTarget.get(new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl"), "result")); + configuredTarget.get( + new SkylarkKey(Label.parseAbsolute("//foo:rule.bzl", ImmutableMap.of()), "result")); Label javaToolchainLabel = ((Label) info.getValue("java_toolchain_label")); assertThat(javaToolchainLabel.toString()).isEqualTo("//java/com/google/test:toolchain"); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java index 8983ccaa56..f617673885 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java @@ -380,7 +380,7 @@ public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { String objFileName, Iterable<String> compilationInputExecPaths) throws Exception { - String labelName = Label.parseAbsolute(targetLabel).getName(); + String labelName = Label.parseAbsolute(targetLabel, ImmutableMap.of()).getName(); CommandAction linkAction = (CommandAction) getGeneratingAction( diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/J2ObjcSourceTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/J2ObjcSourceTest.java index 0486cd309f..1304d647ba 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/J2ObjcSourceTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/J2ObjcSourceTest.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.rules.objc; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.testing.EqualsTester; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactRoot; @@ -61,7 +62,7 @@ public class J2ObjcSourceTest { private J2ObjcSource getJ2ObjcSource(String label, String fileName, J2ObjcSource.SourceType sourceType) throws Exception { - Label ruleLabel = Label.parseAbsolute(label); + Label ruleLabel = Label.parseAbsolute(label, ImmutableMap.of()); PathFragment path = ruleLabel.toPathFragment(); return new J2ObjcSource( ruleLabel, diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java index 5d2eed5d9c..689bbb5ad9 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java @@ -17,6 +17,7 @@ package com.google.devtools.build.lib.rules.objc; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.CommandAction; @@ -118,7 +119,8 @@ public class ObjcBuildVariablesTest extends LinkBuildVariablesTestCase { // actions, follow the chain of actions starting at the lipobin // creation. Artifact lipoBin = - getBinArtifact(Label.parseAbsolute("//x:bin").getName() + "_lipobin", target); + getBinArtifact( + Label.parseAbsolute("//x:bin", ImmutableMap.of()).getName() + "_lipobin", target); Action lipoAction = getGeneratingAction(lipoBin); Artifact bin = ActionsTestUtil.getFirstArtifactEndingWith(lipoAction.getInputs(), "_bin"); CommandAction appleBinLinkAction = (CommandAction) getGeneratingAction(bin); @@ -166,7 +168,8 @@ public class ObjcBuildVariablesTest extends LinkBuildVariablesTestCase { // In order to get the set of variables that apply to the c++ actions, follow the chain of // actions starting at the lipobin creation. Artifact lipoBin = - getBinArtifact(Label.parseAbsolute("//x:bin").getName() + "_lipobin", target); + getBinArtifact( + Label.parseAbsolute("//x:bin", ImmutableMap.of()).getName() + "_lipobin", target); Action lipoAction = getGeneratingAction(lipoBin); Artifact bin = ActionsTestUtil.getFirstArtifactEndingWith(lipoAction.getInputs(), "_bin"); CommandAction appleBinLinkAction = (CommandAction) getGeneratingAction(bin); @@ -231,7 +234,8 @@ public class ObjcBuildVariablesTest extends LinkBuildVariablesTestCase { // In order to get the set of variables that apply to the c++ actions, follow the chain of // actions starting at the lipobin creation. Artifact lipoBin = - getBinArtifact(Label.parseAbsolute("//x:bin").getName() + "_lipobin", target); + getBinArtifact( + Label.parseAbsolute("//x:bin", ImmutableMap.of()).getName() + "_lipobin", target); Action lipoAction = getGeneratingAction(lipoBin); Artifact bin = ActionsTestUtil.getFirstArtifactEndingWith(lipoAction.getInputs(), "_bin"); CommandAction appleBinLinkAction = (CommandAction) getGeneratingAction(bin); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java index 68e3b0ae58..4227116991 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java @@ -31,6 +31,7 @@ import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Action; @@ -910,7 +911,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { protected Action actionProducingArtifact(String targetLabel, String artifactSuffix) throws Exception { ConfiguredTarget libraryTarget = getConfiguredTarget(targetLabel); - Label parsedLabel = Label.parseAbsolute(targetLabel); + Label parsedLabel = Label.parseAbsolute(targetLabel, ImmutableMap.of()); Artifact linkedLibrary = getBinArtifact( parsedLabel.getName() + artifactSuffix, libraryTarget); @@ -1398,7 +1399,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { } private BinaryFileWriteAction plMergeAction(String binaryLabelString) throws Exception { - Label binaryLabel = Label.parseAbsolute(binaryLabelString); + Label binaryLabel = Label.parseAbsolute(binaryLabelString, ImmutableMap.of()); ConfiguredTarget binary = getConfiguredTarget(binaryLabelString); return (BinaryFileWriteAction) getGeneratingAction(getBinArtifact(binaryLabel.getName() diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java b/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java index 200d9f7ebf..a6f0cda13e 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.platform; import static com.google.common.truth.Truth.assertThat; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; @@ -49,19 +50,19 @@ public class ConstraintTest extends BuildViewTestCase { assertThat(PlatformProviderUtils.constraintSetting(setting)).isNotNull(); assertThat(PlatformProviderUtils.constraintSetting(setting)).isNotNull(); assertThat(PlatformProviderUtils.constraintSetting(setting).label()) - .isEqualTo(Label.parseAbsolute("//constraint:basic")); + .isEqualTo(Label.parseAbsolute("//constraint:basic", ImmutableMap.of())); ConfiguredTarget fooValue = getConfiguredTarget("//constraint:foo"); assertThat(fooValue).isNotNull(); assertThat(PlatformProviderUtils.constraintValue(fooValue)).isNotNull(); assertThat(PlatformProviderUtils.constraintValue(fooValue).constraint().label()) - .isEqualTo(Label.parseAbsolute("//constraint:basic")); + .isEqualTo(Label.parseAbsolute("//constraint:basic", ImmutableMap.of())); assertThat(PlatformProviderUtils.constraintValue(fooValue).label()) - .isEqualTo(Label.parseAbsolute("//constraint:foo")); + .isEqualTo(Label.parseAbsolute("//constraint:foo", ImmutableMap.of())); ConfiguredTarget barValue = getConfiguredTarget("//constraint:bar"); assertThat(barValue).isNotNull(); assertThat(PlatformProviderUtils.constraintValue(barValue).constraint().label()) - .isEqualTo(Label.parseAbsolute("//constraint:basic")); + .isEqualTo(Label.parseAbsolute("//constraint:basic", ImmutableMap.of())); assertThat(PlatformProviderUtils.constraintValue(barValue).label()) - .isEqualTo(Label.parseAbsolute("//constraint:bar")); + .isEqualTo(Label.parseAbsolute("//constraint:bar", ImmutableMap.of())); } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/proto/ProtoLangToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/proto/ProtoLangToolchainTest.java index 262cb7de5d..e11d2d6b54 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/proto/ProtoLangToolchainTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/proto/ProtoLangToolchainTest.java @@ -18,11 +18,11 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.prettyArtifactNames; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.eventbus.EventBus; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.cmdline.Label; - import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -58,7 +58,8 @@ public class ProtoLangToolchainTest extends BuildViewTestCase { .isEqualTo("x/plugin"); TransitiveInfoCollection runtimes = toolchain.runtime(); - assertThat(runtimes.getLabel()).isEqualTo(Label.parseAbsolute("//x:runtime")); + assertThat(runtimes.getLabel()) + .isEqualTo(Label.parseAbsolute("//x:runtime", ImmutableMap.of())); assertThat(prettyArtifactNames(toolchain.blacklistedProtos())) .containsExactly("x/metadata.proto", "x/descriptor.proto", "x/any.proto"); diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java index 64244a5787..bf20766a6c 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.when; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.ActionCompletionEvent; @@ -335,7 +336,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { ManualClock clock = new ManualClock(); ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock); TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class); - Label labelA = Label.parseAbsolute("//foo/bar:baz"); + Label labelA = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); ConfiguredTarget targetA = Mockito.mock(ConfiguredTarget.class); when(targetA.getLabel()).thenReturn(labelA); ConfiguredTarget targetB = Mockito.mock(ConfiguredTarget.class); @@ -368,7 +369,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { ManualClock clock = new ManualClock(); ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock); TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class); - Label labelA = Label.parseAbsolute("//foo/bar:baz"); + Label labelA = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); ConfiguredTarget targetA = Mockito.mock(ConfiguredTarget.class); when(targetA.getLabel()).thenReturn(labelA); ConfiguredTarget targetB = Mockito.mock(ConfiguredTarget.class); @@ -399,7 +400,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { ManualClock clock = new ManualClock(); ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock); TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class); - Label labelA = Label.parseAbsolute("//foo/bar:baz"); + Label labelA = Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of()); ConfiguredTarget targetA = Mockito.mock(ConfiguredTarget.class); when(targetA.getLabel()).thenReturn(labelA); ConfiguredTarget targetB = Mockito.mock(ConfiguredTarget.class); @@ -434,7 +435,8 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { "Building some/very/very/long/path/for/some/library/directory/foo.jar (42 source files)", "some/very/very/long/path/for/some/library/directory/foo.jar"); Label label = - Label.parseAbsolute("//some/very/very/long/path/for/some/library/directory:libfoo"); + Label.parseAbsolute( + "//some/very/very/long/path/for/some/library/directory:libfoo", ImmutableMap.of()); ActionOwner owner = ActionOwner.create( label, @@ -509,7 +511,8 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { Label bartestLabel = Label.parseAbsolute( - "//src/another/very/long/long/path/long/long/long/long/long/long/long/long/bars:bartest"); + "//src/another/very/long/long/path/long/long/long/long/long/long/long/long/bars:bartest", + ImmutableMap.of()); ConfiguredTarget bartestTarget = Mockito.mock(ConfiguredTarget.class); when(bartestTarget.getLabel()).thenReturn(bartestLabel); @@ -772,7 +775,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { clock.advanceMillis(TimeUnit.SECONDS.toMillis(1234)); ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock, 80); - Label labelFooTest = Label.parseAbsolute("//foo/bar:footest"); + Label labelFooTest = Label.parseAbsolute("//foo/bar:footest", ImmutableMap.of()); ConfiguredTarget targetFooTest = Mockito.mock(ConfiguredTarget.class); when(targetFooTest.getLabel()).thenReturn(labelFooTest); ActionOwner fooOwner = @@ -787,7 +790,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { null, null); - Label labelBarTest = Label.parseAbsolute("//baz:bartest"); + Label labelBarTest = Label.parseAbsolute("//baz:bartest", ImmutableMap.of()); ConfiguredTarget targetBarTest = Mockito.mock(ConfiguredTarget.class); when(targetBarTest.getLabel()).thenReturn(labelBarTest); TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java index df0320f16d..fafe4b7717 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java @@ -215,7 +215,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase { } private static Label label(String label) throws Exception { - return Label.parseAbsolute(label); + return Label.parseAbsolute(label, ImmutableMap.of()); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java index b6681d023f..3d9971d15d 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java @@ -448,8 +448,10 @@ public class PackageFunctionTest extends BuildViewTestCase { SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo")); PackageValue value = validPackage(skyKey); - assertThat(value.getPackage().getSkylarkFileDependencies()).containsExactly( - Label.parseAbsolute("//bar:ext.bzl"), Label.parseAbsolute("//baz:ext.bzl")); + assertThat(value.getPackage().getSkylarkFileDependencies()) + .containsExactly( + Label.parseAbsolute("//bar:ext.bzl", ImmutableMap.of()), + Label.parseAbsolute("//baz:ext.bzl", ImmutableMap.of())); scratch.overwriteFile("bar/ext.bzl", "load('//qux:ext.bzl', 'c')", @@ -461,8 +463,10 @@ public class PackageFunctionTest extends BuildViewTestCase { Root.fromPath(rootDirectory)); value = validPackage(skyKey); - assertThat(value.getPackage().getSkylarkFileDependencies()).containsExactly( - Label.parseAbsolute("//bar:ext.bzl"), Label.parseAbsolute("//qux:ext.bzl")); + assertThat(value.getPackage().getSkylarkFileDependencies()) + .containsExactly( + Label.parseAbsolute("//bar:ext.bzl", ImmutableMap.of()), + Label.parseAbsolute("//qux:ext.bzl", ImmutableMap.of())); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java index 7423652698..985cb9cb96 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.skyframe; import static com.google.common.truth.Truth.assertThat; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.platform.ToolchainInfo; import com.google.devtools.build.lib.cmdline.Label; @@ -36,12 +37,12 @@ public class RuleContextTest extends ToolchainTestCase { "--platforms=//platforms:mac"); RuleContext ruleContext = getRuleContext(getConfiguredTarget("//x")); assertThat(ruleContext.getToolchainContext().resolvedToolchainLabels()) - .contains(Label.parseAbsolute("//toolchain:toolchain_1_impl")); + .contains(Label.parseAbsolute("//toolchain:toolchain_1_impl", ImmutableMap.of())); ToolchainInfo toolchain = ruleContext .getToolchainContext() - .forToolchainType(Label.parseAbsolute("//toolchain:test_toolchain")); + .forToolchainType(Label.parseAbsolute("//toolchain:test_toolchain", ImmutableMap.of())); assertThat(toolchain.getValue("data")).isEqualTo("foo"); } } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java index b13b87910b..eb43635135 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java @@ -492,7 +492,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase { } }; fs.stubStat(bazDir, inconsistentParentFileStatus); - Set<Label> labels = ImmutableSet.of(Label.parseAbsolute("//foo:foo")); + Set<Label> labels = ImmutableSet.of(Label.parseAbsolute("//foo:foo", ImmutableMap.of())); getSkyframeExecutor() .getPackageManager() .newTransitiveLoader() diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java index 90843718d7..fae9d22012 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java @@ -19,6 +19,7 @@ import static com.google.devtools.build.skyframe.WalkableGraphUtils.exists; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -228,7 +229,7 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas throws LabelSyntaxException, NoSuchThingException, InterruptedException { Set<Target> targets = new HashSet<>(); for (String strLabel : strLabels) { - Label label = Label.parseAbsolute(strLabel); + Label label = Label.parseAbsolute(strLabel, ImmutableMap.of()); targets.add(getSkyframeExecutor().getPackageManager().getTarget(reporter, label)); } return targets; diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java index 75a4888cc1..6778dc8862 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.skyframe; import static com.google.common.truth.Truth.assertThat; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.clock.BlazeClock; @@ -63,12 +64,12 @@ public class TargetMarkerFunctionTest extends BuildViewTestCase { } private SkyKey skyKey(String labelName) throws Exception { - return TargetMarkerValue.key(Label.parseAbsolute(labelName)); + return TargetMarkerValue.key(Label.parseAbsolute(labelName, ImmutableMap.of())); } private Throwable getErrorFromTargetValue(String labelName) throws Exception { reporter.removeHandler(failFastHandler); - SkyKey targetKey = TargetMarkerValue.key(Label.parseAbsolute(labelName)); + SkyKey targetKey = TargetMarkerValue.key(Label.parseAbsolute(labelName, ImmutableMap.of())); EvaluationResult<TargetMarkerValue> evaluationResult = SkyframeExecutorTestUtils.evaluate( skyframeExecutor, targetKey, /*keepGoing=*/ false, reporter); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java index 7749f9e9ff..f3389712eb 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java @@ -43,7 +43,7 @@ public class TransitiveTraversalFunctionTest extends BuildViewTestCase { @Test public void noRepeatedLabelVisitationForTransitiveTraversalFunction() throws Exception { // Create a basic package with a target //foo:foo. - Label label = Label.parseAbsolute("//foo:foo"); + Label label = Label.parseAbsolute("//foo:foo", ImmutableMap.of()); Package pkg = scratchPackage( "workspace", @@ -64,8 +64,8 @@ public class TransitiveTraversalFunctionTest extends BuildViewTestCase { // Create the GroupedList saying we had already requested two targets the last time we called // #compute. GroupedListHelper<SkyKey> helper = new GroupedListHelper<>(); - SkyKey fakeDep1 = function.getKey(Label.parseAbsolute("//foo:bar")); - SkyKey fakeDep2 = function.getKey(Label.parseAbsolute("//foo:baz")); + SkyKey fakeDep1 = function.getKey(Label.parseAbsolute("//foo:bar", ImmutableMap.of())); + SkyKey fakeDep2 = function.getKey(Label.parseAbsolute("//foo:baz", ImmutableMap.of())); helper.add(TargetMarkerValue.key(label)); helper.add(PackageValue.key(label.getPackageIdentifier())); helper.startGroup(); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java index 4e633e4632..9a502988ea 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java @@ -17,6 +17,7 @@ package com.google.devtools.build.lib.skyframe; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.FileStateValue; import com.google.devtools.build.lib.actions.FileValue; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; @@ -206,7 +207,8 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase { SkyKey key = ExternalPackageFunction.key(workspacePath); PackageValue value = (PackageValue) externalSkyFunc.compute(key, getEnv()); Package pkg = value.getPackage(); - assertThat(getLabelMapping(pkg, "foo/bar")).isEqualTo(Label.parseAbsolute("//foo:bar")); + assertThat(getLabelMapping(pkg, "foo/bar")) + .isEqualTo(Label.parseAbsolute("//foo:bar", ImmutableMap.of())); MoreAsserts.assertNoEvents(pkg.getEvents()); } @@ -218,7 +220,8 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase { SkyKey key = ExternalPackageFunction.key(workspacePath); PackageValue value = (PackageValue) externalSkyFunc.compute(key, getEnv()); Package pkg = value.getPackage(); - assertThat(getLabelMapping(pkg, "foo/bar")).isEqualTo(Label.parseAbsolute("//foo:bar")); + assertThat(getLabelMapping(pkg, "foo/bar")) + .isEqualTo(Label.parseAbsolute("//foo:bar", ImmutableMap.of())); MoreAsserts.assertNoEvents(pkg.getEvents()); } @@ -274,7 +277,8 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase { SkyKey key = ExternalPackageFunction.key(workspacePath); PackageValue value = (PackageValue) externalSkyFunc.compute(key, getEnv()); Package pkg = value.getPackage(); - assertThat(getLabelMapping(pkg, "foo/bar")).isEqualTo(Label.parseAbsolute("//foo:bar")); + assertThat(getLabelMapping(pkg, "foo/bar")) + .isEqualTo(Label.parseAbsolute("//foo:bar", ImmutableMap.of())); MoreAsserts.assertNoEvents(pkg.getEvents()); } } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodecTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodecTest.java index 745ad95edc..08ea24e51e 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodecTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/LabelCodecTest.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.skyframe.serialization; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester; import org.junit.Test; @@ -26,6 +27,6 @@ public class LabelCodecTest { @Test public void testCodec() throws Exception { - new SerializationTester(Label.parseAbsolute("//foo/bar:baz")).runTests(); + new SerializationTester(Label.parseAbsolute("//foo/bar:baz", ImmutableMap.of())).runTests(); } } diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java index e3afc4e2ca..e1c4cd1d68 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.skylark; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; import com.google.devtools.build.lib.actions.Artifact; @@ -58,7 +59,8 @@ public class SkylarkActionProviderTest extends AnalysisTestCase { ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()).getConfiguredAspect(); - SkylarkKey fooKey = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "foo"); + SkylarkKey fooKey = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "foo"); assertThat(configuredAspect.get(fooKey).getValue("actions")).isNotNull(); @SuppressWarnings("unchecked") @@ -112,7 +114,8 @@ public class SkylarkActionProviderTest extends AnalysisTestCase { ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()).getConfiguredAspect(); - SkylarkKey fooKey = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "foo"); + SkylarkKey fooKey = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "foo"); assertThat(configuredAspect.get(fooKey).getValue("actions")).isNotNull(); diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java index b81b4936a9..a0786f9929 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java @@ -21,6 +21,7 @@ import static java.util.stream.Collectors.toList; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; @@ -106,8 +107,10 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()) .getConfiguredAspect(); - SkylarkKey fooKey = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "foo"); - SkylarkKey barKey = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "bar"); + SkylarkKey fooKey = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "foo"); + SkylarkKey barKey = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "bar"); assertThat(configuredAspect.get(fooKey).getProvider().getKey()).isEqualTo(fooKey); assertThat(configuredAspect.get(barKey).getProvider().getKey()).isEqualTo(barKey); @@ -133,8 +136,10 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()) .getConfiguredAspect(); - SkylarkKey fooKey = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "foo"); - SkylarkKey barKey = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "bar"); + SkylarkKey fooKey = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "foo"); + SkylarkKey barKey = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "bar"); assertThat(configuredAspect.get(fooKey).getProvider().getKey()).isEqualTo(fooKey); assertThat(configuredAspect.get(barKey).getProvider().getKey()).isEqualTo(barKey); @@ -2290,7 +2295,8 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { AnalysisResult analysisResult = update(ImmutableList.of("//test:aspect.bzl%a3"), "//test:r2_1"); ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()) .getConfiguredAspect(); - SkylarkKey p3 = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "p3"); + SkylarkKey p3 = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "p3"); assertThat((SkylarkList<?>) configuredAspect.get(p3).getValue("value")) .containsExactly( "//test:r0_1=True", @@ -2353,7 +2359,8 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { AnalysisResult analysisResult = update(ImmutableList.of(), "//test:rcollect"); ConfiguredTarget configuredTarget = Iterables.getOnlyElement(analysisResult.getTargetsToBuild()); - SkylarkKey pCollector = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "PCollector"); + SkylarkKey pCollector = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "PCollector"); assertThat((SkylarkList<?>) configuredTarget.get(pCollector).getValue("result")) .containsExactly( "//test:r1", @@ -2393,9 +2400,11 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { update(ImmutableList.of("//test:aspect.bzl%acollect"), "//test:baz"); ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()).getConfiguredAspect(); - SkylarkKey pCollector = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "PCollector"); + SkylarkKey pCollector = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "PCollector"); Info collector = configuredAspect.get(pCollector); - assertThat(collector.getValue("aspect_attr")).isEqualTo(Label.parseAbsolute("//test:foo")); + assertThat(collector.getValue("aspect_attr")) + .isEqualTo(Label.parseAbsolute("//test:foo", ImmutableMap.of())); } @Test @@ -2434,7 +2443,8 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { update(ImmutableList.of("//test:aspect.bzl%acollect"), "//test:baz"); ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()).getConfiguredAspect(); - SkylarkKey pCollector = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "PCollector"); + SkylarkKey pCollector = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "PCollector"); Info collector = configuredAspect.get(pCollector); assertThat(collector.getValue("attr_value")).isEqualTo(30); } @@ -2489,7 +2499,8 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { update(ImmutableList.of("//test:aspect.bzl%acollect"), "//test:quux"); ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()).getConfiguredAspect(); - SkylarkKey pCollector = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "PCollector"); + SkylarkKey pCollector = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "PCollector"); Info collector = configuredAspect.get(pCollector); assertThat(collector.getValue("attr_value")).isEqualTo(30); } @@ -2529,13 +2540,14 @@ public class SkylarkDefinedAspectsTest extends AnalysisTestCase { update(ImmutableList.of("//test:aspect.bzl%acollect"), "//test:baz"); ConfiguredAspect configuredAspect = Iterables.getOnlyElement(analysisResult.getAspects()).getConfiguredAspect(); - SkylarkKey pCollector = new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl"), "PCollector"); + SkylarkKey pCollector = + new SkylarkKey(Label.parseAbsolute("//test:aspect.bzl", ImmutableMap.of()), "PCollector"); Info collector = configuredAspect.get(pCollector); assertThat(((SkylarkNestedSet) collector.getValue("visited")).toCollection()) .containsExactly( - Label.parseAbsolute("//test:referenced_from_aspect_only"), - Label.parseAbsolute("//test:bar"), - Label.parseAbsolute("//test:baz")); + Label.parseAbsolute("//test:referenced_from_aspect_only", ImmutableMap.of()), + Label.parseAbsolute("//test:bar", ImmutableMap.of()), + Label.parseAbsolute("//test:baz", ImmutableMap.of())); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java index db9f87ae46..75d79294f5 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java @@ -1639,7 +1639,8 @@ public class SkylarkIntegrationTest extends BuildViewTestCase { "my_dep_rule(name = 'yyy', dep = ':xxx')" ); - SkylarkKey pInfoKey = new SkylarkKey(Label.parseAbsolute("//test:rule.bzl"), "PInfo"); + SkylarkKey pInfoKey = + new SkylarkKey(Label.parseAbsolute("//test:rule.bzl", ImmutableMap.of()), "PInfo"); ConfiguredTarget targetXXX = getConfiguredTarget("//test:xxx"); assertThat(targetXXX.get(pInfoKey).getValue("s")) diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java index 0127f49239..9b13ccde09 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.fail; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; import com.google.devtools.build.lib.actions.Artifact; @@ -970,7 +971,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { SkylarkRuleContext context = createRuleContext("//:r"); Label keyLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.label_dict.keys()[0].label"); - assertThat(keyLabel).isEqualTo(Label.parseAbsolute("//:dep")); + assertThat(keyLabel).isEqualTo(Label.parseAbsolute("//:dep", ImmutableMap.of())); String valueString = (String) evalRuleContextCode(context, "ruleContext.attr.label_dict.values()[0]"); assertThat(valueString).isEqualTo("value"); @@ -1001,7 +1002,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { SkylarkRuleContext context = createRuleContext("//:r"); Label keyLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.label_dict.keys()[0].label"); - assertThat(keyLabel).isEqualTo(Label.parseAbsolute("//:dep")); + assertThat(keyLabel).isEqualTo(Label.parseAbsolute("//:dep", ImmutableMap.of())); String valueString = (String) evalRuleContextCode(context, "ruleContext.attr.label_dict.values()[0]"); assertThat(valueString).isEqualTo("value"); @@ -1030,7 +1031,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { SkylarkRuleContext context = createRuleContext("//:r"); Label keyLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.label_dict.keys()[0].label"); - assertThat(keyLabel).isEqualTo(Label.parseAbsolute("//:default")); + assertThat(keyLabel).isEqualTo(Label.parseAbsolute("//:default", ImmutableMap.of())); String valueString = (String) evalRuleContextCode(context, "ruleContext.attr.label_dict.values()[0]"); assertThat(valueString).isEqualTo("defs"); @@ -1329,16 +1330,16 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { SkylarkRuleContext context = createRuleContext("//:r"); Label explicitDepLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.explicit_dep.label"); - assertThat(explicitDepLabel).isEqualTo(Label.parseAbsolute("//:dep")); + assertThat(explicitDepLabel).isEqualTo(Label.parseAbsolute("//:dep", ImmutableMap.of())); Label implicitDepLabel = (Label) evalRuleContextCode(context, "ruleContext.attr._implicit_dep.label"); - assertThat(implicitDepLabel).isEqualTo(Label.parseAbsolute("//:dep")); + assertThat(implicitDepLabel).isEqualTo(Label.parseAbsolute("//:dep", ImmutableMap.of())); Label explicitDepListLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.explicit_dep_list[0].label"); - assertThat(explicitDepListLabel).isEqualTo(Label.parseAbsolute("//:dep")); + assertThat(explicitDepListLabel).isEqualTo(Label.parseAbsolute("//:dep", ImmutableMap.of())); Label implicitDepListLabel = (Label) evalRuleContextCode(context, "ruleContext.attr._implicit_dep_list[0].label"); - assertThat(implicitDepListLabel).isEqualTo(Label.parseAbsolute("//:dep")); + assertThat(implicitDepListLabel).isEqualTo(Label.parseAbsolute("//:dep", ImmutableMap.of())); } @Test @@ -1370,7 +1371,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchain labels. SkylarkRuleContext context = createRuleContext("@r//a:r"); Label depLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.internal_dep.label"); - assertThat(depLabel).isEqualTo(Label.parseAbsolute("//:dep")); + assertThat(depLabel).isEqualTo(Label.parseAbsolute("//:dep", ImmutableMap.of())); } @Test @@ -1405,7 +1406,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { invalidatePackages(/*alsoConfigs=*/false); // Repository shuffling messes with toolchain labels. SkylarkRuleContext context = createRuleContext("@r//a:r"); Label depLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.internal_dep.label"); - assertThat(depLabel).isEqualTo(Label.parseAbsolute("@r//:dep")); + assertThat(depLabel).isEqualTo(Label.parseAbsolute("@r//:dep", ImmutableMap.of())); } @Test @@ -1472,7 +1473,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { .getAssociatedRule() .getAttributeContainer() .getAttr("srcs")) - .contains(Label.parseAbsolute("@foo//:baz.txt")); + .contains(Label.parseAbsolute("@foo//:baz.txt", ImmutableMap.of())); scratch.overwriteFile("BUILD"); scratch.overwriteFile("bar.bzl", "dummy = 1"); @@ -2025,7 +2026,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { assertThat(keyString).isEqualTo("x86"); Label valueLabel = (Label) evalRuleContextCode(ruleContext, "ruleContext.attr.runtimes.values()[0]"); - assertThat(valueLabel).isEqualTo(Label.parseAbsolute("//jvm:runtime")); + assertThat(valueLabel).isEqualTo(Label.parseAbsolute("//jvm:runtime", ImmutableMap.of())); } // A list of attributes and methods ctx objects have @@ -2216,7 +2217,8 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { "a(name='a', value={'c': 'c', 'b': 'b', 'a': 'a', 'f': 'f', 'e': 'e', 'd': 'd'})"); ConfiguredTarget a = getConfiguredTarget("//a"); - SkylarkKey key = new SkylarkKey(Label.parseAbsolute("//a:a.bzl"), "key_provider"); + SkylarkKey key = + new SkylarkKey(Label.parseAbsolute("//a:a.bzl", ImmutableMap.of()), "key_provider"); @SuppressWarnings("unchecked") SkylarkList<String> keys = (SkylarkList<String>) a.get(key).getValue("keys"); assertThat(keys).containsExactly("c", "b", "a", "f", "e", "d").inOrder(); diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java index 1de6ab0899..b8b38dd8bf 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.fail; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; import com.google.devtools.build.lib.actions.ActionKeyContext; @@ -1336,7 +1337,9 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase { Object provider = configuredTarget.get("proxy"); assertThat(provider).isInstanceOf(Info.class); assertThat(((Info) provider).getProvider().getKey()) - .isEqualTo(new SkylarkKey(Label.parseAbsolute("//test:foo.bzl"), "foo_provider")); + .isEqualTo( + new SkylarkKey( + Label.parseAbsolute("//test:foo.bzl", ImmutableMap.of()), "foo_provider")); } @Test @@ -1376,7 +1379,8 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase { Object provider = configuredTarget.get("proxy"); assertThat(provider).isInstanceOf(Info.class); assertThat(((Info) provider).getProvider().getKey()) - .isEqualTo(new SkylarkKey(Label.parseAbsolute("//test:foo.bzl"), "FooInfo")); + .isEqualTo( + new SkylarkKey(Label.parseAbsolute("//test:foo.bzl", ImmutableMap.of()), "FooInfo")); } @Test @@ -1493,7 +1497,9 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase { Object provider = configuredTarget.get("proxy"); assertThat(provider).isInstanceOf(Info.class); assertThat(((Info) provider).getProvider().getKey()) - .isEqualTo(new SkylarkKey(Label.parseAbsolute("//test:foo.bzl"), "foo_provider")); + .isEqualTo( + new SkylarkKey( + Label.parseAbsolute("//test:foo.bzl", ImmutableMap.of()), "foo_provider")); assertThat(((Info) provider).getValue("a")).isEqualTo(123); } @@ -1540,7 +1546,9 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase { Object provider = configuredTarget.get("proxy"); assertThat(provider).isInstanceOf(Info.class); assertThat(((Info) provider).getProvider().getKey()) - .isEqualTo(new SkylarkKey(Label.parseAbsolute("//test:foo.bzl"), "foo_provider")); + .isEqualTo( + new SkylarkKey( + Label.parseAbsolute("//test:foo.bzl", ImmutableMap.of()), "foo_provider")); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java b/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java index d6c165931b..3609c0c8be 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java @@ -61,8 +61,9 @@ public class PrinterTest { assertThat(Printer.repr(3)).isEqualTo("3"); assertThat(Printer.repr(Runtime.NONE)).isEqualTo("None"); - assertThat(Printer.str(Label.parseAbsolute("//x"))).isEqualTo("//x:x"); - assertThat(Printer.repr(Label.parseAbsolute("//x"))).isEqualTo("Label(\"//x:x\")"); + assertThat(Printer.str(Label.parseAbsolute("//x", ImmutableMap.of()))).isEqualTo("//x:x"); + assertThat(Printer.repr(Label.parseAbsolute("//x", ImmutableMap.of()))) + .isEqualTo("Label(\"//x:x\")"); List<?> list = MutableList.of(null, "foo", "bar"); List<?> tuple = Tuple.of("foo", "bar"); diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java index cb8629c143..813c727428 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java @@ -99,9 +99,10 @@ public class SkylarkImportsTest { assertThat(importForLabel.getImportString()).named("getImportString()").isEqualTo(labelString); // The import label is relative to the parent's package, not the parent's directory. - Label containingLabel = Label.parseAbsolute(containingLabelString); - assertThat(importForLabel.getLabel(containingLabel)).named("getLabel()") - .isEqualTo(Label.parseAbsolute(expectedLabelString)); + Label containingLabel = Label.parseAbsolute(containingLabelString, ImmutableMap.of()); + assertThat(importForLabel.getLabel(containingLabel)) + .named("getLabel()") + .isEqualTo(Label.parseAbsolute(expectedLabelString, ImmutableMap.of())); assertThat(importForLabel.asPathFragment()).named("asPathFragment()") .isEqualTo(PathFragment.create(expectedPathString)); diff --git a/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java b/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java index a7c45f436b..0fd54903f6 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java @@ -48,7 +48,7 @@ public class TypeTest { @Before public final void setCurrentRule() throws Exception { - this.currentRule = Label.parseAbsolute("//quux:baz"); + this.currentRule = Label.parseAbsolute("//quux:baz", ImmutableMap.of()); } @Test @@ -220,16 +220,14 @@ public class TypeTest { @Test public void testLabel() throws Exception { - Label label = Label - .parseAbsolute("//foo:bar"); + Label label = Label.parseAbsolute("//foo:bar", ImmutableMap.of()); assertThat(BuildType.LABEL.convert("//foo:bar", null, currentRule)).isEqualTo(label); assertThat(collectLabels(BuildType.LABEL, label)).containsExactly(label); } @Test public void testNodepLabel() throws Exception { - Label label = Label - .parseAbsolute("//foo:bar"); + Label label = Label.parseAbsolute("//foo:bar", ImmutableMap.of()); assertThat(BuildType.NODEP_LABEL.convert("//foo:bar", null, currentRule)).isEqualTo(label); assertThat(collectLabels(BuildType.NODEP_LABEL, label)).containsExactly(label); } @@ -237,9 +235,9 @@ public class TypeTest { @Test public void testRelativeLabel() throws Exception { assertThat(BuildType.LABEL.convert(":wiz", null, currentRule)) - .isEqualTo(Label.parseAbsolute("//quux:wiz")); + .isEqualTo(Label.parseAbsolute("//quux:wiz", ImmutableMap.of())); assertThat(BuildType.LABEL.convert("wiz", null, currentRule)) - .isEqualTo(Label.parseAbsolute("//quux:wiz")); + .isEqualTo(Label.parseAbsolute("//quux:wiz", ImmutableMap.of())); try { BuildType.LABEL.convert("wiz", null); fail(); @@ -336,8 +334,9 @@ public class TypeTest { List<Label> converted = BuildType.LABEL_LIST.convert(input , null, currentRule); List<Label> expected = - Arrays.asList(Label.parseAbsolute("//foo:bar"), - Label.parseAbsolute("//quux:wiz")); + Arrays.asList( + Label.parseAbsolute("//foo:bar", ImmutableMap.of()), + Label.parseAbsolute("//quux:wiz", ImmutableMap.of())); assertThat(converted).isEqualTo(expected); assertThat(converted).isNotSameAs(expected); assertThat(collectLabels(BuildType.LABEL_LIST, converted)).containsExactlyElementsIn(expected); |