Merge "Convert android/packaging_test.go to test fixtures" am: 813bfcb252
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1645098 Change-Id: I656567ac9b750e1c37488abe92a8f20b68db0606
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
@@ -87,33 +86,30 @@ func (m *packageTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|||||||
func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []string) {
|
func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
config := TestArchConfig(buildDir, nil, bp, nil)
|
|
||||||
|
|
||||||
ctx := NewTestArchContext(config)
|
|
||||||
ctx.RegisterModuleType("component", componentTestModuleFactory)
|
|
||||||
|
|
||||||
var archVariant string
|
var archVariant string
|
||||||
|
var moduleFactory ModuleFactory
|
||||||
if multitarget {
|
if multitarget {
|
||||||
archVariant = "android_common"
|
archVariant = "android_common"
|
||||||
ctx.RegisterModuleType("package_module", packageMultiTargetTestModuleFactory)
|
moduleFactory = packageMultiTargetTestModuleFactory
|
||||||
} else {
|
} else {
|
||||||
archVariant = "android_arm64_armv8-a"
|
archVariant = "android_arm64_armv8-a"
|
||||||
ctx.RegisterModuleType("package_module", packageTestModuleFactory)
|
moduleFactory = packageTestModuleFactory
|
||||||
}
|
}
|
||||||
ctx.Register()
|
|
||||||
|
|
||||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
result := emptyTestFixtureFactory.RunTest(t,
|
||||||
FailIfErrored(t, errs)
|
PrepareForTestWithArchMutator,
|
||||||
_, errs = ctx.PrepareBuildActions(config)
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
FailIfErrored(t, errs)
|
ctx.RegisterModuleType("component", componentTestModuleFactory)
|
||||||
|
ctx.RegisterModuleType("package_module", moduleFactory)
|
||||||
|
}),
|
||||||
|
FixtureWithRootAndroidBp(bp),
|
||||||
|
)
|
||||||
|
|
||||||
p := ctx.ModuleForTests("package", archVariant).Module().(*packageTestModule)
|
p := result.Module("package", archVariant).(*packageTestModule)
|
||||||
actual := p.entries
|
actual := p.entries
|
||||||
actual = SortedUniqueStrings(actual)
|
actual = SortedUniqueStrings(actual)
|
||||||
expected = SortedUniqueStrings(expected)
|
expected = SortedUniqueStrings(expected)
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
AssertDeepEquals(t, "package entries", expected, actual)
|
||||||
t.Errorf("\ngot: %v\nexpected: %v\n", actual, expected)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPackagingBaseMultiTarget(t *testing.T) {
|
func TestPackagingBaseMultiTarget(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user