Skip to content

Commit

Permalink
Calculate target_rule_type_name correctly
Browse files Browse the repository at this point in the history
Summary: When we have a transition on a rule, we want the `target_rule_type_name` to be the actual rule type, rather than always just being `"forward"`.

Reviewed By: JakobDegen

Differential Revision: D66312159

fbshipit-source-id: aa6a0c1475b97c5d1928a8dd278973990237a3b2
  • Loading branch information
Ian Childs authored and facebook-github-bot committed Nov 26, 2024
1 parent 92ebaa5 commit f556953
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/buck2_build_api/src/actions/calculation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ pub async fn get_target_rule_type_name(
.get_configured_target_node(label)
.await?
.require_compatible()?
.rule_type()
.underlying_rule_type()
.name()
.to_owned())
}
11 changes: 11 additions & 0 deletions app/buck2_node/src/nodes/configured.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ impl TargetNodeOrForward {
}
}

fn underlying_rule_type(&self) -> &RuleType {
match self {
TargetNodeOrForward::TargetNode(target_node) => target_node.rule_type(),
TargetNodeOrForward::Forward(_, node) => node.underlying_rule_type(),
}
}

fn rule_kind(&self) -> RuleKind {
match self {
TargetNodeOrForward::TargetNode(x) => x.rule_kind(),
Expand Down Expand Up @@ -433,6 +440,10 @@ impl ConfiguredTargetNode {
self.0.target_node.rule_type()
}

pub fn underlying_rule_type(&self) -> &RuleType {
self.0.target_node.underlying_rule_type()
}

pub fn rule_kind(&self) -> RuleKind {
self.0.target_node.rule_kind()
}
Expand Down
7 changes: 3 additions & 4 deletions tests/core/build/test_build_rule_type_name_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ async def test_build_rule_with_transition(buck: Buck) -> None:
"//:a_writer_with_transition",
)

# TODO(T208425986) This should not be "forward"
await check_rule_type_names(buck, ["forward"])
await check_rule_type_names(buck, ["three_with_transition"])


@buck_test()
Expand All @@ -76,7 +75,7 @@ async def test_build_all_in_target(buck: Buck) -> None:
buck,
[
"two",
"forward",
"three_with_transition",
"nested_subtargets",
"one",
"one",
Expand All @@ -94,7 +93,7 @@ async def test_build_all_recursive(buck: Buck) -> None:
buck,
[
"two",
"forward",
"three_with_transition",
"nested_subtargets",
"one",
"one",
Expand Down

0 comments on commit f556953

Please sign in to comment.