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:
@@ -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.",
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user