|
14 | 14 | package com.google.devtools.build.lib.buildtool;
|
15 | 15 |
|
16 | 16 | import static com.google.common.truth.Truth.assertThat;
|
| 17 | +import static com.google.devtools.build.lib.server.FailureDetails.Spawn.Code.NON_ZERO_EXIT; |
17 | 18 | import static org.junit.Assert.assertThrows;
|
18 | 19 |
|
19 | 20 | import com.google.common.collect.Iterables;
|
20 | 21 | import com.google.devtools.build.lib.actions.BuildFailedException;
|
21 | 22 | import com.google.devtools.build.lib.analysis.ViewCreationFailedException;
|
22 | 23 | import com.google.devtools.build.lib.buildtool.util.BuildIntegrationTestCase;
|
| 24 | +import com.google.devtools.build.lib.util.io.RecordingOutErr; |
23 | 25 | import com.google.testing.junit.testparameterinjector.TestParameter;
|
24 | 26 | import com.google.testing.junit.testparameterinjector.TestParameterInjector;
|
25 | 27 | import java.io.IOException;
|
@@ -149,4 +151,31 @@ public void analysisAndExecutionFailure_keepGoing_bothReported() throws Exceptio
|
149 | 151 | "Action foo/execution_failure.out failed: missing input file '//foo:missing'");
|
150 | 152 | events.assertContainsError("rule '//foo:missing' does not exist");
|
151 | 153 | }
|
| 154 | + |
| 155 | + @Test |
| 156 | + public void noSymlinkPlantedLocalAction_failureNoSuchFileOrDirectory() throws Exception { |
| 157 | + addOptions("--spawn_strategy=standalone"); |
| 158 | + write( |
| 159 | + "foo/BUILD", |
| 160 | + "genrule(", |
| 161 | + " name = 'foo',", |
| 162 | + " srcs = ['foo.in'],", |
| 163 | + " outs = ['foo.out'],", |
| 164 | + " cmd = 'cp foo.in $(location foo.out)'", |
| 165 | + ")"); |
| 166 | + write("foo/foo.in"); |
| 167 | + |
| 168 | + outErr = new RecordingOutErr(); |
| 169 | + BuildFailedException e = |
| 170 | + assertThrows(BuildFailedException.class, () -> buildTarget("//foo:foo")); |
| 171 | + String err = ((RecordingOutErr) outErr).errAsLatin1(); |
| 172 | + |
| 173 | + assertThat(e.getDetailedExitCode().getFailureDetail().getSpawn().getCode()) |
| 174 | + .isEqualTo(NON_ZERO_EXIT); |
| 175 | + assertThat(err) |
| 176 | + .contains( |
| 177 | + "Executing genrule //foo:foo failed: (Exit 1): bash failed: error executing command" |
| 178 | + + " (from target //foo:foo)"); |
| 179 | + assertThat(err).contains("No such file or directory"); |
| 180 | + } |
152 | 181 | }
|
0 commit comments