diff options
author | 2016-11-11 02:45:29 +0000 | |
---|---|---|
committer | 2016-11-11 10:05:15 +0000 | |
commit | 33aa306d3420ba406acdf998208f438e88bebe4b (patch) | |
tree | 99a05fd7eca35c374f274575f3a1e103e35484fb /src/test | |
parent | 9048164b509762ed54291b18fbd2e7be27443b95 (diff) |
Expose aspect-related information in the extra-action proto that Bazel hands to action_listener() rules.
RELNOTES: Extra actions now contain aspect-related information.
--
MOS_MIGRATED_REVID=138832922
Diffstat (limited to 'src/test')
3 files changed, 55 insertions, 4 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java index 53b83c682e..81fbd6c0dc 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java +++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java @@ -190,7 +190,14 @@ public final class ActionsTestUtil { public static final ActionOwner NULL_ACTION_OWNER = ActionOwner.create( - NULL_LABEL, null, "dummy-configuration-mnemonic", null, "dummy-configuration", null); + NULL_LABEL, + null, + null, + null, + "dummy-configuration-mnemonic", + null, + "dummy-configuration", + null); public static final ArtifactOwner NULL_ARTIFACT_OWNER = new ArtifactOwner() { diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java index 80b8ab9448..3c87b27e9f 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.analysis.actions; +import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.util.Arrays.asList; @@ -24,6 +25,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; +import com.google.common.eventbus.EventBus; import com.google.devtools.build.lib.actions.AbstractAction; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; @@ -420,4 +422,44 @@ public class SpawnActionTest extends BuildViewTestCase { fail("Expected exception"); } catch (IllegalArgumentException expected) {} } + + /** + * Tests that the ExtraActionInfo proto that's generated from an action, contains Aspect-related + * information. + */ + @Test + public void testGetExtraActionInfoOnAspects() throws Exception { + scratch.file( + "a/BUILD", + "load('//a:def.bzl', 'testrule')", + "testrule(name='a', deps=[':b'])", + "testrule(name='b')"); + scratch.file( + "a/def.bzl", + "def _aspect_impl(target, ctx):", + " f = ctx.new_file('foo.txt')", + " ctx.action(outputs = [f], command = 'echo foo > \"$1\"')", + " return struct(output=f)", + "def _rule_impl(ctx):", + " return struct(files=set([artifact.output for artifact in ctx.attr.deps]))", + "aspect1 = aspect(_aspect_impl, attr_aspects=['deps'], ", + " attrs = {'parameter': attr.string(values = ['param_value'])})", + "testrule = rule(_rule_impl, attrs = { ", + " 'deps' : attr.label_list(aspects = [aspect1]), ", + " 'parameter': attr.string(default='param_value') })"); + + update( + ImmutableList.of("//a:a"), + false /* keepGoing */, + 1 /* loadingPhaseThreads */, + true /* doAnalysis */, + new EventBus()); + + Artifact artifact = getOnlyElement(getFilesToBuild(getConfiguredTarget("//a:a"))); + ExtraActionInfo.Builder extraActionInfo = getGeneratingAction(artifact).getExtraActionInfo(); + assertThat(extraActionInfo.getAspectName()).isEqualTo("//a:def.bzl%aspect1"); + assertThat(extraActionInfo.getAspectParametersMap()) + .containsExactly( + "parameter", ExtraActionInfo.StringList.newBuilder().addValue("param_value").build()); + } } diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java index 5594a32734..e841310da1 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java @@ -390,7 +390,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { "/home/user/bazel/out/abcdef/some/very/very/long/path/for/some/library/directory/foo.jar"); Label label = Label.parseAbsolute("//some/very/very/long/path/for/some/library/directory:libfoo"); - ActionOwner owner = ActionOwner.create(label, null, null, null, "fedcba", null); + ActionOwner owner = ActionOwner.create(label, null, null, null, null, null, "fedcba", null); when(action.getOwner()).thenReturn(owner); clock.advanceMillis(TimeUnit.SECONDS.toMillis(3)); @@ -517,7 +517,8 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { Label labelFooTest = Label.parseAbsolute("//foo/bar:footest"); ConfiguredTarget targetFooTest = Mockito.mock(ConfiguredTarget.class); when(targetFooTest.getLabel()).thenReturn(labelFooTest); - ActionOwner fooOwner = ActionOwner.create(labelFooTest, null, null, null, "abcdef", null); + ActionOwner fooOwner = + ActionOwner.create(labelFooTest, null, null, null, null, null, "abcdef", null); Label labelBarTest = Label.parseAbsolute("//baz:bartest"); ConfiguredTarget targetBarTest = Mockito.mock(ConfiguredTarget.class); @@ -525,7 +526,8 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class); when(filteringComplete.getTestTargets()) .thenReturn(ImmutableSet.of(targetFooTest, targetBarTest)); - ActionOwner barOwner = ActionOwner.create(labelBarTest, null, null, null, "fedcba", null); + ActionOwner barOwner = + ActionOwner.create(labelBarTest, null, null, null, null, null, "fedcba", null); stateTracker.testFilteringComplete(filteringComplete); |