use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class PackageFunctionTest method testPropagatesFilesystemInconsistencies.
@Test
public void testPropagatesFilesystemInconsistencies() throws Exception {
reporter.removeHandler(failFastHandler);
RecordingDifferencer differencer = getSkyframeExecutor().getDifferencerForTesting();
Path pkgRoot = getSkyframeExecutor().getPathEntries().get(0);
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() {
@Override
public boolean isFile() {
return true;
}
@Override
public boolean isDirectory() {
return false;
}
@Override
public boolean isSymbolicLink() {
return false;
}
@Override
public boolean isSpecialFile() {
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(fooDir, inconsistentParentFileStatus);
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";
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(getSkyframeExecutor(), skyKey, /*keepGoing=*/
false, reporter);
assertTrue(result.hasError());
ErrorInfo errorInfo = result.getError(skyKey);
String errorMessage = errorInfo.getException().getMessage();
assertThat(errorMessage).contains("Inconsistent filesystem operations");
assertThat(errorMessage).contains(expectedMessage);
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FileFunctionTest method testFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable.
@Test
public void testFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable() throws Exception {
file("/outsideroot");
SequentialBuildDriver driver = makeDriver(ExternalFileAction.ASSUME_NON_EXISTENT_AND_IMMUTABLE_FOR_EXTERNAL_PATHS);
SkyKey key = skyKey("/outsideroot");
EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(key), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertThatEvaluationResult(result).hasNoError();
FileValue value = (FileValue) result.get(key);
assertThat(value).isNotNull();
assertFalse(value.exists());
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class RecursiveFilesystemTraversalFunctionTest method testGeneratedDirectoryConflictsWithPackage.
@Test
public void testGeneratedDirectoryConflictsWithPackage() throws Exception {
Artifact genDir = derivedArtifact("a/b");
createFile(rootedPath(sourceArtifact("a/b/c/file.real")));
createFile(rootedPath(derivedArtifact("a/b/c/file.fake")));
createFile(sourceArtifact("a/b/c/BUILD"));
SkyKey key = rftvSkyKey(fileLikeRoot(genDir, CROSS));
EvaluationResult<SkyValue> result = eval(key);
assertThat(result.hasError()).isTrue();
ErrorInfo error = result.getError(key);
assertThat(error.isTransient()).isFalse();
assertThat(error.getException().getMessage()).contains("Generated directory a/b/c conflicts with package under the same path.");
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FilesetEntryFunctionTest method assertRecursiveTraversalForDirectory.
private void assertRecursiveTraversalForDirectory(SymlinkBehavior symlinks, PackageBoundaryMode pkgBoundaryMode) throws Exception {
Artifact dir = getSourceArtifact("foo/dir");
RootedPath fileA = createFile(childOf(dir, "file.a"), "blah");
RootedPath fileAsym = childOf(dir, "subdir/file.a.sym");
RootedPath buildFile = createFile(childOf(dir, "subpkg/BUILD"), "blah");
RootedPath fileB = createFile(childOf(dir, "subpkg/file.b"), "blah");
fileAsym.asPath().getParentDirectory().createDirectory();
fileAsym.asPath().createSymbolicLink(new PathFragment("../file.a"));
FilesetOutputSymlink outA = symlink("output-name/file.a", childOf(dir, "file.a"));
FilesetOutputSymlink outAsym = null;
FilesetOutputSymlink outBuild = symlink("output-name/subpkg/BUILD", buildFile);
FilesetOutputSymlink outB = symlink("output-name/subpkg/file.b", fileB);
switch(symlinks) {
case COPY:
outAsym = symlink("output-name/subdir/file.a.sym", "../file.a");
break;
case DEREFERENCE:
outAsym = symlink("output-name/subdir/file.a.sym", fileA);
break;
default:
throw new IllegalStateException(symlinks.toString());
}
FilesetTraversalParams params = FilesetTraversalParamsFactory.recursiveTraversalOfDirectory(/*ownerLabel=*/
label("//foo"), /*directoryToTraverse=*/
dir, /*destPath=*/
new PathFragment("output-name"), /*excludes=*/
null, /*symlinkBehaviorMode=*/
symlinks, /*pkgBoundaryMode=*/
pkgBoundaryMode);
switch(pkgBoundaryMode) {
case CROSS:
assertSymlinksInOrder(params, outA, outAsym, outBuild, outB);
break;
case DONT_CROSS:
assertSymlinksInOrder(params, outA, outAsym);
break;
case REPORT_ERROR:
SkyKey key = FilesetEntryValue.key(params);
EvaluationResult<SkyValue> result = eval(key);
assertThat(result.hasError()).isTrue();
assertThat(result.getError(key).getException().getMessage()).contains("'foo/dir' crosses package boundary into package rooted at foo/dir/subpkg");
break;
default:
throw new IllegalStateException(pkgBoundaryMode.toString());
}
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FilesystemValueCheckerTest method testFilesInCycleNotConsideredDirty.
@Test
public void testFilesInCycleNotConsideredDirty() throws Exception {
Path path1 = pkgRoot.getRelative("foo1");
Path path2 = pkgRoot.getRelative("foo2");
Path path3 = pkgRoot.getRelative("foo3");
FileSystemUtils.ensureSymbolicLink(path1, path2);
FileSystemUtils.ensureSymbolicLink(path2, path3);
FileSystemUtils.ensureSymbolicLink(path3, path1);
SkyKey fileKey1 = FileValue.key(RootedPath.toRootedPath(pkgRoot, path1));
EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(fileKey1), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertTrue(result.hasError());
FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Diff diff = getDirtyFilesystemKeys(evaluator, checker);
assertThat(diff.changedKeysWithoutNewValues()).isEmpty();
assertThat(diff.changedKeysWithNewValues()).isEmpty();
}
Aggregations