Make bp2buildMutators registration local to TestContext.
The previous implementation relied on the implicit registration of Bp2Build mutators, resulting in test non-hermeticity. Refactor bp2build tests to explicitly specify the bp2build mutators under test.
Test: Soong tests
Test: TH
Change-Id: I9b9674bad1ea533b3bd31b07077a9e02c99b4c1d
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 66e5652..ddfb459 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -47,7 +47,7 @@
ctx.BottomUp("genrule_tool_deps", toolDepsMutator).Parallel()
})
- android.RegisterBp2BuildMutator("genrule", bp2buildMutator)
+ android.RegisterBp2BuildMutator("genrule", GenruleBp2Build)
}
var (
@@ -794,7 +794,7 @@
return module
}
-func bp2buildMutator(ctx android.TopDownMutatorContext) {
+func GenruleBp2Build(ctx android.TopDownMutatorContext) {
if m, ok := ctx.Module().(*Module); ok {
name := "__bp2build__" + m.Name()
// Bazel only has the "tools" attribute.