Search in sources :

Example 21 with ErrorInfo

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");
}
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) ErrorInfo(com.google.devtools.build.skyframe.ErrorInfo) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 22 with ErrorInfo

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

Example 23 with ErrorInfo

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

Example 24 with ErrorInfo

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

Example 25 with ErrorInfo

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");
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyKey(com.google.devtools.build.skyframe.SkyKey) ErrorInfo(com.google.devtools.build.skyframe.ErrorInfo) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ErrorInfo (com.google.devtools.build.skyframe.ErrorInfo)30 SkyKey (com.google.devtools.build.skyframe.SkyKey)29 Test (org.junit.Test)19 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)10 Path (com.google.devtools.build.lib.vfs.Path)9 SkyValue (com.google.devtools.build.skyframe.SkyValue)8 SequentialBuildDriver (com.google.devtools.build.skyframe.SequentialBuildDriver)6 Map (java.util.Map)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Label (com.google.devtools.build.lib.cmdline.Label)4 StoredEventHandler (com.google.devtools.build.lib.events.StoredEventHandler)3 Dirent (com.google.devtools.build.lib.vfs.Dirent)3 FileStatus (com.google.devtools.build.lib.vfs.FileStatus)3 RecordingDifferencer (com.google.devtools.build.skyframe.RecordingDifferencer)3 IOException (java.io.IOException)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Artifact (com.google.devtools.build.lib.actions.Artifact)2 BuildFailedException (com.google.devtools.build.lib.actions.BuildFailedException)2 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)2