From b795e6bd2a2371a4a9f5e1b2cd618fdd7eceb30a Mon Sep 17 00:00:00 2001 From: Nathan Harmata Date: Thu, 4 Feb 2016 01:10:19 +0000 Subject: Have GlobFunction make use of the assumption that the glob's package exists by having it not declare a dep on the PackageLookupValue for the package. This optimization means that a BUILD file edit doesn't (necessarily) invalidate all the globs in the package; the PackageLookupValue node would get change-pruned but we still pay the very small cost of invalidating unnecessarily. Also slightly improve variable naming in GlobFunctionTest. -- MOS_MIGRATED_REVID=113799936 --- .../build/lib/skyframe/GlobFunctionTest.java | 50 ++++------------------ 1 file changed, 9 insertions(+), 41 deletions(-) (limited to 'src/test/java/com/google/devtools/build/lib/skyframe') 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 cb558228bc..32dffabba7 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 @@ public abstract class GlobFunctionTest { private AtomicReference pkgLocator; private TimestampGranularityMonitor tsgm; - private static final PackageIdentifier PKG_PATH_ID = PackageIdentifier.createInDefaultRepo("pkg"); + private static final PackageIdentifier PKG_ID = PackageIdentifier.createInDefaultRepo("pkg"); @Before public final void setUp() throws Exception { @@ -104,7 +104,7 @@ public abstract class GlobFunctionTest { root = fs.getRootDirectory().getRelative("root/workspace"); writableRoot = fs.getRootDirectory().getRelative("writableRoot/workspace"); outputBase = fs.getRootDirectory().getRelative("output_base"); - pkgPath = root.getRelative(PKG_PATH_ID.getPackageFragment()); + pkgPath = root.getRelative(PKG_ID.getPackageFragment()); pkgLocator = new AtomicReference<>( @@ -266,33 +266,6 @@ public abstract class GlobFunctionTest { .testEquals(); } - @Test - public void testGlobMissingPackage() throws Exception { - // This is a malformed value key, because "missing" is not a package. Nevertheless, we have a - // sanity check that building the corresponding GlobValue fails loudly. The test depends on - // implementation details of ParallelEvaluator and GlobFunction. - SkyKey skyKey = - GlobValue.key( - PackageIdentifier.createInDefaultRepo("missing"), - "foo", - false, - PathFragment.EMPTY_FRAGMENT); - try { - driver.evaluate( - ImmutableList.of(skyKey), - false, - SkyframeExecutor.DEFAULT_THREAD_COUNT, - NullEventHandler.INSTANCE); - fail(); - } catch (RuntimeException e) { - assertThat(e.getMessage()) - .contains("Unrecoverable error while evaluating node '" + skyKey + "'"); - Throwable cause = e.getCause(); - assertThat(cause).isInstanceOf(IllegalStateException.class); - assertThat(cause.getMessage()).contains("isn't an existing package"); - } - } - @Test public void testGlobDoesNotCrossPackageBoundary() throws Exception { FileSystemUtils.createEmptyFile(pkgPath.getRelative("foo/BUILD")); @@ -360,7 +333,7 @@ public abstract class GlobFunctionTest { } private GlobValue runGlob(boolean excludeDirs, String pattern) throws Exception { - SkyKey skyKey = GlobValue.key(PKG_PATH_ID, pattern, excludeDirs, PathFragment.EMPTY_FRAGMENT); + SkyKey skyKey = GlobValue.key(PKG_ID, root, pattern, excludeDirs, PathFragment.EMPTY_FRAGMENT); EvaluationResult result = driver.evaluate( ImmutableList.of(skyKey), @@ -444,7 +417,7 @@ public abstract class GlobFunctionTest { private void assertIllegalPattern(String pattern) { try { - GlobValue.key(PKG_PATH_ID, pattern, false, PathFragment.EMPTY_FRAGMENT); + GlobValue.key(PKG_ID, root, pattern, false, PathFragment.EMPTY_FRAGMENT); fail("invalid pattern not detected: " + pattern); } catch (InvalidGlobPatternException e) { // Expected. @@ -582,7 +555,6 @@ public abstract class GlobFunctionTest { /** Regression test for b/13319874: Directory listing crash. */ @Test public void testResilienceToFilesystemInconsistencies_DirectoryExistence() throws Exception { - long nodeId = pkgPath.getRelative("BUILD").stat().getNodeId(); // Our custom filesystem says "pkgPath/BUILD" exists but "pkgPath" does not exist. fs.stubStat(pkgPath, null); RootedPath pkgRootedPath = RootedPath.toRootedPath(root, pkgPath); @@ -590,13 +562,8 @@ public abstract class GlobFunctionTest { FileValue pkgDirValue = FileValue.value(pkgRootedPath, pkgDirFileStateValue, pkgRootedPath, pkgDirFileStateValue); differencer.inject(ImmutableMap.of(FileValue.key(pkgRootedPath), pkgDirValue)); - String expectedMessage = - "Some filesystem operations implied /root/workspace/pkg/BUILD was a " - + "regular file with size of 0 and mtime of 0 and nodeId of " - + nodeId - + " and mtime of 0 " - + "but others made us think it was a nonexistent path"; - SkyKey skyKey = GlobValue.key(PKG_PATH_ID, "*/foo", false, PathFragment.EMPTY_FRAGMENT); + String expectedMessage = "/root/workspace/pkg is no longer an existing directory"; + SkyKey skyKey = GlobValue.key(PKG_ID, root, "*/foo", false, PathFragment.EMPTY_FRAGMENT); EvaluationResult result = driver.evaluate( ImmutableList.of(skyKey), @@ -623,7 +590,7 @@ public abstract class GlobFunctionTest { ImmutableMap.of( DirectoryListingStateValue.key(fooBarDirRootedPath), fooBarDirListingValue)); String expectedMessage = "/root/workspace/pkg/foo/bar/wiz is no longer an existing directory."; - SkyKey skyKey = GlobValue.key(PKG_PATH_ID, "**/wiz", false, PathFragment.EMPTY_FRAGMENT); + SkyKey skyKey = GlobValue.key(PKG_ID, root, "**/wiz", false, PathFragment.EMPTY_FRAGMENT); EvaluationResult result = driver.evaluate( ImmutableList.of(skyKey), @@ -695,7 +662,8 @@ public abstract class GlobFunctionTest { ImmutableMap.of(DirectoryListingStateValue.key(wizRootedPath), wizDirListingValue)); String expectedMessage = "readdir and stat disagree about whether " + fileRootedPath.asPath() + " is a symlink"; - SkyKey skyKey = GlobValue.key(PKG_PATH_ID, "foo/bar/wiz/*", false, PathFragment.EMPTY_FRAGMENT); + SkyKey skyKey = GlobValue.key(PKG_ID, root, "foo/bar/wiz/*", false, + PathFragment.EMPTY_FRAGMENT); EvaluationResult result = driver.evaluate( ImmutableList.of(skyKey), -- cgit v1.2.3