diff --git a/android/package_test.go b/android/package_test.go index 99be13ffa..d5b4db4a8 100644 --- a/android/package_test.go +++ b/android/package_test.go @@ -6,7 +6,7 @@ import ( var packageTests = []struct { name string - fs map[string][]byte + fs MockFS expectedErrors []string }{ // Package default_visibility handling is tested in visibility_test.go @@ -61,43 +61,13 @@ var packageTests = []struct { func TestPackage(t *testing.T) { for _, test := range packageTests { t.Run(test.name, func(t *testing.T) { - _, errs := testPackage(test.fs) - - expectedErrors := test.expectedErrors - if expectedErrors == nil { - FailIfErrored(t, errs) - } else { - for _, expectedError := range expectedErrors { - FailIfNoMatchingErrors(t, expectedError, errs) - } - if len(errs) > len(expectedErrors) { - t.Errorf("additional errors found, expected %d, found %d", len(expectedErrors), len(errs)) - for i, expectedError := range expectedErrors { - t.Errorf("expectedErrors[%d] = %s", i, expectedError) - } - for i, err := range errs { - t.Errorf("errs[%d] = %s", i, err) - } - } - } + emptyTestFixtureFactory. + ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)). + RunTest(t, + PrepareForTestWithArchMutator, + PrepareForTestWithPackageModule, + test.fs.AddToFixture(), + ) }) } } - -func testPackage(fs map[string][]byte) (*TestContext, []error) { - - // Create a new config per test as visibility information is stored in the config. - config := TestArchConfig(buildDir, nil, "", fs) - - ctx := NewTestArchContext(config) - RegisterPackageBuildComponents(ctx) - ctx.Register() - - _, errs := ctx.ParseBlueprintsFiles(".") - if len(errs) > 0 { - return ctx, errs - } - - _, errs = ctx.PrepareBuildActions(config) - return ctx, errs -}