aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar neerajen <neerajen@google.com>2018-07-19 13:03:43 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-19 13:05:07 -0700
commit89188eb35a5b92f248d1eeb4b1549d9d1db10951 (patch)
treef2c4dd3bd111609ffa74368df661812eed471327 /src/test/java/com/google/devtools/build/lib
parent96829fef59ca2400d274b402fa9fb7ea1eda0982 (diff)
Check if ParentFileValue is a directory when evaluating a FileFunction node.
RELNOTES: None. PiperOrigin-RevId: 205288166
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java63
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java13
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java9
3 files changed, 11 insertions, 74 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
index 1401bde72a..65639f3f90 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
@@ -898,69 +898,6 @@ public class FileFunctionTest {
}
@Test
- public void testFilesystemInconsistencies_ParentIsntADirectory() throws Exception {
- file("a/b");
- // Our custom filesystem says "a/b" exists but its parent "a" is a file.
- FileStatus inconsistentParentFileStatus =
- new FileStatus() {
- @Override
- public boolean isFile() {
- return true;
- }
-
- @Override
- public boolean isSpecialFile() {
- return false;
- }
-
- @Override
- public boolean isDirectory() {
- return false;
- }
-
- @Override
- public boolean isSymbolicLink() {
- return false;
- }
-
- @Override
- public long getSize() throws IOException {
- return 0;
- }
-
- @Override
- public long getLastModifiedTime() throws IOException {
- return 0;
- }
-
- @Override
- public long getLastChangeTime() throws IOException {
- return 0;
- }
-
- @Override
- public long getNodeId() throws IOException {
- return 0;
- }
- };
- fs.stubStat(path("a"), inconsistentParentFileStatus);
- // Disable fast-path md5 so that we don't try try to md5 the "a" (since it actually physically
- // is a directory).
- fastDigest = false;
- SequentialBuildDriver driver = makeDriver();
- SkyKey skyKey = skyKey("a/b");
- EvaluationResult<FileValue> result =
- driver.evaluate(
- ImmutableList.of(skyKey), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
- assertThat(result.hasError()).isTrue();
- ErrorInfo errorInfo = result.getError(skyKey);
- assertThat(errorInfo.getException()).isInstanceOf(InconsistentFilesystemException.class);
- assertThat(errorInfo.getException())
- .hasMessageThat()
- .contains("file /root/a/b exists but its parent path /root/a isn't an existing directory");
- }
-
- @Test
public void testFilesystemInconsistencies_GetFastDigest() throws Exception {
file("a");
// Our custom filesystem says "a/b" exists but "a" does not exist.
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 57502211fb..0dd046d67d 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
@@ -125,11 +125,11 @@ public class PackageFunctionTest extends BuildViewTestCase {
Path fooBuildFile = scratch.file("foo/BUILD");
Path fooDir = fooBuildFile.getParentDirectory();
- // Our custom filesystem says "foo/BUILD" exists but its parent "foo" is a file.
- FileStatus inconsistentParentFileStatus = new FileStatus() {
+ // Our custom filesystem says that fooDir is neither a file nor directory nor symlink
+ FileStatus inconsistentFileStatus = new FileStatus() {
@Override
public boolean isFile() {
- return true;
+ return false;
}
@Override
@@ -167,13 +167,14 @@ public class PackageFunctionTest extends BuildViewTestCase {
return 0;
}
};
- fs.stubStat(fooDir, inconsistentParentFileStatus);
+
+ fs.stubStat(fooBuildFile, inconsistentFileStatus);
RootedPath pkgRootedPath = RootedPath.toRootedPath(pkgRoot, fooDir);
SkyValue fooDirValue = FileStateValue.create(pkgRootedPath, tsgm);
differencer.inject(ImmutableMap.of(FileStateValue.key(pkgRootedPath), fooDirValue));
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
- String expectedMessage = "/workspace/foo/BUILD exists but its parent path /workspace/foo isn't "
- + "an existing directory";
+ String expectedMessage = "according to stat, existing path /workspace/foo/BUILD is neither"
+ + " a file nor directory nor symlink.";
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
assertThat(result.hasError()).isTrue();
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
index eb43635135..a665d4055a 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
@@ -447,13 +447,12 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
reporter.removeHandler(failFastHandler);
scratch.file("foo/BUILD", "sh_library(name = 'foo', deps = ['//bar:baz/fizz'])");
Path barBuildFile = scratch.file("bar/BUILD", "sh_library(name = 'bar/baz')");
- Path bazDir = barBuildFile.getParentDirectory().getRelative("baz");
scratch.file("bar/baz/BUILD");
- FileStatus inconsistentParentFileStatus =
+ FileStatus inconsistentFileStatus =
new FileStatus() {
@Override
public boolean isFile() {
- return true;
+ return false;
}
@Override
@@ -491,8 +490,8 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
return 0;
}
};
- fs.stubStat(bazDir, inconsistentParentFileStatus);
- Set<Label> labels = ImmutableSet.of(Label.parseAbsolute("//foo:foo", ImmutableMap.of()));
+ fs.stubStat(barBuildFile, inconsistentFileStatus);
+ Set<Label> labels = ImmutableSet.of(Label.parseAbsolute("//bar:baz", ImmutableMap.of()));
getSkyframeExecutor()
.getPackageManager()
.newTransitiveLoader()