diff options
author | 2021-03-16 23:45:22 +0000 | |
---|---|---|
committer | 2021-03-18 12:18:09 +0000 | |
commit | a9237b6eebb78b64ecf8ebb4296a59636fcc2447 (patch) | |
tree | b3cc9f2d4de1a368115460fa339ab9b28adc23fc /android/package_test.go | |
parent | 3c6a4ea24a1d2a7d970f0e2dbf3c2221e3196949 (diff) |
Convert android/singleton_module_test.go to test fixtures
Bug: 182885307
Test: m nothing
Change-Id: Id77575f8ceda43545e2fad97fa1bd6b612c967b4
Diffstat (limited to 'android/package_test.go')
-rw-r--r-- | android/package_test.go | 46 |
1 files changed, 8 insertions, 38 deletions
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 -} |