Simplify preparers now that tests use consistent registration order

It is no longer necessary to use preparers in a specific order now that
the test infrastructure enforces a consistent registration order.

So, this change:
* Sorts preparers alphabetically to make them easier to maintain.
* Creates a single visiblity preparer for all the visibility mutators.
* Adds PrepareForTestWithPackageModule

Bug: 181070625
Bug: 181953909
Test: m nothing
Change-Id: I9e65dd182be664d8d0d5db7ccc0b63fa315129c8
This commit is contained in:
Paul Duffin
2021-03-07 13:20:38 +00:00
parent 706cb6f344
commit 530483c61e
3 changed files with 22 additions and 23 deletions

View File

@@ -1143,21 +1143,22 @@ func TestVisibility(t *testing.T) {
for _, test := range visibilityTests {
t.Run(test.name, func(t *testing.T) {
result := emptyTestFixtureFactory.Extend(
// General preparers in alphabetical order as test infrastructure will enforce correct
// registration order.
PrepareForTestWithArchMutator,
PrepareForTestWithDefaults,
PrepareForTestWithOverrides,
PrepareForTestWithPackageModule,
PrepareForTestWithPrebuilts,
PrepareForTestWithVisibility,
// Additional test specific preparers.
FixtureRegisterWithContext(func(ctx RegistrationContext) {
ctx.RegisterModuleType("mock_library", newMockLibraryModule)
ctx.RegisterModuleType("mock_parent", newMockParentFactory)
ctx.RegisterModuleType("mock_defaults", defaultsFactory)
}),
prepareForTestWithFakePrebuiltModules,
PrepareForTestWithPackageModule,
// Order of the following method calls is significant as they register mutators.
PrepareForTestWithArchMutator,
PrepareForTestWithPrebuilts,
PrepareForTestWithOverrides,
PrepareForTestWithVisibilityRuleChecker,
PrepareForTestWithDefaults,
PrepareForTestWithVisibilityRuleGatherer,
PrepareForTestWithVisibilityRuleEnforcer,
// Add additional files to the mock filesystem
test.fs.AddToFixture(),
).