use of com.google.devtools.build.skyframe.ErrorInfo in project bazel by bazelbuild.
the class PackageFunctionTest method testSymlinkCycleWithSkylarkExtension.
@Test
public void testSymlinkCycleWithSkylarkExtension() throws Exception {
reporter.removeHandler(failFastHandler);
Path extensionFilePath = scratch.resolve("/workspace/test/skylark/extension.bzl");
FileSystemUtils.ensureSymbolicLink(extensionFilePath, new PathFragment("extension.bzl"));
scratch.file("test/skylark/BUILD", "load('/test/skylark/extension', 'a')", "genrule(name = gr,", " outs = ['out.txt'],", " cmd = 'echo hello >@')");
invalidatePackages();
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//test/skylark"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(getSkyframeExecutor(), skyKey, /*keepGoing=*/
false, reporter);
assertTrue(result.hasError());
ErrorInfo errorInfo = result.getError(skyKey);
assertEquals(skyKey, errorInfo.getRootCauseOfException());
assertThat(errorInfo.getException()).hasMessage("error loading package 'test/skylark': Encountered error while reading extension " + "file 'test/skylark/extension.bzl': Symlink cycle");
}
use of com.google.devtools.build.skyframe.ErrorInfo in project bazel by bazelbuild.
the class PackageFunctionTest method testNonExistingSkylarkExtensionWithPythonPreprocessing.
@Test
public void testNonExistingSkylarkExtensionWithPythonPreprocessing() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("foo/BUILD", "exports_files(['a'])");
scratch.file("foo/a", "load('/test/skylark/bad_extension', 'some_symbol')");
scratch.file("test/skylark/BUILD", "subinclude('//foo:a')");
invalidatePackages();
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//test/skylark"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(getSkyframeExecutor(), skyKey, /*keepGoing=*/
false, reporter);
assertTrue(result.hasError());
ErrorInfo errorInfo = result.getError(skyKey);
String expectedMsg = "error loading package 'test/skylark': " + "Extension file not found. Unable to load file '//test/skylark:bad_extension.bzl': " + "file doesn't exist or isn't a file";
assertThat(errorInfo.getException()).hasMessage(expectedMsg);
}
use of com.google.devtools.build.skyframe.ErrorInfo in project bazel by bazelbuild.
the class PackageFunctionTest method testNonExistingSkylarkExtensionFromExtension.
@Test
public void testNonExistingSkylarkExtensionFromExtension() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("test/skylark/extension.bzl", "load('/test/skylark/bad_extension', 'some_symbol')", "a = 'a'");
scratch.file("test/skylark/BUILD", "load('/test/skylark/extension', 'a')", "genrule(name = gr,", " outs = ['out.txt'],", " cmd = 'echo hello >@')");
invalidatePackages();
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//test/skylark"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(getSkyframeExecutor(), skyKey, /*keepGoing=*/
false, reporter);
assertTrue(result.hasError());
ErrorInfo errorInfo = result.getError(skyKey);
assertThat(errorInfo.getException()).hasMessage("error loading package 'test/skylark': Extension file not found. " + "Unable to load file '//test/skylark:bad_extension.bzl': " + "file doesn't exist or isn't a file");
}
use of com.google.devtools.build.skyframe.ErrorInfo in project bazel by bazelbuild.
the class FileFunctionTest method testFilesystemInconsistencies_ParentIsntADirectory.
@Test
public void testFilesystemInconsistencies_ParentIsntADirectory() throws Exception {
file("a/b");
// Our custom filesystem says "a/b" exists but its parent "a" is a file.
FileStatus inconsistentParentFileStatus = new FileStatus() {
@Override
public boolean isFile() {
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 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(path("a"), inconsistentParentFileStatus);
// Disable fast-path md5 so that we don't try try to md5 the "a" (since it actually physically
// is a directory).
fastDigest = false;
SequentialBuildDriver driver = makeDriver();
SkyKey skyKey = skyKey("a/b");
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("file /root/a/b exists but its parent path /root/a isn't an existing directory");
}
use of com.google.devtools.build.skyframe.ErrorInfo 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");
}
Aggregations