Merge "Remove apexFixtureFactory" am: abc89cf86b am: 4ec4ca02bd

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1660142

Change-Id: Ibf8f775bb108903a46c5de8a69b15280a7a493b0
This commit is contained in:
Paul Duffin 2021-04-01 10:50:33 +00:00 committed by Automerger Merge Worker
commit 8f1c917639
1 changed files with 28 additions and 9 deletions

View File

@ -50,18 +50,28 @@ func names(s string) (ns []string) {
func testApexError(t *testing.T, pattern, bp string, preparers ...android.FixturePreparer) { func testApexError(t *testing.T, pattern, bp string, preparers ...android.FixturePreparer) {
t.Helper() t.Helper()
apexFixtureFactory.Extend(preparers...). android.GroupFixturePreparers(
prepareForApexTest,
android.GroupFixturePreparers(preparers...),
).
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)). ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)).
RunTestWithBp(t, bp) RunTestWithBp(t, bp)
} }
func testApex(t *testing.T, bp string, preparers ...android.FixturePreparer) *android.TestContext { func testApex(t *testing.T, bp string, preparers ...android.FixturePreparer) *android.TestContext {
t.Helper() t.Helper()
factory := apexFixtureFactory.Extend(preparers...)
optionalBpPreparer := android.NullFixturePreparer
if bp != "" { 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 return result.TestContext
} }
@ -115,8 +125,16 @@ var withUnbundledBuild = android.FixtureModifyProductVariables(
}, },
) )
var apexFixtureFactory = android.NewFixtureFactory( // Legacy preparer used for running tests within the apex package.
nil, //
// 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 // General preparers in alphabetical order as test infrastructure will enforce correct
// registration order. // registration order.
android.PrepareForTestWithAndroidBuildComponents, android.PrepareForTestWithAndroidBuildComponents,
@ -5885,9 +5903,10 @@ func TestJavaSDKLibrary_ImportOnly(t *testing.T) {
} }
func TestCompatConfig(t *testing.T) { func TestCompatConfig(t *testing.T) {
result := apexFixtureFactory. result := android.GroupFixturePreparers(
Extend(java.PrepareForTestWithPlatformCompatConfig). prepareForApexTest,
RunTestWithBp(t, ` java.PrepareForTestWithPlatformCompatConfig,
).RunTestWithBp(t, `
apex { apex {
name: "myapex", name: "myapex",
key: "myapex.key", key: "myapex.key",