product_variables srcs in prebuilt_etc
bp2build conversion handles product_variable srcs bug: 228353067 Test: prebuilt_etc_conversion_test.go Change-Id: I82d3a384ee14d4e981d502dd9eb824c87d5ae2c7
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
package bp2build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/etc"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runPrebuiltEtcTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
@@ -128,6 +129,32 @@ prebuilt_etc {
|
||||
"dir": `"etc/tz"`,
|
||||
})}})
|
||||
}
|
||||
func TestPrebuiltEtcProductVariables(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt etc - product variables",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "apex_tz_version",
|
||||
src: "version/tz_version",
|
||||
filename: "tz_version",
|
||||
product_variables: {
|
||||
native_coverage: {
|
||||
src: "src1",
|
||||
},
|
||||
},
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{
|
||||
"filename": `"tz_version"`,
|
||||
"src": `select({
|
||||
"//build/bazel/product_variables:native_coverage": "src1",
|
||||
"//conditions:default": "version/tz_version",
|
||||
})`,
|
||||
"dir": `"etc"`,
|
||||
})}})
|
||||
}
|
||||
|
||||
func runPrebuiltUsrShareTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
@@ -265,3 +292,57 @@ prebuilt_etc {
|
||||
"dir": `"etc"`,
|
||||
})}})
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcProductVariableArchSrcs(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt etc- SRcs from arch variant product variables",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "foo",
|
||||
filename: "fooFilename",
|
||||
arch: {
|
||||
arm: {
|
||||
src: "armSrc",
|
||||
product_variables: {
|
||||
native_coverage: {
|
||||
src: "nativeCoverageArmSrc",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("prebuilt_file", "foo", AttrNameToString{
|
||||
"filename": `"fooFilename"`,
|
||||
"dir": `"etc"`,
|
||||
"src": `select({
|
||||
"//build/bazel/platforms/arch:arm": "armSrc",
|
||||
"//build/bazel/product_variables:native_coverage-arm": "nativeCoverageArmSrc",
|
||||
"//conditions:default": None,
|
||||
})`,
|
||||
})}})
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcProductVariableError(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "foo",
|
||||
filename: "fooFilename",
|
||||
arch: {
|
||||
arm: {
|
||||
src: "armSrc",
|
||||
},
|
||||
},
|
||||
product_variables: {
|
||||
native_coverage: {
|
||||
src: "nativeCoverageArmSrc",
|
||||
},
|
||||
},
|
||||
}`,
|
||||
ExpectedErr: fmt.Errorf("label attribute could not be collapsed"),
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user