diff --git a/android/fixture.go b/android/fixture.go index ae24b914f..b88300a06 100644 --- a/android/fixture.go +++ b/android/fixture.go @@ -61,15 +61,15 @@ import ( // register module bar twice: // var Preparer1 = FixtureRegisterWithContext(RegisterModuleFooAndBar) // var Preparer2 = FixtureRegisterWithContext(RegisterModuleBarAndBaz) -// var AllPreparers = FixturePreparers(Preparer1, Preparer2) +// var AllPreparers = GroupFixturePreparers(Preparer1, Preparer2) // // However, when restructured like this it would work fine: // var PreparerFoo = FixtureRegisterWithContext(RegisterModuleFoo) // var PreparerBar = FixtureRegisterWithContext(RegisterModuleBar) // var PreparerBaz = FixtureRegisterWithContext(RegisterModuleBaz) -// var Preparer1 = FixturePreparers(RegisterModuleFoo, RegisterModuleBar) -// var Preparer2 = FixturePreparers(RegisterModuleBar, RegisterModuleBaz) -// var AllPreparers = FixturePreparers(Preparer1, Preparer2) +// var Preparer1 = GroupFixturePreparers(RegisterModuleFoo, RegisterModuleBar) +// var Preparer2 = GroupFixturePreparers(RegisterModuleBar, RegisterModuleBaz) +// var AllPreparers = GroupFixturePreparers(Preparer1, Preparer2) // // As after deduping and flattening AllPreparers would result in the following preparers being // applied: @@ -109,7 +109,7 @@ import ( // An exported preparer for use by other packages that need to use java modules. // // package java -// var PrepareForIntegrationTestWithJava = FixturePreparers( +// var PrepareForIntegrationTestWithJava = GroupFixturePreparers( // android.PrepareForIntegrationTestWithAndroid, // FixtureRegisterWithContext(RegisterAGroupOfRelatedModulesMutatorsAndSingletons), // FixtureRegisterWithContext(RegisterAnotherGroupOfRelatedModulesMutatorsAndSingletons), @@ -144,7 +144,7 @@ import ( // } // // package cc -// var PrepareForTestWithCC = FixturePreparers( +// var PrepareForTestWithCC = GroupFixturePreparers( // android.PrepareForArchMutator, // android.prepareForPrebuilts, // FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest), @@ -153,7 +153,7 @@ import ( // // package apex // -// var PrepareForApex = FixturePreparers( +// var PrepareForApex = GroupFixturePreparers( // ... // ) // @@ -285,9 +285,12 @@ func FixtureWithRootAndroidBp(contents string) FixturePreparer { return FixtureAddTextFile("Android.bp", contents) } -// Create a composite FixturePreparer that is equivalent to applying each of the supplied -// FixturePreparer instances in order. -func FixturePreparers(preparers ...FixturePreparer) FixturePreparer { +// GroupFixturePreparers creates a composite FixturePreparer that is equivalent to applying each of +// the supplied FixturePreparer instances in order. +// +// Before preparing the fixture the list of preparers is flattened by replacing each +// instance of GroupFixturePreparers with its contents. +func GroupFixturePreparers(preparers ...FixturePreparer) FixturePreparer { return &compositeFixturePreparer{dedupAndFlattenPreparers(nil, preparers)} } diff --git a/android/fixture_test.go b/android/fixture_test.go index 7bc033be7..5a7bf3b6e 100644 --- a/android/fixture_test.go +++ b/android/fixture_test.go @@ -32,9 +32,9 @@ func TestFixtureDedup(t *testing.T) { preparer3 := appendToList("preparer3") preparer4 := appendToList("preparer4") - preparer1Then2 := FixturePreparers(preparer1, preparer2) + preparer1Then2 := GroupFixturePreparers(preparer1, preparer2) - preparer2Then1 := FixturePreparers(preparer2, preparer1) + preparer2Then1 := GroupFixturePreparers(preparer2, preparer1) buildDir := "build" factory := NewFixtureFactory(&buildDir, preparer1, preparer2, preparer1, preparer1Then2) diff --git a/android/testing.go b/android/testing.go index 583279656..691ebe1cd 100644 --- a/android/testing.go +++ b/android/testing.go @@ -48,7 +48,7 @@ func NewTestContext(config Config) *TestContext { return ctx } -var PrepareForTestWithArchMutator = FixturePreparers( +var PrepareForTestWithArchMutator = GroupFixturePreparers( // Configure architecture targets in the fixture config. FixtureModifyConfig(modifyTestConfigToSupportArchMutator), @@ -73,7 +73,7 @@ var PrepareForTestWithOverrides = FixtureRegisterWithContext(func(ctx Registrati }) // Prepares an integration test with build components from the android package. -var PrepareForIntegrationTestWithAndroid = FixturePreparers( +var PrepareForIntegrationTestWithAndroid = GroupFixturePreparers( // Mutators. Must match order in mutator.go. PrepareForTestWithArchMutator, PrepareForTestWithDefaults,