aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis
diff options
context:
space:
mode:
authorGravatar dannark <dannark@google.com>2018-06-27 13:35:04 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-27 13:36:25 -0700
commit90e2b4b5e745fe2de9ca82bc8163c198e5be8ca9 (patch)
treef827defac036acf55c4253c01f11126e0c502572 /src/test/java/com/google/devtools/build/lib/analysis
parent116971c08caa3f9bd94fc91066cd4cd1e432cafe (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/devtools/build/lib/analysis')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java11
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapperTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/AspectValueTest.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java42
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java18
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java27
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java18
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/DependencyTest.java44
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java10
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java8
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java29
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java8
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java14
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java5
15 files changed, 147 insertions, 99 deletions
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();
}