Convert android/singleton_module_test.go to test fixtures
Bug: 182885307 Test: m nothing Change-Id: Id77575f8ceda43545e2fad97fa1bd6b612c967b4
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user