Don't keep packages in the default repository around after loading.
Previously, this would get thrown when referring to the same package
from both the main and default repositories:
java.lang.IllegalArgumentException: Multiple entries with same key: tools/cpp=/home/brian/971-Robot-Code and tools/cpp=/home/brian/971-Robot-Code
at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:136)
at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:98)
at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:84)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:295)
at com.google.devtools.build.lib.buildtool.BuildTool.transformPackageRoots(BuildTool.java:301)
at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:209)
at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:334)
at com.google.devtools.build.lib.runtime.commands.TestCommand.doTest(TestCommand.java:119)
at com.google.devtools.build.lib.runtime.commands.TestCommand.exec(TestCommand.java:104)
at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:371)
at com.google.devtools.build.lib.runtime.BlazeRuntime$3.exec(BlazeRuntime.java:1016)
at com.google.devtools.build.lib.server.RPCService.executeRequest(RPCService.java:65)
at com.google.devtools.build.lib.server.RPCServer.executeRequest(RPCServer.java:434)
at com.google.devtools.build.lib.server.RPCServer.serve(RPCServer.java:229)
at com.google.devtools.build.lib.runtime.BlazeRuntime.serverMain(BlazeRuntime.java:975)
at com.google.devtools.build.lib.runtime.BlazeRuntime.main(BlazeRuntime.java:772)
at com.google.devtools.build.lib.bazel.BazelMain.main(BazelMain.java:55)
And this would get thrown for any packages in the main repository loaded
from other repositories:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'PACKAGE:@//tools/build_rules/go/toolchain' (requested by nodes )
at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:982)
at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:499)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Invalid BUILD file name for package '@//tools/build_rules/go/toolchain': /home/brian/bazel/tools/build_rules/go/toolchain/BUILD
at com.google.devtools.build.lib.packages.Package.finishInit(Package.java:299)
at com.google.devtools.build.lib.packages.Package$Builder.finishBuild(Package.java:1308)
at com.google.devtools.build.lib.skyframe.PackageFunction.compute(PackageFunction.java:501)
at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:933)
... 4 more
Sponsor's comment: note the abundance of new Label.resolveRepositoryRelative() calls. They are ugly, but it's only making existing ugliness explicit. Yes, we should fix it, especially in the implementation of configurable attributes.
Refs #940
--
Change-Id: I8bd7f7b00bec58a7157507595421bc50c81b404c
Reviewed-on: https://bazel-review.googlesource.com/#/c/2591
MOS_MIGRATED_REVID=117429733
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java
index 3d7f77e..0476e56 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java
@@ -82,7 +82,7 @@
private ContainingPackageLookupValue lookupContainingPackage(String packageName)
throws InterruptedException {
SkyKey key =
- ContainingPackageLookupValue.key(PackageIdentifier.createInDefaultRepo(packageName));
+ ContainingPackageLookupValue.key(PackageIdentifier.createInMainRepo(packageName));
return driver
.<ContainingPackageLookupValue>evaluate(
ImmutableList.of(key),
@@ -103,7 +103,7 @@
scratch.file("a/BUILD");
ContainingPackageLookupValue value = lookupContainingPackage("a/b");
assertTrue(value.hasContainingPackage());
- assertEquals(PackageIdentifier.createInDefaultRepo("a"), value.getContainingPackageName());
+ assertEquals(PackageIdentifier.createInMainRepo("a"), value.getContainingPackageName());
assertEquals(rootDirectory, value.getContainingPackageRoot());
}
@@ -112,7 +112,7 @@
scratch.file("a/b/BUILD");
ContainingPackageLookupValue value = lookupContainingPackage("a/b");
assertTrue(value.hasContainingPackage());
- assertEquals(PackageIdentifier.createInDefaultRepo("a/b"), value.getContainingPackageName());
+ assertEquals(PackageIdentifier.createInMainRepo("a/b"), value.getContainingPackageName());
assertEquals(rootDirectory, value.getContainingPackageRoot());
}
@@ -122,11 +122,11 @@
ContainingPackageLookupValue valueA2 = ContainingPackageLookupValue.NONE;
ContainingPackageLookupValue valueB1 =
ContainingPackageLookupValue.withContainingPackage(
- PackageIdentifier.createInDefaultRepo("b"), rootDirectory);
+ PackageIdentifier.createInMainRepo("b"), rootDirectory);
ContainingPackageLookupValue valueB2 =
ContainingPackageLookupValue.withContainingPackage(
- PackageIdentifier.createInDefaultRepo("b"), rootDirectory);
- PackageIdentifier cFrag = PackageIdentifier.createInDefaultRepo("c");
+ PackageIdentifier.createInMainRepo("b"), rootDirectory);
+ PackageIdentifier cFrag = PackageIdentifier.createInMainRepo("c");
ContainingPackageLookupValue valueC1 =
ContainingPackageLookupValue.withContainingPackage(cFrag, rootDirectory);
ContainingPackageLookupValue valueC2 =
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
index e553ef4..8829e77 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
@@ -96,7 +96,7 @@
private AtomicReference<PathPackageLocator> pkgLocator;
private TimestampGranularityMonitor tsgm;
- private static final PackageIdentifier PKG_ID = PackageIdentifier.createInDefaultRepo("pkg");
+ private static final PackageIdentifier PKG_ID = PackageIdentifier.createInMainRepo("pkg");
@Before
public final void setUp() throws Exception {
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 c985256..9178fd5 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
@@ -110,7 +110,7 @@
scratch.file("foo/BUILD");
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("pkg"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//pkg"));
result = SkyframeExecutorTestUtils.evaluate(getSkyframeExecutor(),
skyKey, /*keepGoing=*/false, reporter);
assertTrue(result.hasError());
@@ -136,7 +136,7 @@
ConstantRuleVisibility.PUBLIC, true,
7, "", UUID.randomUUID());
- SkyKey pkgLookupKey = PackageLookupValue.key(PackageIdentifier.parse("foo"));
+ SkyKey pkgLookupKey = PackageLookupValue.key(PackageIdentifier.parse("@//foo"));
EvaluationResult<PackageLookupValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), pkgLookupKey, /*keepGoing=*/false, reporter);
assertFalse(result.hasError());
@@ -144,7 +144,7 @@
scratch.file("/root1/foo/BUILD");
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("pkg"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//pkg"));
result = SkyframeExecutorTestUtils.evaluate(getSkyframeExecutor(),
skyKey, /*keepGoing=*/false, reporter);
assertTrue(result.hasError());
@@ -209,7 +209,7 @@
SkyValue fooDirValue = FileStateValue.create(pkgRootedPath,
getSkyframeExecutor().getTimestampGranularityMonitorForTesting());
differencer.inject(ImmutableMap.of(FileStateValue.key(pkgRootedPath), fooDirValue));
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
String expectedMessage = "/workspace/foo/BUILD exists but its parent path /workspace/foo isn't "
+ "an existing directory";
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
@@ -248,7 +248,7 @@
barDirFileValue, DirectoryListingStateValue.create(ImmutableList.of(
new Dirent("baz", Dirent.Type.DIRECTORY))));
differencer.inject(ImmutableMap.of(DirectoryListingValue.key(barDirRootedPath), barDirListing));
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
String expectedMessage = "Some filesystem operations implied /workspace/foo/bar/baz/baz.sh was "
+ "a regular file with size of 0 and mtime of 0 and nodeId of " + bazFileNodeId + " and "
+ "mtime of 0 but others made us think it was a nonexistent path";
@@ -272,7 +272,7 @@
scratch.file("foo/bar/baz.sh");
fs.scheduleMakeUnreadableAfterReaddir(barDir);
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
String expectedMessage = "Encountered error 'Directory is not readable'";
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
@@ -298,7 +298,7 @@
ConstantRuleVisibility.PUBLIC, true,
7, "", UUID.randomUUID());
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
validPackage(skyKey);
}
@@ -320,7 +320,7 @@
ConstantRuleVisibility.PUBLIC, true,
7, "", UUID.randomUUID());
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
PackageValue value = validPackage(skyKey);
assertThat(value.getPackage().getSubincludeLabels()).containsExactly(
Label.parseAbsolute("//bar:a"), Label.parseAbsolute("//baz:b"));
@@ -336,6 +336,32 @@
}
@Test
+ public void testIncludeInMainAndDefaultRepository() throws Exception {
+ scratch.file("foo/BUILD",
+ "subinclude('//baz:a')");
+ scratch.file("bar/BUILD",
+ "subinclude('@//baz:a')");
+ scratch.file("baz/BUILD",
+ "exports_files(['a'])");
+ scratch.file("baz/a");
+
+ getSkyframeExecutor().preparePackageLoading(
+ new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)),
+ ConstantRuleVisibility.PUBLIC, true,
+ 7, "", UUID.randomUUID());
+
+ SkyKey fooKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
+ PackageValue fooValue = validPackage(fooKey);
+ assertThat(fooValue.getPackage().getSubincludeLabels()).containsExactly(
+ Label.parseAbsolute("//baz:a"));
+
+ SkyKey barKey = PackageValue.key(PackageIdentifier.parse("@//bar"));
+ PackageValue barValue = validPackage(barKey);
+ assertThat(barValue.getPackage().getSubincludeLabels()).containsExactly(
+ Label.parseAbsolute("@//baz:a"));
+ }
+
+ @Test
public void testTransitiveSkylarkDepsStoredInPackage() throws Exception {
scratch.file("foo/BUILD",
"load('/bar/ext', 'a')");
@@ -355,7 +381,7 @@
ConstantRuleVisibility.PUBLIC, true,
7, "", UUID.randomUUID());
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ 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"));
@@ -381,7 +407,7 @@
" cmd = 'echo hello >@')");
invalidatePackages();
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("test/skylark"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//test/skylark"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
assertTrue(result.hasError());
@@ -404,7 +430,7 @@
"subinclude('//foo:a')");
invalidatePackages();
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("test/skylark"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//test/skylark"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
assertTrue(result.hasError());
@@ -429,7 +455,7 @@
" cmd = 'echo hello >@')");
invalidatePackages();
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("test/skylark"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//test/skylark"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
assertTrue(result.hasError());
@@ -452,7 +478,7 @@
" cmd = 'echo hello >@')");
invalidatePackages();
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("test/skylark"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//test/skylark"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
assertTrue(result.hasError());
@@ -471,7 +497,7 @@
"sh_library(name = 'foo', srcs = ['bar/baz.sh'])");
Path barBuildFile = scratch.file("foo/bar/BUILD");
fs.stubStatError(barBuildFile, new IOException("nope"));
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
assertTrue(result.hasError());
@@ -482,7 +508,7 @@
public void testLoadRelativePath() throws Exception {
scratch.file("pkg/BUILD", "load('ext', 'a')");
scratch.file("pkg/ext.bzl", "a = 1");
- validPackage(PackageValue.key(PackageIdentifier.parse("pkg")));
+ validPackage(PackageValue.key(PackageIdentifier.parse("@//pkg")));
}
@Test
@@ -491,13 +517,13 @@
scratch.file("pkg2/BUILD",
"load('/pkg1/ext', 'a')");
scratch.file("pkg1/ext.bzl", "a = 1");
- validPackage(PackageValue.key(PackageIdentifier.parse("pkg2")));
+ validPackage(PackageValue.key(PackageIdentifier.parse("@//pkg2")));
}
@Test
public void testBadWorkspaceFile() throws Exception {
Path workspacePath = scratch.overwriteFile("WORKSPACE", "junk");
- SkyKey skyKey = PackageValue.key(PackageIdentifier.createInDefaultRepo("external"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.createInMainRepo("external"));
getSkyframeExecutor()
.invalidate(
Predicates.equalTo(
@@ -528,7 +554,7 @@
ConstantRuleVisibility.PUBLIC, true,
7, "", UUID.randomUUID());
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
PackageValue value = validPackage(skyKey);
assertFalse(value.getPackage().containsErrors());
assertThat(value.getPackage().getTarget("existing.txt").getName()).isEqualTo("existing.txt");
@@ -584,7 +610,7 @@
ConstantRuleVisibility.PUBLIC, true,
7, "", UUID.randomUUID());
- SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("foo"));
+ SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
PackageValue value = validPackage(skyKey);
assertFalse(value.getPackage().containsErrors());
assertThat(value.getPackage().getTarget("bar-matched").getName()).isEqualTo("bar-matched");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
index 39b038f..3452728 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
@@ -108,7 +108,7 @@
}
private PackageLookupValue lookupPackage(String packageName) throws InterruptedException {
- return lookupPackage(PackageIdentifier.createInDefaultRepo(packageName));
+ return lookupPackage(PackageIdentifier.createInMainRepo(packageName));
}
private PackageLookupValue lookupPackage(PackageIdentifier packageId)
@@ -141,7 +141,7 @@
public void testDeletedPackage() throws Exception {
scratch.file("parentpackage/deletedpackage/BUILD");
deletedPackages.set(ImmutableSet.of(
- PackageIdentifier.createInDefaultRepo("parentpackage/deletedpackage")));
+ PackageIdentifier.createInMainRepo("parentpackage/deletedpackage")));
PackageLookupValue packageLookupValue = lookupPackage("parentpackage/deletedpackage");
assertFalse(packageLookupValue.packageExists());
assertEquals(ErrorReason.DELETED_PACKAGE, packageLookupValue.getErrorReason());
@@ -215,7 +215,8 @@
@Test
public void testWorkspaceLookup() throws Exception {
scratch.overwriteFile("WORKSPACE");
- PackageLookupValue packageLookupValue = lookupPackage("external");
+ PackageLookupValue packageLookupValue = lookupPackage(
+ PackageIdentifier.createInMainRepo("external"));
assertTrue(packageLookupValue.packageExists());
assertEquals(rootDirectory, packageLookupValue.getRoot());
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java
index fa3da90..278567a 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java
@@ -47,7 +47,7 @@
@Test
public void testRecursiveEvaluationFailsOnBadBuildFile() throws Exception {
- // Given a well-formed package "//foo" and a malformed package "//foo/foo",
+ // Given a well-formed package "@//foo" and a malformed package "@//foo/foo",
createFooAndFooFoo();
// Given a target pattern sequence consisting of a recursive pattern for "//foo/...",
@@ -59,12 +59,12 @@
getGraphFromPatternsEvaluation(
patternSequence, /*successExpected=*/ true, /*keepGoing=*/ true);
- // Then the graph contains package values for "//foo" and "//foo/foo",
- assertTrue(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("foo"))));
- assertTrue(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("foo/foo"))));
+ // Then the graph contains package values for "@//foo" and "@//foo/foo",
+ assertTrue(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("@//foo"))));
+ assertTrue(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("@//foo/foo"))));
- // But the graph does not contain a value for the target "//foo/foo:foofoo".
- assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("foo/foo", "foofoo"))));
+ // But the graph does not contain a value for the target "@//foo/foo:foofoo".
+ assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("@//foo/foo", "foofoo"))));
}
@Test
@@ -103,14 +103,14 @@
getGraphFromPatternsEvaluation(
patternSequence, /*successExpected=*/ true, /*keepGoing=*/ true);
- // Then the graph contains a package value for "//foo",
- assertTrue(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("foo"))));
+ // Then the graph contains a package value for "@//foo",
+ assertTrue(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("@//foo"))));
- // But no package value for "//foo/foo",
- assertFalse(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("foo/foo"))));
+ // But no package value for "@//foo/foo",
+ assertFalse(walkableGraph.exists(PackageValue.key(PackageIdentifier.parse("@//foo/foo"))));
- // And the graph does not contain a value for the target "//foo/foo:foofoo".
- Label label = Label.create("foo/foo", "foofoo");
+ // And the graph does not contain a value for the target "@//foo/foo:foofoo".
+ Label label = Label.create("@//foo/foo", "foofoo");
assertFalse(walkableGraph.exists(getKeyForLabel(label)));
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java
index 1d90220..a21c6f5 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java
@@ -59,11 +59,11 @@
// When PrepareDepsOfPatternsFunction successfully completes evaluation,
WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence);
- // Then the graph contains a value for the target "//foo:foo",
- assertValidValue(walkableGraph, getKeyForLabel(Label.create("foo", "foo")));
+ // Then the graph contains a value for the target "@//foo:foo",
+ assertValidValue(walkableGraph, getKeyForLabel(Label.create("@//foo", "foo")));
- // And the graph does not contain a value for the target "//foo:foo2".
- assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("foo", "foo2"))));
+ // And the graph does not contain a value for the target "@//foo:foo2".
+ assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("@//foo", "foo2"))));
}
@Test
@@ -79,12 +79,12 @@
WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence);
// Then the graph contains an entry for ":foo"'s dependency, ":foo2".
- assertValidValue(walkableGraph, getKeyForLabel(Label.create("foo", "foo2")));
+ assertValidValue(walkableGraph, getKeyForLabel(Label.create("@//foo", "foo2")));
}
@Test
public void testFunctionExpandsTargetPatterns() throws Exception {
- // Given a package "//foo" with independent target rules ":foo" and ":foo2",
+ // Given a package "@//foo" with independent target rules ":foo" and ":foo2",
createFooAndFoo2(/*dependent=*/ false);
// Given a target pattern sequence consisting of a pattern for "//foo:*",
@@ -94,8 +94,8 @@
WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence);
// Then the graph contains an entry for ":foo" and ":foo2".
- assertValidValue(walkableGraph, getKeyForLabel(Label.create("foo", "foo")));
- assertValidValue(walkableGraph, getKeyForLabel(Label.create("foo", "foo2")));
+ assertValidValue(walkableGraph, getKeyForLabel(Label.create("@//foo", "foo")));
+ assertValidValue(walkableGraph, getKeyForLabel(Label.create("@//foo", "foo2")));
}
@Test
@@ -108,7 +108,7 @@
WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence);
// Then the graph does not contain an entry for ":foo",
- assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("foo", "foo"))));
+ assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("@//foo", "foo"))));
}
@Test
@@ -126,11 +126,11 @@
// Then the graph contains an entry for ":foo",
assertValidValue(
walkableGraph,
- getKeyForLabel(Label.create("foo", "foo")),
+ getKeyForLabel(Label.create("@//foo", "foo")),
/*expectTransitiveException=*/ true);
// And an entry with a NoSuchPackageException for "//bar:bar",
- Exception e = assertException(walkableGraph, getKeyForLabel(Label.create("bar", "bar")));
+ Exception e = assertException(walkableGraph, getKeyForLabel(Label.create("@//bar", "bar")));
assertThat(e).isInstanceOf(NoSuchPackageException.class);
}
@@ -149,11 +149,11 @@
// Then the graph contains an entry for ":foo" which has both a value and an exception,
assertValidValue(
walkableGraph,
- getKeyForLabel(Label.create("foo", "foo")),
+ getKeyForLabel(Label.create("@//foo", "foo")),
/*expectTransitiveException=*/ true);
// And an entry with a NoSuchTargetException for "//bar:bar",
- Exception e = assertException(walkableGraph, getKeyForLabel(Label.create("bar", "bar")));
+ Exception e = assertException(walkableGraph, getKeyForLabel(Label.create("@//bar", "bar")));
assertThat(e).isInstanceOf(NoSuchTargetException.class);
}
@@ -189,8 +189,8 @@
// Then it skips evaluation of the malformed target pattern, but logs about it,
assertContainsEvent("Skipping '" + bogusPattern + "': ");
- // And then the graph contains a value for the legit target pattern's target "//foo:foo".
- assertTrue(walkableGraph.exists(getKeyForLabel(Label.create("foo", "foo"))));
+ // And then the graph contains a value for the legit target pattern's target "@//foo:foo".
+ assertTrue(walkableGraph.exists(getKeyForLabel(Label.create("@//foo", "foo"))));
}
// Helpers:
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java
index 4915f3f..207465c 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java
@@ -59,7 +59,7 @@
Path root, PathFragment rootRelativePath, ImmutableSet<PathFragment> excludedPaths) {
RootedPath rootedPath = RootedPath.toRootedPath(root, rootRelativePath);
return CollectPackagesUnderDirectoryValue.key(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME, rootedPath, excludedPaths);
+ PackageIdentifier.MAIN_REPOSITORY_NAME, rootedPath, excludedPaths);
}
private SkyKey createPrepDepsKey(Path root, PathFragment rootRelativePath) {
@@ -70,14 +70,14 @@
ImmutableSet<PathFragment> excludedPaths) {
RootedPath rootedPath = RootedPath.toRootedPath(root, rootRelativePath);
return PrepareDepsOfTargetsUnderDirectoryValue.key(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME, rootedPath, excludedPaths);
+ PackageIdentifier.MAIN_REPOSITORY_NAME, rootedPath, excludedPaths);
}
private SkyKey createPrepDepsKey(Path root, PathFragment rootRelativePath,
ImmutableSet<PathFragment> excludedPaths, FilteringPolicy filteringPolicy) {
RootedPath rootedPath = RootedPath.toRootedPath(root, rootRelativePath);
return PrepareDepsOfTargetsUnderDirectoryValue.key(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME, rootedPath, excludedPaths, filteringPolicy);
+ PackageIdentifier.MAIN_REPOSITORY_NAME, rootedPath, excludedPaths, filteringPolicy);
}
private EvaluationResult<?> getEvaluationResult(SkyKey... keys) throws InterruptedException {
@@ -102,14 +102,14 @@
EvaluationResult<?> evaluationResult = getEvaluationResult(key);
WalkableGraph graph = Preconditions.checkNotNull(evaluationResult.getWalkableGraph());
- // Then the TransitiveTraversalValue for "a:a" is evaluated,
- SkyKey aaKey = TransitiveTraversalValue.key(Label.create("a", "a"));
+ // Then the TransitiveTraversalValue for "@//a:a" is evaluated,
+ SkyKey aaKey = TransitiveTraversalValue.key(Label.create("@//a", "a"));
assertThat(graph.exists(aaKey)).isTrue();
- // And that TransitiveTraversalValue depends on "b:b.txt".
+ // And that TransitiveTraversalValue depends on "@//b:b.txt".
Iterable<SkyKey> depsOfAa =
Iterables.getOnlyElement(graph.getDirectDeps(ImmutableList.of(aaKey)).values());
- SkyKey bTxtKey = TransitiveTraversalValue.key(Label.create("b", "b.txt"));
+ SkyKey bTxtKey = TransitiveTraversalValue.key(Label.create("@//b", "b.txt"));
assertThat(depsOfAa).contains(bTxtKey);
// And the TransitiveTraversalValue for "b:b.txt" is evaluated.
@@ -128,12 +128,12 @@
EvaluationResult<?> evaluationResult = getEvaluationResult(key);
WalkableGraph graph = Preconditions.checkNotNull(evaluationResult.getWalkableGraph());
- // Then the TransitiveTraversalValue for "a:a" is not evaluated,
- SkyKey aaKey = TransitiveTraversalValue.key(Label.create("a", "a"));
+ // Then the TransitiveTraversalValue for "@//a:a" is not evaluated,
+ SkyKey aaKey = TransitiveTraversalValue.key(Label.create("@//a", "a"));
assertThat(graph.exists(aaKey)).isFalse();
- // But the TransitiveTraversalValue for "a:aTest" is.
- SkyKey aaTestKey = TransitiveTraversalValue.key(Label.create("a", "aTest"));
+ // But the TransitiveTraversalValue for "@//a:aTest" is.
+ SkyKey aaTestKey = TransitiveTraversalValue.key(Label.create("@//a", "aTest"));
assertThat(graph.exists(aaTestKey)).isTrue();
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java
index 4b2e1ab..5a16bc3 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java
@@ -60,7 +60,7 @@
Path root, PathFragment rootRelativePath, ImmutableSet<PathFragment> excludedPaths) {
RootedPath rootedPath = RootedPath.toRootedPath(root, rootRelativePath);
return RecursivePkgValue.key(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME, rootedPath, excludedPaths);
+ PackageIdentifier.MAIN_REPOSITORY_NAME, rootedPath, excludedPaths);
}
private RecursivePkgValue buildRecursivePkgValue(Path root, PathFragment rootRelativePath)
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java
index 2b264e3..6ee4ac0 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java
@@ -44,7 +44,7 @@
PathFragment rootRelativePath, ImmutableSet<PathFragment> excludedPaths) {
try {
buildRecursivePkgKey(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME, rootRelativePath, excludedPaths);
+ PackageIdentifier.MAIN_REPOSITORY_NAME, rootRelativePath, excludedPaths);
fail();
} catch (IllegalArgumentException expected) {
}
@@ -53,29 +53,29 @@
@Test
public void testValidRecursivePkgKeys() throws Exception {
buildRecursivePkgKey(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME,
+ PackageIdentifier.MAIN_REPOSITORY_NAME,
new PathFragment(""),
ImmutableSet.<PathFragment>of());
buildRecursivePkgKey(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME,
+ PackageIdentifier.MAIN_REPOSITORY_NAME,
new PathFragment(""),
ImmutableSet.of(new PathFragment("a")));
buildRecursivePkgKey(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME,
+ PackageIdentifier.MAIN_REPOSITORY_NAME,
new PathFragment("a"),
ImmutableSet.<PathFragment>of());
buildRecursivePkgKey(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME,
+ PackageIdentifier.MAIN_REPOSITORY_NAME,
new PathFragment("a"),
ImmutableSet.of(new PathFragment("a/b")));
buildRecursivePkgKey(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME,
+ PackageIdentifier.MAIN_REPOSITORY_NAME,
new PathFragment("a/b"),
ImmutableSet.<PathFragment>of());
buildRecursivePkgKey(
- PackageIdentifier.DEFAULT_REPOSITORY_NAME,
+ PackageIdentifier.MAIN_REPOSITORY_NAME,
new PathFragment("a/b"),
ImmutableSet.of(new PathFragment("a/b/c")));
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java
index 606e140..4cdc8be 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java
@@ -162,7 +162,7 @@
7,
"",
UUID.randomUUID());
- SkyKey pkgLookupKey = PackageValue.key(PackageIdentifier.parse(pkg));
+ SkyKey pkgLookupKey = PackageValue.key(PackageIdentifier.parse("@//" + pkg));
EvaluationResult<PackageValue> result =
SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), pkgLookupKey, /*keepGoing=*/ false, reporter);
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 1605916..d4dda9b 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
@@ -109,7 +109,7 @@
String labelName = "//no/such/package:target/withslash";
BuildFileNotFoundException exn =
(BuildFileNotFoundException) getErrorFromTargetValue(labelName);
- assertEquals(PackageIdentifier.createInDefaultRepo("no/such/package"), exn.getPackageId());
+ assertEquals(PackageIdentifier.createInMainRepo("no/such/package"), exn.getPackageId());
String expectedMessage =
"no such package 'no/such/package': BUILD file not found on "
+ "package path for 'no/such/package'";
@@ -123,11 +123,10 @@
"a/BUILD",
"genrule(name = 'conflict1', cmd = '', srcs = [], outs = ['conflict'])",
"genrule(name = 'conflict2', cmd = '', srcs = [], outs = ['conflict'])");
- String labelName = "//a:conflict1";
- NoSuchTargetException exn = (NoSuchTargetException) getErrorFromTargetValue(labelName);
+ NoSuchTargetException exn = (NoSuchTargetException) getErrorFromTargetValue("@//a:conflict1");
assertThat(exn.getMessage())
.contains("Target '//a:conflict1' contains an error and its package is in error");
- assertEquals(labelName, exn.getLabel().toString());
+ assertEquals("//a:conflict1", exn.getLabel().toString());
assertTrue(exn.hasTarget());
}