From 32e841d5b4463ebc057ed2c3471f16153ffea0e9 Mon Sep 17 00:00:00 2001 From: leba Date: Fri, 8 Apr 2022 03:03:17 -0700 Subject: [PATCH] Add a test to document the fact the local actions fail with Skymeld. PiperOrigin-RevId: 440318640 --- .../google/devtools/build/lib/buildtool/BUILD | 2 ++ .../SkymeldBuildIntegrationTest.java | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/BUILD b/src/test/java/com/google/devtools/build/lib/buildtool/BUILD index 0cf35e9e77d439..706a54c9bc8620 100644 --- a/src/test/java/com/google/devtools/build/lib/buildtool/BUILD +++ b/src/test/java/com/google/devtools/build/lib/buildtool/BUILD @@ -640,6 +640,8 @@ java_test( "//src/main/java/com/google/devtools/build/lib:runtime", "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/analysis:view_creation_failed_exception", + "//src/main/java/com/google/devtools/build/lib/util/io", + "//src/main/protobuf:failure_details_java_proto", "//src/test/java/com/google/devtools/build/lib/buildtool/util", "//third_party:guava", "//third_party:junit4", diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/SkymeldBuildIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/buildtool/SkymeldBuildIntegrationTest.java index 101ecdb0aa7a3d..bc2a0be5dc499d 100644 --- a/src/test/java/com/google/devtools/build/lib/buildtool/SkymeldBuildIntegrationTest.java +++ b/src/test/java/com/google/devtools/build/lib/buildtool/SkymeldBuildIntegrationTest.java @@ -14,12 +14,14 @@ package com.google.devtools.build.lib.buildtool; import static com.google.common.truth.Truth.assertThat; +import static com.google.devtools.build.lib.server.FailureDetails.Spawn.Code.NON_ZERO_EXIT; import static org.junit.Assert.assertThrows; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.BuildFailedException; import com.google.devtools.build.lib.analysis.ViewCreationFailedException; import com.google.devtools.build.lib.buildtool.util.BuildIntegrationTestCase; +import com.google.devtools.build.lib.util.io.RecordingOutErr; import com.google.testing.junit.testparameterinjector.TestParameter; import com.google.testing.junit.testparameterinjector.TestParameterInjector; import java.io.IOException; @@ -149,4 +151,31 @@ public void analysisAndExecutionFailure_keepGoing_bothReported() throws Exceptio "Action foo/execution_failure.out failed: missing input file '//foo:missing'"); events.assertContainsError("rule '//foo:missing' does not exist"); } + + @Test + public void noSymlinkPlantedLocalAction_failureNoSuchFileOrDirectory() throws Exception { + addOptions("--spawn_strategy=standalone"); + write( + "foo/BUILD", + "genrule(", + " name = 'foo',", + " srcs = ['foo.in'],", + " outs = ['foo.out'],", + " cmd = 'cp foo.in $(location foo.out)'", + ")"); + write("foo/foo.in"); + + outErr = new RecordingOutErr(); + BuildFailedException e = + assertThrows(BuildFailedException.class, () -> buildTarget("//foo:foo")); + String err = ((RecordingOutErr) outErr).errAsLatin1(); + + assertThat(e.getDetailedExitCode().getFailureDetail().getSpawn().getCode()) + .isEqualTo(NON_ZERO_EXIT); + assertThat(err) + .contains( + "Executing genrule //foo:foo failed: (Exit 1): bash failed: error executing command" + + " (from target //foo:foo)"); + assertThat(err).contains("No such file or directory"); + } }