Add unit test for parsing build files in bp2build

This involves some minor changes to testing infrastructure.

Bug: 285631638
Fixes: 286545783
Test: unit test
Change-Id: If64ba29308d99e63a1cc5526feaf077f2cb14478
This commit is contained in:
Chris Parsons
2023-06-16 20:47:03 +00:00
parent df9c3441aa
commit e1f25230df
5 changed files with 119 additions and 47 deletions

View File

@@ -1946,3 +1946,36 @@ func TestPrettyPrintSelectMapEqualValues(t *testing.T) {
actual, _ := prettyPrintAttribute(lla, 0)
android.AssertStringEquals(t, "Print the common value if all keys in an axis have the same value", `[":libfoo.impl"]`, actual)
}
func TestAlreadyPresentBuildTarget(t *testing.T) {
bp := `
custom {
name: "foo",
}
custom {
name: "bar",
}
`
alreadyPresentBuildFile :=
MakeBazelTarget(
"custom",
"foo",
AttrNameToString{},
)
expectedBazelTargets := []string{
MakeBazelTarget(
"custom",
"bar",
AttrNameToString{},
),
}
registerCustomModule := func(ctx android.RegistrationContext) {
ctx.RegisterModuleType("custom", customModuleFactoryHostAndDevice)
}
RunBp2BuildTestCase(t, registerCustomModule, Bp2buildTestCase{
AlreadyExistingBuildContents: alreadyPresentBuildFile,
Blueprint: bp,
ExpectedBazelTargets: expectedBazelTargets,
Description: "Not duplicating work for an already-present BUILD target.",
})
}