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;
}
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);
}
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);
}
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);
}
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());
}
Aggregations