Automated rollback of commit 351cc1638f7f3613c01b42796cd9b069d21ffaa7.
*** Reason for rollback ***
Verbose error message not needed
*** Original change description ***
Emit more useful information when analyzing inline bzl code
RELNOTES: Improved error messages when analyzing inline bzl code
PiperOrigin-RevId: 472990366
Change-Id: I655e5ef10754aa9adb5ac67a379fe55a490b599d
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BzlCompileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/BzlCompileFunction.java
index e8d5f0c..8dc5c76 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/BzlCompileFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/BzlCompileFunction.java
@@ -178,10 +178,9 @@
} catch (SyntaxError.Exception ex) {
Event.replayEventsOn(env.getListener(), ex.errors());
return BzlCompileValue.noFile(
- "compilation of module '%s'%s failed: %s",
+ "compilation of module '%s'%s failed",
key.label.toPathFragment(),
- StarlarkBuiltinsValue.isBuiltinsRepo(key.label.getRepository()) ? " (internal)" : "",
- ex.getMessage());
+ StarlarkBuiltinsValue.isBuiltinsRepo(key.label.getRepository()) ? " (internal)" : "");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/BzlCompileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/BzlCompileFunctionTest.java
index 9930801..54ce1a8 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/BzlCompileFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/BzlCompileFunctionTest.java
@@ -16,7 +16,6 @@
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
@@ -167,35 +166,4 @@
assertThat(val.toString()).isEqualTo("[-9223372036854775809, 9223372036854775808]");
}
}
-
- @Test
- public void testErrorMessageContainsExceptionInfo() throws Exception {
- // If an analysis error occurs, the cause of that error should be communicated to the user.
- // Check that syntax errors in remote repositories are percolated back to the user.
- scratch.overwriteFile(
- "WORKSPACE",
- "local_repository(",
- " name = 'a_remote_repo',",
- " path = '/a_remote_repo'",
- ")");
- Path repoPath = scratch.dir("/a_remote_repo");
- scratch.file("/a_remote_repo/WORKSPACE");
- scratch.file("/a_remote_repo/remote_pkg/BUILD", "load(':foo.bzl', 'broken')");
- scratch.file("/a_remote_repo/remote_pkg/foo.bzl", "def broken():", " undefined_token");
- invalidatePackages(/*alsoConfigs=*/ false); // Repository shuffling messes with toolchains.
- SkyKey skyKey =
- BzlCompileValue.key(
- Root.fromPath(repoPath),
- Label.parseAbsoluteUnchecked("@a_remote_repo//remote_pkg:foo.bzl"));
- AssertionError e =
- assertThrows(
- AssertionError.class,
- () ->
- SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skyKey, /*keepGoing=*/ false, reporter));
- assertThat(e)
- .hasMessageThat()
- .contains(
- "ERROR /a_remote_repo/remote_pkg/foo.bzl:2:3: name 'undefined_token' is not defined");
- }
}