diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/pkgcache')
6 files changed, 77 insertions, 55 deletions
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 |