use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FileFunctionTest method testAbsoluteSymlinksReferredByInternalFilesToFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable.
@Test
public void testAbsoluteSymlinksReferredByInternalFilesToFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable() throws Exception {
file("/outsideroot/src/foo/bar");
symlink("/root/src", "/outsideroot/src");
SequentialBuildDriver driver = makeDriver(ExternalFileAction.ASSUME_NON_EXISTENT_AND_IMMUTABLE_FOR_EXTERNAL_PATHS);
SkyKey key = skyKey("/root/src/foo/bar");
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 FileFunctionTest method testFileStateEquality.
@Test
public void testFileStateEquality() throws Exception {
file("a");
symlink("b1", "a");
symlink("b2", "a");
symlink("b3", "zzz");
directory("d1");
directory("d2");
SkyKey file = fileStateSkyKey("a");
SkyKey symlink1 = fileStateSkyKey("b1");
SkyKey symlink2 = fileStateSkyKey("b2");
SkyKey symlink3 = fileStateSkyKey("b3");
SkyKey missing1 = fileStateSkyKey("c1");
SkyKey missing2 = fileStateSkyKey("c2");
SkyKey directory1 = fileStateSkyKey("d1");
SkyKey directory2 = fileStateSkyKey("d2");
ImmutableList<SkyKey> keys = ImmutableList.of(file, symlink1, symlink2, symlink3, missing1, missing2, directory1, directory2);
SequentialBuildDriver driver = makeDriver();
EvaluationResult<SkyValue> result = driver.evaluate(keys, false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
new EqualsTester().addEqualityGroup(result.get(file)).addEqualityGroup(result.get(symlink1), result.get(symlink2)).addEqualityGroup(result.get(symlink3)).addEqualityGroup(result.get(missing1), result.get(missing2)).addEqualityGroup(result.get(directory1), result.get(directory2)).testEquals();
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FilesetEntryFunctionTest method assertRecursiveTraversalForDirectorySymlink.
private void assertRecursiveTraversalForDirectorySymlink(SymlinkBehavior symlinks, PackageBoundaryMode pkgBoundaryMode) throws Exception {
Artifact dir = getSourceArtifact("foo/dir_real");
Artifact symlink = getSourceArtifact("foo/dir_sym");
createFile(childOf(dir, "file.a"), "blah");
RootedPath fileAsym = childOf(dir, "subdir/file.a.sym");
createFile(childOf(dir, "subpkg/BUILD"), "blah");
createFile(childOf(dir, "subpkg/file.b"), "blah");
fileAsym.asPath().getParentDirectory().createDirectory();
fileAsym.asPath().createSymbolicLink(new PathFragment("../file.a"));
symlink.getPath().createSymbolicLink(new PathFragment("dir_real"));
FilesetOutputSymlink outA = symlink("output-name/file.a", childOf(symlink, "file.a"));
FilesetOutputSymlink outASym = null;
FilesetOutputSymlink outBuild = symlink("output-name/subpkg/BUILD", childOf(symlink, "subpkg/BUILD"));
FilesetOutputSymlink outB = symlink("output-name/subpkg/file.b", childOf(symlink, "subpkg/file.b"));
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", childOf(dir, "file.a"));
break;
default:
throw new IllegalStateException(symlinks.toString());
}
FilesetTraversalParams params = FilesetTraversalParamsFactory.recursiveTraversalOfDirectory(/*ownerLabel=*/
label("//foo"), /*directoryToTraverse=*/
symlink, /*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_sym' crosses package boundary into package rooted at foo/dir_sym/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 testExplicitFiles.
@Test
public void testExplicitFiles() throws Exception {
FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Path path1 = fs.getPath("/foo1");
Path path2 = fs.getPath("/foo2");
FileSystemUtils.createEmptyFile(path1);
FileSystemUtils.createEmptyFile(path2);
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));
SkyKey key1 = FileStateValue.key(RootedPath.toRootedPath(fs.getRootDirectory(), new PathFragment("foo1")));
SkyKey key2 = FileStateValue.key(RootedPath.toRootedPath(fs.getRootDirectory(), new PathFragment("foo2")));
Iterable<SkyKey> skyKeys = ImmutableList.of(key1, key2);
EvaluationResult<SkyValue> result = driver.evaluate(skyKeys, false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertFalse(result.hasError());
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));
FileSystemUtils.writeContentAsLatin1(path1, "hello1");
FileSystemUtils.writeContentAsLatin1(path1, "hello2");
path1.setLastModifiedTime(27);
path2.setLastModifiedTime(42);
assertDiffWithNewValues(getDirtyFilesystemKeys(evaluator, checker), key1, key2);
differencer.invalidate(skyKeys);
result = driver.evaluate(skyKeys, false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertFalse(result.hasError());
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FilesystemValueCheckerTest method testFileWithIOExceptionNotConsideredDirty.
@Test
public void testFileWithIOExceptionNotConsideredDirty() throws Exception {
Path path = fs.getPath("/testroot/foo");
path.getParentDirectory().createDirectory();
path.createSymbolicLink(new PathFragment("bar"));
fs.readlinkThrowsIoException = true;
SkyKey fileKey = FileStateValue.key(RootedPath.toRootedPath(pkgRoot, new PathFragment("foo")));
EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(fileKey), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertTrue(result.hasError());
fs.readlinkThrowsIoException = false;
FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Diff diff = getDirtyFilesystemKeys(evaluator, checker);
assertThat(diff.changedKeysWithoutNewValues()).isEmpty();
assertThat(diff.changedKeysWithNewValues()).isEmpty();
}
Aggregations