Convert android/packaging_test.go to test fixtures

Bug: 182885307
Test: m nothing
Change-Id: Ic2384bfe3f1edb8d252053fda7df66d49c46fd0f
This commit is contained in:
Paul Duffin 2021-03-17 00:06:49 +00:00
parent d9ec7d2694
commit c3bdd310bd
1 changed files with 13 additions and 17 deletions

View File

@ -15,7 +15,6 @@
package android
import (
"reflect"
"testing"
"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) {
t.Helper()
config := TestArchConfig(buildDir, nil, bp, nil)
ctx := NewTestArchContext(config)
ctx.RegisterModuleType("component", componentTestModuleFactory)
var archVariant string
var moduleFactory ModuleFactory
if multitarget {
archVariant = "android_common"
ctx.RegisterModuleType("package_module", packageMultiTargetTestModuleFactory)
moduleFactory = packageMultiTargetTestModuleFactory
} else {
archVariant = "android_arm64_armv8-a"
ctx.RegisterModuleType("package_module", packageTestModuleFactory)
moduleFactory = packageTestModuleFactory
}
ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
FailIfErrored(t, errs)
result := emptyTestFixtureFactory.RunTest(t,
PrepareForTestWithArchMutator,
FixtureRegisterWithContext(func(ctx RegistrationContext) {
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 = SortedUniqueStrings(actual)
expected = SortedUniqueStrings(expected)
if !reflect.DeepEqual(actual, expected) {
t.Errorf("\ngot: %v\nexpected: %v\n", actual, expected)
}
AssertDeepEquals(t, "package entries", expected, actual)
}
func TestPackagingBaseMultiTarget(t *testing.T) {