Skip to content

Commit

Permalink
Add a test for an aspect applied to a cc_libc_top_alias target.
Browse files Browse the repository at this point in the history
Adds test coverage for an aspect on a late-bound alias whose `ConfiguredTarget` turns out not to be an alias.

PiperOrigin-RevId: 412965476
  • Loading branch information
justinhorvitz authored and copybara-github committed Nov 29, 2021
1 parent af15543 commit 9fddd56
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests for cc_libc_top_alias rule. */
/** Tests for the {@code cc_libc_top_alias} rule. */
@RunWith(JUnit4.class)
public class CcLibcTopAliasTest extends BuildViewTestCase {

Expand All @@ -35,7 +35,6 @@ public void testCcLibcTopAlias() throws Exception {
assertThat(target.getLabel().toString()).isEqualTo("//a:current_cc_libc_top");
}


@Test
public void testCcLibcTopAliasWithGrteTopArgument() throws Exception {
scratch.file("a/BUILD", "cc_libc_top_alias(name='current_cc_libc_top')");
Expand All @@ -51,4 +50,27 @@ public void testCcLibcTopAliasWithGrteTopArgument() throws Exception {

assertThat(target.getLabel().toString()).isEqualTo("//b:everything");
}

@Test
public void aspectOnCcLibcTopAlias() throws Exception {
scratch.file(
"a/defs.bzl",
"def _my_aspect_impl(target, ctx):",
" return []",
"my_aspect = aspect(implementation = _my_aspect_impl)",
"def _apply_aspect_impl(ctx):",
" pass",
"apply_aspect = rule(",
" implementation = _apply_aspect_impl,",
" attrs = {'on': attr.label(aspects = [my_aspect])},",
")");
scratch.file(
"a/BUILD",
"load(':defs.bzl', 'apply_aspect')",
"apply_aspect(name = 'apply_aspect', on = ':current_cc_libc_top')",
"cc_libc_top_alias(name = 'current_cc_libc_top')");

assertThat(getConfiguredTarget("//a:apply_aspect")).isNotNull();
assertThat(getAspect("//a:defs.bzl%my_aspect")).isNotNull();
}
}

0 comments on commit 9fddd56

Please sign in to comment.