Merge "Simplify preparers now that tests use consistent registration order"
This commit is contained in:
commit
9c35c5d2a6
3 changed files with 22 additions and 23 deletions
|
@ -75,15 +75,16 @@ var PrepareForTestWithOverrides = FixtureRegisterWithContext(func(ctx Registrati
|
|||
|
||||
// Prepares an integration test with build components from the android package.
|
||||
var PrepareForIntegrationTestWithAndroid = GroupFixturePreparers(
|
||||
// Mutators. Must match order in mutator.go.
|
||||
// Sorted alphabetically as the actual order does not matter as tests automatically enforce the
|
||||
// correct order.
|
||||
PrepareForTestWithArchMutator,
|
||||
PrepareForTestWithDefaults,
|
||||
PrepareForTestWithComponentsMutator,
|
||||
PrepareForTestWithPrebuilts,
|
||||
PrepareForTestWithOverrides,
|
||||
|
||||
// Modules
|
||||
PrepareForTestWithDefaults,
|
||||
PrepareForTestWithFilegroup,
|
||||
PrepareForTestWithOverrides,
|
||||
PrepareForTestWithPackageModule,
|
||||
PrepareForTestWithPrebuilts,
|
||||
PrepareForTestWithVisibility,
|
||||
)
|
||||
|
||||
func NewTestArchContext(config Config) *TestContext {
|
||||
|
|
|
@ -202,17 +202,14 @@ type ExcludeFromVisibilityEnforcementTag interface {
|
|||
ExcludeFromVisibilityEnforcement()
|
||||
}
|
||||
|
||||
var PrepareForTestWithVisibilityRuleChecker = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||
// The visibility mutators.
|
||||
var PrepareForTestWithVisibility = FixtureRegisterWithContext(registerVisibilityMutators)
|
||||
|
||||
func registerVisibilityMutators(ctx RegistrationContext) {
|
||||
ctx.PreArchMutators(RegisterVisibilityRuleChecker)
|
||||
})
|
||||
|
||||
var PrepareForTestWithVisibilityRuleGatherer = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||
ctx.PreArchMutators(RegisterVisibilityRuleGatherer)
|
||||
})
|
||||
|
||||
var PrepareForTestWithVisibilityRuleEnforcer = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||
ctx.PostDepsMutators(RegisterVisibilityRuleEnforcer)
|
||||
})
|
||||
}
|
||||
|
||||
// The rule checker needs to be registered before defaults expansion to correctly check that
|
||||
// //visibility:xxx isn't combined with other packages in the same list in any one module.
|
||||
|
|
|
@ -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(),
|
||||
).
|
||||
|
|
Loading…
Reference in a new issue