From 284165afb5f46efa45a8121ece6e4e45e59e2adc Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 29 Mar 2021 01:50:31 +0100 Subject: [PATCH] Remove apexFixtureFactory Bug: 182885307 Test: m nothing Change-Id: I88c58bf6b4adda4017e54548748897c51c3f3aa1 --- apex/apex_test.go | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index 6f56cbdb8..7fd0a654d 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -50,18 +50,28 @@ func names(s string) (ns []string) { func testApexError(t *testing.T, pattern, bp string, preparers ...android.FixturePreparer) { t.Helper() - apexFixtureFactory.Extend(preparers...). + android.GroupFixturePreparers( + prepareForApexTest, + android.GroupFixturePreparers(preparers...), + ). ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)). RunTestWithBp(t, bp) } func testApex(t *testing.T, bp string, preparers ...android.FixturePreparer) *android.TestContext { t.Helper() - factory := apexFixtureFactory.Extend(preparers...) + + optionalBpPreparer := android.NullFixturePreparer if bp != "" { - factory = factory.Extend(android.FixtureWithRootAndroidBp(bp)) + optionalBpPreparer = android.FixtureWithRootAndroidBp(bp) } - result := factory.RunTest(t) + + result := android.GroupFixturePreparers( + prepareForApexTest, + android.GroupFixturePreparers(preparers...), + optionalBpPreparer, + ).RunTest(t) + return result.TestContext } @@ -115,8 +125,16 @@ var withUnbundledBuild = android.FixtureModifyProductVariables( }, ) -var apexFixtureFactory = android.NewFixtureFactory( - nil, +// Legacy preparer used for running tests within the apex package. +// +// This includes everything that was needed to run any test in the apex package prior to the +// introduction of the test fixtures. Tests that are being converted to use fixtures directly +// rather than through the testApex...() methods should avoid using this and instead use the +// various preparers directly, using android.GroupFixturePreparers(...) to group them when +// necessary. +// +// deprecated +var prepareForApexTest = android.GroupFixturePreparers( // General preparers in alphabetical order as test infrastructure will enforce correct // registration order. android.PrepareForTestWithAndroidBuildComponents, @@ -5885,9 +5903,10 @@ func TestJavaSDKLibrary_ImportOnly(t *testing.T) { } func TestCompatConfig(t *testing.T) { - result := apexFixtureFactory. - Extend(java.PrepareForTestWithPlatformCompatConfig). - RunTestWithBp(t, ` + result := android.GroupFixturePreparers( + prepareForApexTest, + java.PrepareForTestWithPlatformCompatConfig, + ).RunTestWithBp(t, ` apex { name: "myapex", key: "myapex.key",