Search in sources :

Example 56 with SkyValue

use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.

the class IOExceptionsTest method visitTransitively.

private boolean visitTransitively(Label label) throws InterruptedException {
    SkyKey key = TransitiveTargetValue.key(label);
    EvaluationResult<SkyValue> result = skyframeExecutor.prepareAndGet(key, /*numThreads=*/
    5, reporter);
    TransitiveTargetValue value = (TransitiveTargetValue) result.get(key);
    System.out.println(value);
    boolean hasTransitiveError = (value == null) || value.getTransitiveRootCauses() != null;
    return !result.hasError() && !hasTransitiveError;
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) TransitiveTargetValue(com.google.devtools.build.lib.skyframe.TransitiveTargetValue)

Example 57 with SkyValue

use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.

the class GlobFunctionTest method testResilienceToFilesystemInconsistencies_SubdirectoryExistence.

@Test
public void testResilienceToFilesystemInconsistencies_SubdirectoryExistence() throws Exception {
    // Our custom filesystem says directory "pkgPath/foo/bar" contains a subdirectory "wiz" but a
    // direct stat on "pkgPath/foo/bar/wiz" says it does not exist.
    Path fooBarDir = pkgPath.getRelative("foo/bar");
    fs.stubStat(fooBarDir.getRelative("wiz"), null);
    RootedPath fooBarDirRootedPath = RootedPath.toRootedPath(root, fooBarDir);
    SkyValue fooBarDirListingValue = DirectoryListingStateValue.create(ImmutableList.of(new Dirent("wiz", Dirent.Type.DIRECTORY)));
    differencer.inject(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_ID, root, "**/wiz", false, PathFragment.EMPTY_FRAGMENT);
    EvaluationResult<GlobValue> result = driver.evaluate(ImmutableList.of(skyKey), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    assertTrue(result.hasError());
    ErrorInfo errorInfo = result.getError(skyKey);
    assertThat(errorInfo.getException()).isInstanceOf(InconsistentFilesystemException.class);
    assertThat(errorInfo.getException().getMessage()).contains(expectedMessage);
}
Also used : 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) ErrorInfo(com.google.devtools.build.skyframe.ErrorInfo) Dirent(com.google.devtools.build.lib.vfs.Dirent) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 58 with SkyValue

use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.

the class GlobFunctionTest method runGlob.

private GlobValue runGlob(boolean excludeDirs, String pattern) throws Exception {
    SkyKey skyKey = GlobValue.key(PKG_ID, root, pattern, excludeDirs, PathFragment.EMPTY_FRAGMENT);
    EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(skyKey), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    if (result.hasError()) {
        throw result.getError().getException();
    }
    return (GlobValue) result.get(skyKey);
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue)

Example 59 with SkyValue

use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.

the class GlobFunctionTest method testResilienceToFilesystemInconsistencies_SymlinkType.

@Test
public void testResilienceToFilesystemInconsistencies_SymlinkType() throws Exception {
    RootedPath wizRootedPath = RootedPath.toRootedPath(root, pkgPath.getRelative("foo/bar/wiz"));
    RootedPath fileRootedPath = RootedPath.toRootedPath(root, pkgPath.getRelative("foo/bar/wiz/file"));
    final FileStatus realStat = fileRootedPath.asPath().stat();
    fs.stubStat(fileRootedPath.asPath(), new FileStatus() {

        @Override
        public boolean isFile() {
            // The stat says foo/bar/wiz/file is a real file, not a symlink.
            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 realStat.getSize();
        }

        @Override
        public long getLastModifiedTime() throws IOException {
            return realStat.getLastModifiedTime();
        }

        @Override
        public long getLastChangeTime() throws IOException {
            return realStat.getLastChangeTime();
        }

        @Override
        public long getNodeId() throws IOException {
            return realStat.getNodeId();
        }
    });
    // But the dir listing say foo/bar/wiz/file is a symlink.
    SkyValue wizDirListingValue = DirectoryListingStateValue.create(ImmutableList.of(new Dirent("file", Dirent.Type.SYMLINK)));
    differencer.inject(ImmutableMap.of(DirectoryListingStateValue.key(wizRootedPath), wizDirListingValue));
    String expectedMessage = "readdir and stat disagree about whether " + fileRootedPath.asPath() + " is a symlink";
    SkyKey skyKey = GlobValue.key(PKG_ID, root, "foo/bar/wiz/*", false, PathFragment.EMPTY_FRAGMENT);
    EvaluationResult<GlobValue> result = driver.evaluate(ImmutableList.of(skyKey), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    assertTrue(result.hasError());
    ErrorInfo errorInfo = result.getError(skyKey);
    assertThat(errorInfo.getException()).isInstanceOf(InconsistentFilesystemException.class);
    assertThat(errorInfo.getException().getMessage()).contains(expectedMessage);
}
Also used : 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) Dirent(com.google.devtools.build.lib.vfs.Dirent) IOException(java.io.IOException) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 60 with SkyValue

use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.

the class PrepareDepsOfPatternsFunctionTest method getGraphFromPatternsEvaluation.

private WalkableGraph getGraphFromPatternsEvaluation(ImmutableList<String> patternSequence, boolean keepGoing) throws InterruptedException {
    SkyKey independentTarget = PrepareDepsOfPatternsValue.key(patternSequence, "");
    ImmutableList<SkyKey> singletonTargetPattern = ImmutableList.of(independentTarget);
    // When PrepareDepsOfPatternsFunction completes evaluation,
    EvaluationResult<SkyValue> evaluationResult = getSkyframeExecutor().getDriverForTesting().evaluate(singletonTargetPattern, keepGoing, LOADING_PHASE_THREADS, new Reporter(new EventBus(), eventCollector));
    // Currently all callers either expect success or pass keepGoing=true, which implies success,
    // since PrepareDepsOfPatternsFunction swallows all errors. Will need to be changed if a test
    // that evaluates with keepGoing=false and expects errors is added.
    assertThatEvaluationResult(evaluationResult).hasNoError();
    return Preconditions.checkNotNull(evaluationResult.getWalkableGraph());
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Reporter(com.google.devtools.build.lib.events.Reporter) EventBus(com.google.common.eventbus.EventBus)

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