Search in sources :

Example 61 with SkyValue

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);
}
Also used : RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) SkyValue(com.google.devtools.build.skyframe.SkyValue) SkyKey(com.google.devtools.build.skyframe.SkyKey) FileStatus(com.google.devtools.build.lib.vfs.FileStatus) ErrorInfo(com.google.devtools.build.skyframe.ErrorInfo) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 62 with SkyValue

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());
}
Also used : SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Test(org.junit.Test)

Example 63 with SkyValue

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.");
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) ErrorInfo(com.google.devtools.build.skyframe.ErrorInfo) Artifact(com.google.devtools.build.lib.actions.Artifact) Test(org.junit.Test)

Example 64 with SkyValue

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());
    }
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) FilesetTraversalParams(com.google.devtools.build.lib.actions.FilesetTraversalParams) FilesetOutputSymlink(com.google.devtools.build.lib.actions.FilesetOutputSymlink) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Artifact(com.google.devtools.build.lib.actions.Artifact) RootedPath(com.google.devtools.build.lib.vfs.RootedPath)

Example 65 with SkyValue

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();
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Diff(com.google.devtools.build.skyframe.Differencer.Diff) Test(org.junit.Test)

Aggregations

SkyValue (com.google.devtools.build.skyframe.SkyValue)66 SkyKey (com.google.devtools.build.skyframe.SkyKey)63 Map (java.util.Map)20 ImmutableMap (com.google.common.collect.ImmutableMap)18 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)17 Test (org.junit.Test)16 Artifact (com.google.devtools.build.lib.actions.Artifact)15 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)15 HashMap (java.util.HashMap)14 ImmutableList (com.google.common.collect.ImmutableList)10 SequentialBuildDriver (com.google.devtools.build.skyframe.SequentialBuildDriver)10 Path (com.google.devtools.build.lib.vfs.Path)9 ErrorInfo (com.google.devtools.build.skyframe.ErrorInfo)8 LinkedHashMap (java.util.LinkedHashMap)8 Label (com.google.devtools.build.lib.cmdline.Label)7 HashSet (java.util.HashSet)7 Target (com.google.devtools.build.lib.packages.Target)6 NoSuchPackageException (com.google.devtools.build.lib.packages.NoSuchPackageException)5 IOException (java.io.IOException)5 ImmutableSet (com.google.common.collect.ImmutableSet)4