|  | 
| 30 | 30 | import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; | 
| 31 | 31 | import com.google.devtools.build.lib.testutil.TestConstants; | 
| 32 | 32 | import com.google.devtools.build.lib.testutil.TestRuleClassProvider; | 
|  | 33 | +import com.google.devtools.build.lib.vfs.ModifiedFileSet; | 
|  | 34 | +import com.google.devtools.build.lib.vfs.PathFragment; | 
|  | 35 | +import com.google.devtools.build.lib.vfs.Root; | 
| 33 | 36 | import com.google.testing.junit.testparameterinjector.TestParameterInjector; | 
| 34 | 37 | import com.google.testing.junit.testparameterinjector.TestParameters; | 
| 35 | 38 | import java.util.List; | 
| @@ -1692,4 +1695,67 @@ public void testNoPlatformChange() throws Exception { | 
| 1692 | 1695 |                 .platforms) | 
| 1693 | 1696 |         .containsExactly(Label.parseAbsoluteUnchecked("//platforms:my_platform")); | 
| 1694 | 1697 |   } | 
|  | 1698 | + | 
|  | 1699 | +  @Test | 
|  | 1700 | +  public void testTransitionsStillTriggerWhenOnlyRuleAttributesChange() throws Exception { | 
|  | 1701 | +    scratch.file( | 
|  | 1702 | +        "test/defs.bzl", | 
|  | 1703 | +        "def _transition_impl(settings, attr):", | 
|  | 1704 | +        "  return {", | 
|  | 1705 | +        "    '//command_line_option:foo': attr.my_attr,", | 
|  | 1706 | +        "  }", | 
|  | 1707 | +        "_my_transition = transition(", | 
|  | 1708 | +        "  implementation = _transition_impl,", | 
|  | 1709 | +        "  inputs = [],", | 
|  | 1710 | +        "  outputs = [", | 
|  | 1711 | +        "    '//command_line_option:foo',", | 
|  | 1712 | +        "  ]", | 
|  | 1713 | +        ")", | 
|  | 1714 | +        "def _rule_impl(ctx):", | 
|  | 1715 | +        "  return []", | 
|  | 1716 | +        "my_rule = rule(", | 
|  | 1717 | +        "  implementation = _rule_impl,", | 
|  | 1718 | +        "  cfg = _my_transition,", | 
|  | 1719 | +        "  attrs = {", | 
|  | 1720 | +        "    'my_attr': attr.string(),", | 
|  | 1721 | +        "    '_allowlist_function_transition': attr.label(", | 
|  | 1722 | +        "        default = '//tools/allowlists/function_transition_allowlist',", | 
|  | 1723 | +        "    ),", | 
|  | 1724 | +        "  },", | 
|  | 1725 | +        ")"); | 
|  | 1726 | +    writeAllowlistFile(); | 
|  | 1727 | + | 
|  | 1728 | +    scratch.file( | 
|  | 1729 | +        "test/BUILD", | 
|  | 1730 | +        "load('//test:defs.bzl', 'my_rule')", | 
|  | 1731 | +        "my_rule(", | 
|  | 1732 | +        "  name = 'buildme',", | 
|  | 1733 | +        "  my_attr = 'first build',", | 
|  | 1734 | +        ")"); | 
|  | 1735 | +    assertThat( | 
|  | 1736 | +            getConfiguration(getConfiguredTarget("//test:buildme")) | 
|  | 1737 | +                .getOptions() | 
|  | 1738 | +                .get(DummyTestOptions.class) | 
|  | 1739 | +                .foo) | 
|  | 1740 | +        .isEqualTo("first build"); | 
|  | 1741 | + | 
|  | 1742 | +    scratch.overwriteFile( | 
|  | 1743 | +        "test/BUILD", | 
|  | 1744 | +        "load('//test:defs.bzl', 'my_rule')", | 
|  | 1745 | +        "my_rule(", | 
|  | 1746 | +        "  name = 'buildme',", | 
|  | 1747 | +        "  my_attr = 'second build',", | 
|  | 1748 | +        ")"); | 
|  | 1749 | +    skyframeExecutor.invalidateFilesUnderPathForTesting( | 
|  | 1750 | +        reporter, | 
|  | 1751 | +        ModifiedFileSet.builder().modify(PathFragment.create("test/BUILD")).build(), | 
|  | 1752 | +        Root.fromPath(rootDirectory)); | 
|  | 1753 | + | 
|  | 1754 | +    assertThat( | 
|  | 1755 | +            getConfiguration(getConfiguredTarget("//test:buildme")) | 
|  | 1756 | +                .getOptions() | 
|  | 1757 | +                .get(DummyTestOptions.class) | 
|  | 1758 | +                .foo) | 
|  | 1759 | +        .isEqualTo("second build"); | 
|  | 1760 | +  } | 
| 1695 | 1761 | } | 
0 commit comments