use of com.google.devtools.build.skyframe.SequentialBuildDriver 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.SequentialBuildDriver in project bazel by bazelbuild.
the class FileFunctionTest method makeDriver.
private SequentialBuildDriver makeDriver(ExternalFileAction externalFileAction) {
AtomicReference<PathPackageLocator> pkgLocatorRef = new AtomicReference<>(pkgLocator);
BlazeDirectories directories = new BlazeDirectories(pkgRoot, outputBase, pkgRoot, TestConstants.PRODUCT_NAME);
ExternalFilesHelper externalFilesHelper = new ExternalFilesHelper(pkgLocatorRef, externalFileAction, directories);
differencer = new RecordingDifferencer();
MemoizingEvaluator evaluator = new InMemoryMemoizingEvaluator(ImmutableMap.<SkyFunctionName, SkyFunction>builder().put(SkyFunctions.FILE_STATE, new FileStateFunction(new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper)).put(SkyFunctions.FILE_SYMLINK_CYCLE_UNIQUENESS, new FileSymlinkCycleUniquenessFunction()).put(SkyFunctions.FILE_SYMLINK_INFINITE_EXPANSION_UNIQUENESS, new FileSymlinkInfiniteExpansionUniquenessFunction()).put(SkyFunctions.FILE, new FileFunction(pkgLocatorRef)).put(SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null)).put(SkyFunctions.PACKAGE_LOOKUP, new PackageLookupFunction(new AtomicReference<>(ImmutableSet.<PackageIdentifier>of()), CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD))).put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(TestRuleClassProvider.getRuleClassProvider())).put(SkyFunctions.WORKSPACE_FILE, new WorkspaceFileFunction(TestRuleClassProvider.getRuleClassProvider(), TestConstants.PACKAGE_FACTORY_FACTORY_FOR_TESTING.create(TestRuleClassProvider.getRuleClassProvider(), fs), directories)).put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction()).put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction()).build(), differencer);
PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID());
PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator);
return new SequentialBuildDriver(evaluator);
}
use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.
the class FileFunctionTest method assertNoError.
/**
* Asserts that trying to construct a FileValue for {@code path} succeeds. Returns the paths of
* all files seen.
*/
private Set<RootedPath> assertNoError(String pathString) throws Exception {
SequentialBuildDriver driver = makeDriver();
SkyKey key = skyKey(pathString);
EvaluationResult<FileValue> result;
result = driver.evaluate(ImmutableList.of(key), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertFalse("Did not expect error while evaluating " + pathString + ", got " + result.get(key), result.hasError());
return filesSeen(driver.getGraphForTesting());
}
use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.
the class FileFunctionTest method testFilesystemInconsistencies_GetFastDigestAndIsReadableFailure.
@Test
public void testFilesystemInconsistencies_GetFastDigestAndIsReadableFailure() throws Exception {
createFsAndRoot(new CustomInMemoryFs(manualClock) {
@Override
protected boolean isReadable(Path path) throws IOException {
if (path.getBaseName().equals("unreadable")) {
throw new IOException("isReadable failed");
}
return super.isReadable(path);
}
});
Path p = file("unreadable");
p.chmod(0);
SequentialBuildDriver driver = makeDriver();
SkyKey skyKey = skyKey("unreadable");
EvaluationResult<FileValue> result = driver.evaluate(ImmutableList.of(skyKey), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertTrue(result.hasError());
ErrorInfo errorInfo = result.getError(skyKey);
assertThat(errorInfo.getException()).isInstanceOf(InconsistentFilesystemException.class);
assertThat(errorInfo.getException().getMessage()).contains("encountered error 'isReadable failed'");
assertThat(errorInfo.getException().getMessage()).contains("/root/unreadable is no longer a file");
}
use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.
the class FileFunctionTest method testFilesystemInconsistencies_GetFastDigest.
@Test
public void testFilesystemInconsistencies_GetFastDigest() throws Exception {
file("a");
// Our custom filesystem says "a/b" exists but "a" does not exist.
fs.stubFastDigestError(path("a"), new IOException("nope"));
SequentialBuildDriver driver = makeDriver();
SkyKey skyKey = skyKey("a");
EvaluationResult<FileValue> result = driver.evaluate(ImmutableList.of(skyKey), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertTrue(result.hasError());
ErrorInfo errorInfo = result.getError(skyKey);
assertThat(errorInfo.getException()).isInstanceOf(InconsistentFilesystemException.class);
assertThat(errorInfo.getException().getMessage()).contains("encountered error 'nope'");
assertThat(errorInfo.getException().getMessage()).contains("/root/a is no longer a file");
}
Aggregations