Rollback of commit f341bc4f6e918b6a41c1536c111bbf24f14f967b.

*** Reason for rollback ***

Depends on c/135226123 which depends on commit 9c25afe750a937b2152c21a93effc8b9ba82c27b, which needs to be rolled
back.

*** Original change description ***

Add ctx.get_actions(), for inspecting the actions created by the current rule.

This returns an ActionsProvider. In the case where the rule does not emit any
more actions afterwards, the provider is equivalent to the one that gets passed
on to the rule's dependencies.

This may be useful for unit testing analysis-time helper functions that take
in ctx and have the side-effect of creating actions. In this use case, the
testing rule should be marked _skylark_testable=True, and its implementation
f...

***

--
MOS_MIGRATED_REVID=135781162
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
index 9247001..292f123 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
@@ -285,10 +285,7 @@
             doc = "<i>(Experimental)</i> "
                 + "If true, this rule will expose its actions for inspection by rules that depend "
                 + "on it via an <a href=\"ActionsSkylarkApiProvider.html\">actions</a> provider."
-                + "The provider is also available to the rule itself by calling "
-                + "<code>ctx.created_actions()</code>."
-                + ""
-                + "<p>This should only be used for testing the analysis-time behavior of Skylark "
+                + "This should only be used for testing the analysis-time behavior of Skylark "
                 + "rules. This flag may be removed in the future.")},
       useAst = true, useEnvironment = true)
   private static final BuiltinFunction rule = new BuiltinFunction("rule") {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
index 31ad280..2db3649 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
@@ -22,7 +22,6 @@
 import com.google.common.collect.Iterables;
 import com.google.devtools.build.lib.actions.Artifact;
 import com.google.devtools.build.lib.actions.Root;
-import com.google.devtools.build.lib.analysis.ActionsProvider;
 import com.google.devtools.build.lib.analysis.AnalysisUtils;
 import com.google.devtools.build.lib.analysis.ConfigurationMakeVariableContext;
 import com.google.devtools.build.lib.analysis.FilesToRunProvider;
@@ -165,8 +164,8 @@
   public SkylarkRuleContext(RuleContext ruleContext, Kind kind)
       throws EvalException, InterruptedException {
     this.ruleContext = Preconditions.checkNotNull(ruleContext);
-    this.fragments = new FragmentCollection(ruleContext, ConfigurationTransition.NONE);
-    this.hostFragments = new FragmentCollection(ruleContext, ConfigurationTransition.HOST);
+    fragments = new FragmentCollection(ruleContext, ConfigurationTransition.NONE);
+    hostFragments = new FragmentCollection(ruleContext, ConfigurationTransition.HOST);
 
     if (kind == Kind.RULE) {
       Collection<Attribute> attributes = ruleContext.getRule().getAttributes();
@@ -420,24 +419,6 @@
     return ruleContext;
   }
 
-  @SkylarkCallable(name = "created_actions",
-      doc = "For rules marked <code>_skylark_testable=True</code>, this returns an "
-          + "<a href=\"ActionsSkylarkApiProvider.html\">actions</a> provider representing all "
-          + "actions created so far for the current rule. For all other rules, returns None. "
-          + "Note that the provider is not updated when subsequent actions are created, so you "
-          + "will have to call this function again if you wish to inspect them. "
-          + ""
-          + "<p>This is intended to help test rule-implementation helper functions that take in a "
-          + "<a href=\"ctx.html\">ctx</a> object and create actions for it.")
-  public Object createdActions() {
-    if (ruleContext.getRule().getRuleClassObject().isSkylarkTestable()) {
-      return ActionsProvider.create(
-          ruleContext.getAnalysisEnvironment().getRegisteredActions());
-    } else {
-      return Runtime.NONE;
-    }
-  }
-
   @SkylarkCallable(name = "attr", structField = true, doc = ATTR_DOC)
   public SkylarkClassObject getAttr() {
     return attributesCollection.getAttr();
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
index 674aa40..6066c41 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
@@ -1029,7 +1029,7 @@
   // The common structure of the following actions tests is a rule under test depended upon by
   // a testing rule, where the rule under test has one output and one caller-supplied action.
 
-  private String getSimpleUnderTestDefinition(String actionLine, boolean withSkylarkTestable) {
+  private String getSimpleUnderTestDefinition(String actionLine) {
     return linesAsString(
       "def _undertest_impl(ctx):",
       "  out = ctx.outputs.out",
@@ -1037,18 +1037,10 @@
       "undertest_rule = rule(",
       "  implementation = _undertest_impl,",
       "  outputs = {'out': '%{name}.txt'},",
-      withSkylarkTestable ? "  _skylark_testable = True," : "",
+      "  _skylark_testable = True,",
       ")");
   }
 
-  private String getSimpleUnderTestDefinition(String actionLine) {
-    return getSimpleUnderTestDefinition(actionLine, true);
-  }
-
-  private String getSimpleNontestableUnderTestDefinition(String actionLine) {
-    return getSimpleUnderTestDefinition(actionLine, false);
-  }
-
   private final String testingRuleDefinition =
     linesAsString(
       "def _testing_impl(ctx):",
@@ -1097,8 +1089,13 @@
   public void testNoAccessToDependencyActionsWithoutSkylarkTest() throws Exception {
     reporter.removeHandler(failFastHandler);
     scratch.file("test/rules.bzl",
-        getSimpleNontestableUnderTestDefinition(
-            "ctx.action(outputs=[out], command='echo foo123 > ' + out.path)"),
+        "def _undertest_impl(ctx):",
+        "  out = ctx.outputs.out",
+        "  ctx.action(outputs=[out], command='echo foo123 > ' + out.path)",
+        "undertest_rule = rule(",
+        "  implementation = _undertest_impl,",
+        "  outputs = {'out': '%{name}.txt'},",
+        ")",
         testingRuleDefinition);
     scratch.file("test/BUILD",
         simpleBuildDefinition);
@@ -1151,66 +1148,6 @@
     assertThat(eval("list(action2.outputs)")).isEqualTo(eval("[file2]"));
   }
 
-  // For created_actions() tests, the "undertest" rule represents both the code under test and the
-  // Skylark user test code itself.
-
-  @Test
-  public void testCreatedActions() throws Exception {
-    // createRuleContext() gives us the context for a rule upon entry into its analysis function.
-    // But we need to inspect the result of calling created_actions() after the rule context has
-    // been modified by creating actions. So we'll call created_actions() from within the analysis
-    // function and pass it along as a provider.
-    scratch.file("test/rules.bzl",
-        "def _undertest_impl(ctx):",
-        "  out1 = ctx.outputs.out1",
-        "  out2 = ctx.outputs.out2",
-        "  ctx.action(outputs=[out1], command='echo foo123 > ' + out1.path,",
-        "             mnemonic='foo')",
-        "  v = ctx.created_actions().by_file",
-        "  ctx.action(outputs=[out2], command='echo bar123 > ' + out2.path)",
-        "  return struct(v=v, out1=out1, out2=out2)",
-        "undertest_rule = rule(",
-        "  implementation = _undertest_impl,",
-        "  outputs = {'out1': '%{name}1.txt',",
-        "             'out2': '%{name}2.txt'},",
-        "  _skylark_testable = True,",
-        ")",
-        testingRuleDefinition
-        );
-    scratch.file("test/BUILD",
-        simpleBuildDefinition);
-    SkylarkRuleContext ruleContext = createRuleContext("//test:testing");
-
-    Object mapUnchecked = evalRuleContextCode(ruleContext, "ruleContext.attr.dep.v");
-    assertThat(mapUnchecked).isInstanceOf(SkylarkDict.class);
-    SkylarkDict<?, ?> map = (SkylarkDict<?, ?>) mapUnchecked;
-    // Should only have the first action because created_actions() was called
-    // before the second action was created.
-    Object file = eval("ruleContext.attr.dep.out1");
-    assertThat(map).hasSize(1);
-    assertThat(map).containsKey(file);
-    Object actionUnchecked = map.get(file);
-    assertThat(actionUnchecked).isInstanceOf(ActionAnalysisMetadata.class);
-    assertThat(((ActionAnalysisMetadata) actionUnchecked).getMnemonic()).isEqualTo("foo");
-  }
-
-  @Test
-  public void testNoAccessToCreatedActionsWithoutSkylarkTest() throws Exception {
-    scratch.file("test/rules.bzl",
-        getSimpleNontestableUnderTestDefinition(
-            "ctx.action(outputs=[out], command='echo foo123 > ' + out.path)")
-        );
-    scratch.file("test/BUILD",
-        "load(':rules.bzl', 'undertest_rule')",
-        "undertest_rule(",
-        "    name = 'undertest',",
-        ")");
-    SkylarkRuleContext ruleContext = createRuleContext("//test:undertest");
-
-    Object result = evalRuleContextCode(ruleContext, "ruleContext.created_actions()");
-    assertThat(result).isEqualTo(Runtime.NONE);
-  }
-
   @Test
   public void testSpawnActionInterface() throws Exception {
     scratch.file("test/rules.bzl",