diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java | 64 |
1 files changed, 45 insertions, 19 deletions
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 c985256e34..9178fd5de4 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { } @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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { " 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 @@ public class PackageFunctionTest extends BuildViewTestCase { "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 @@ public class PackageFunctionTest extends BuildViewTestCase { " 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 @@ public class PackageFunctionTest extends BuildViewTestCase { " 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 @@ public class PackageFunctionTest extends BuildViewTestCase { "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 class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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 @@ public class PackageFunctionTest extends BuildViewTestCase { 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"); |