Search in sources :

Example 6 with MissingInputFileException

use of com.google.devtools.build.lib.actions.MissingInputFileException in project bazel by bazelbuild.

the class ArtifactFunction method makeMissingInputFileExn.

private static MissingInputFileException makeMissingInputFileExn(Artifact artifact, boolean mandatory, Exception failure, EventHandler reporter) {
    String extraMsg = (failure == null) ? "" : (":" + failure.getMessage());
    MissingInputFileException ex = new MissingInputFileException(constructErrorMessage(artifact) + extraMsg, null);
    if (mandatory) {
        reporter.handle(Event.error(ex.getLocation(), ex.getMessage()));
    }
    return ex;
}
Also used : MissingInputFileException(com.google.devtools.build.lib.actions.MissingInputFileException)

Example 7 with MissingInputFileException

use of com.google.devtools.build.lib.actions.MissingInputFileException in project bazel by bazelbuild.

the class ArtifactFunctionTest method testIOException_EndToEnd.

/**
   * Tests that ArtifactFunction rethrows transitive {@link IOException}s as
   * {@link MissingInputFileException}s.
   */
@Test
public void testIOException_EndToEnd() throws Throwable {
    final IOException exception = new IOException("beep");
    setupRoot(new CustomInMemoryFs() {

        @Override
        public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
            if (path.getBaseName().equals("bad")) {
                throw exception;
            }
            return super.stat(path, followSymlinks);
        }
    });
    try {
        evaluateArtifactValue(createSourceArtifact("bad"));
        fail();
    } catch (MissingInputFileException e) {
        assertThat(e.getMessage()).contains(exception.getMessage());
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) FileStatus(com.google.devtools.build.lib.vfs.FileStatus) IOException(java.io.IOException) MissingInputFileException(com.google.devtools.build.lib.actions.MissingInputFileException) Test(org.junit.Test)

Example 8 with MissingInputFileException

use of com.google.devtools.build.lib.actions.MissingInputFileException in project bazel by bazelbuild.

the class ArtifactFunctionTest method testMissingMandatoryArtifact.

@Test
public void testMissingMandatoryArtifact() throws Throwable {
    Artifact input = createSourceArtifact("input1");
    try {
        evaluateArtifactValue(input, /*mandatory=*/
        true);
        fail();
    } catch (MissingInputFileException ex) {
    // Expected.
    }
}
Also used : SpecialArtifact(com.google.devtools.build.lib.actions.Artifact.SpecialArtifact) Artifact(com.google.devtools.build.lib.actions.Artifact) TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact) MissingInputFileException(com.google.devtools.build.lib.actions.MissingInputFileException) Test(org.junit.Test)

Aggregations

MissingInputFileException (com.google.devtools.build.lib.actions.MissingInputFileException)8 Artifact (com.google.devtools.build.lib.actions.Artifact)5 ActionExecutionException (com.google.devtools.build.lib.actions.ActionExecutionException)3 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)2 Cause (com.google.devtools.build.lib.causes.Cause)2 LabelCause (com.google.devtools.build.lib.causes.LabelCause)2 FileStatus (com.google.devtools.build.lib.vfs.FileStatus)2 Path (com.google.devtools.build.lib.vfs.Path)2 SkyKey (com.google.devtools.build.skyframe.SkyKey)2 ValueOrException2 (com.google.devtools.build.skyframe.ValueOrException2)2 Map (java.util.Map)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 Action (com.google.devtools.build.lib.actions.Action)1 ActionAnalysisMetadata (com.google.devtools.build.lib.actions.ActionAnalysisMetadata)1 AlreadyReportedActionExecutionException (com.google.devtools.build.lib.actions.AlreadyReportedActionExecutionException)1 BuildFailedException (com.google.devtools.build.lib.actions.BuildFailedException)1