bazel syntax: hide EvalUtils.execToplevelStatement
All file execution now happens through EvalUtils.exec(StarlarkFile)
or EvalUtils.execOrEval (which I plan to eliminate in a followup).
Clients do not execute individual statements.
This requires a temporary hack: StarlarkThread.postAssignHook is a
hook that clients can install to be notified of each assignment at top
level. SkylarkImportLookupFunction uses it to "export" values such as
rules, aspects, and transitions during execution, instead of at the
end of execution. (The behavior will be changed soon; see unknown commit
and b/65374671.)
This may seem like two steps forward and one back, but it will allow us
to develop the EvalUtils API, in particular, turning the top-level statements
of a StarlarkFile into a StarlarkFunction, leading to a consistent treatment
of the call stack.
Also:
- EvalUtils.debugExec is now expressible in terms of the API,
and has been moved up into the debugger.
- Identifier.boundIdentifiers is no longer public.
- Minor simplifications to tests.
PiperOrigin-RevId: 273741627
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
index 1f20b01..f490bf6 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
@@ -70,11 +70,9 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-/**
- * Tests for SkylarkRuleClassFunctions.
- */
+/** Tests for SkylarkRuleClassFunctions. */
@RunWith(JUnit4.class)
-public class SkylarkRuleClassFunctionsTest extends SkylarkTestCase {
+public final class SkylarkRuleClassFunctionsTest extends SkylarkTestCase {
@Rule public ExpectedException thrown = ExpectedException.none();
@Before
@@ -703,10 +701,10 @@
assertThat(c.hasAttr("a1", Type.STRING)).isTrue();
}
- protected void evalAndExport(String... lines) throws Exception {
+ private void evalAndExport(String... lines) throws Exception {
ParserInput input = ParserInput.fromLines(lines);
StarlarkFile file = EvalUtils.parseAndValidateSkylark(input, ev.getStarlarkThread());
- if (!file.errors().isEmpty()) {
+ if (!file.ok()) {
throw new SyntaxError(file.errors());
}
SkylarkImportLookupFunction.execAndExport(