Remove javaFixtureFactory
Replaces uses of javaFixtureFactory with prepareForJavaTest and removes
the unused javaFixtureFactory.
Bug: 182885307
Test: m nothing
Change-Id: I809772d14af2af211b9e15ad676fbdc06b07cd46
diff --git a/java/androidmk_test.go b/java/androidmk_test.go
index 0b1961b..5eaa77b 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -135,7 +135,8 @@
}
func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo-shared_library", "foo-no_shared_library"),
).RunTestWithBp(t, `
diff --git a/java/app_test.go b/java/app_test.go
index 609ddf1..2523533 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -29,14 +29,14 @@
"android/soong/genrule"
)
-// testApp runs tests using the javaFixtureFactory
+// testApp runs tests using the prepareForJavaTest
//
// See testJava for an explanation as to how to stop using this deprecated method.
//
// deprecated
func testApp(t *testing.T, bp string) *android.TestContext {
t.Helper()
- result := javaFixtureFactory.RunTestWithBp(t, bp)
+ result := prepareForJavaTest.RunTestWithBp(t, bp)
return result.TestContext
}
@@ -55,7 +55,8 @@
for _, moduleType := range []string{"android_app", "android_library"} {
t.Run(moduleType, func(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
android.FixtureModifyMockFS(func(fs android.MockFS) {
for _, file := range resourceFiles {
fs[file] = nil
@@ -364,8 +365,8 @@
if test.expectedError != "" {
errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(test.expectedError)
}
- javaFixtureFactory.
- Extend(FixtureWithPrebuiltApis(map[string][]string{
+ android.GroupFixturePreparers(
+ prepareForJavaTest, FixtureWithPrebuiltApis(map[string][]string{
"29": {"foo"},
})).
ExtendWithErrorHandler(errorHandler).RunTestWithBp(t, test.bp)
@@ -1063,7 +1064,8 @@
%s
}`, moduleType, test.sdkVersion, platformApiProp)
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Platform_sdk_version = &test.platformSdkInt
variables.Platform_sdk_codename = &test.platformSdkCodename
@@ -1131,7 +1133,8 @@
vendor: true,
}`, moduleType, sdkKind, test.sdkVersion)
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Platform_sdk_version = &test.platformSdkInt
variables.Platform_sdk_codename = &test.platformSdkCodename
@@ -2331,7 +2334,8 @@
}
`
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
@@ -2681,7 +2685,8 @@
test := func(t *testing.T, bp string, want bool, unbundled bool) {
t.Helper()
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithPrebuiltsOfCurrentApi,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
if unbundled {
diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go
index 9db53fc..d78651d 100644
--- a/java/dexpreopt_bootjars_test.go
+++ b/java/dexpreopt_bootjars_test.go
@@ -43,12 +43,12 @@
}
`
- result := javaFixtureFactory.
- Extend(
- PrepareForTestWithJavaSdkLibraryFiles,
- FixtureWithLastReleaseApis("foo"),
- dexpreopt.FixtureSetBootJars("platform:foo", "platform:bar", "platform:baz"),
- ).RunTestWithBp(t, bp)
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ dexpreopt.FixtureSetBootJars("platform:foo", "platform:bar", "platform:baz"),
+ ).RunTestWithBp(t, bp)
dexpreoptBootJars := result.SingletonForTests("dex_bootjars")
rule := dexpreoptBootJars.Output(ruleFile)
diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go
index 12a85d5..d6c6a2d 100644
--- a/java/hiddenapi_singleton_test.go
+++ b/java/hiddenapi_singleton_test.go
@@ -35,7 +35,8 @@
})
}
-var hiddenApiFixtureFactory = javaFixtureFactory.Extend(PrepareForTestWithHiddenApiBuildComponents)
+var hiddenApiFixtureFactory = android.GroupFixturePreparers(
+ prepareForJavaTest, PrepareForTestWithHiddenApiBuildComponents)
func TestHiddenAPISingleton(t *testing.T) {
result := hiddenApiFixtureFactory.Extend(
diff --git a/java/java_test.go b/java/java_test.go
index a907c82..b6f639f 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -33,14 +33,6 @@
"android/soong/python"
)
-// Legacy factory to use to create fixtures for tests in this package.
-//
-// deprecated: See prepareForJavaTest
-var javaFixtureFactory = android.NewFixtureFactory(
- nil,
- prepareForJavaTest,
-)
-
// Legacy preparer used for running tests within the java package.
//
// This includes everything that was needed to run any test in the java package prior to the
@@ -75,8 +67,8 @@
// deprecated
func testJavaError(t *testing.T, pattern string, bp string) (*android.TestContext, android.Config) {
t.Helper()
- result := javaFixtureFactory.
- Extend(dexpreopt.PrepareForTestWithDexpreopt).
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest, dexpreopt.PrepareForTestWithDexpreopt).
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)).
RunTestWithBp(t, bp)
return result.TestContext, result.Config
@@ -93,37 +85,38 @@
// the fixture's config will be ignored when RunTestWithConfig replaces it.
pathCtx := android.PathContextForTesting(config)
dexpreopt.SetTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx))
- result := javaFixtureFactory.
+ result := prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)).
RunTestWithConfig(t, config)
return result.TestContext, result.Config
}
-// testJavaWithFS runs tests using the javaFixtureFactory
+// testJavaWithFS runs tests using the prepareForJavaTest
//
// See testJava for an explanation as to how to stop using this deprecated method.
//
// deprecated
func testJavaWithFS(t *testing.T, bp string, fs android.MockFS) (*android.TestContext, android.Config) {
t.Helper()
- result := javaFixtureFactory.Extend(fs.AddToFixture()).RunTestWithBp(t, bp)
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest, fs.AddToFixture()).RunTestWithBp(t, bp)
return result.TestContext, result.Config
}
-// testJava runs tests using the javaFixtureFactory
+// testJava runs tests using the prepareForJavaTest
//
-// Do not add any new usages of this, instead use the javaFixtureFactory directly as it makes it
+// Do not add any new usages of this, instead use the prepareForJavaTest directly as it makes it
// much easier to customize the test behavior.
//
// If it is necessary to customize the behavior of an existing test that uses this then please first
-// convert the test to using javaFixtureFactory first and then in a following change add the
+// convert the test to using prepareForJavaTest first and then in a following change add the
// appropriate fixture preparers. Keeping the conversion change separate makes it easy to verify
// that it did not change the test behavior unexpectedly.
//
// deprecated
func testJava(t *testing.T, bp string) (*android.TestContext, android.Config) {
t.Helper()
- result := javaFixtureFactory.RunTestWithBp(t, bp)
+ result := prepareForJavaTest.RunTestWithBp(t, bp)
return result.TestContext, result.Config
}
@@ -638,7 +631,7 @@
}
func TestJavaSdkLibraryImport(t *testing.T) {
- result := javaFixtureFactory.RunTestWithBp(t, `
+ result := prepareForJavaTest.RunTestWithBp(t, `
java_library {
name: "foo",
srcs: ["a.java"],
@@ -692,7 +685,8 @@
}
func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
).RunTestWithBp(t, `
@@ -734,7 +728,8 @@
}
func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
).RunTestWithBp(t, `
@@ -841,7 +836,7 @@
if expectedErrorPattern != "" {
errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern)
}
- javaFixtureFactory.ExtendWithErrorHandler(errorHandler).RunTest(t, createPreparer(info))
+ prepareForJavaTest.ExtendWithErrorHandler(errorHandler).RunTest(t, createPreparer(info))
})
}
@@ -1319,8 +1314,8 @@
}
func TestTurbine(t *testing.T) {
- result := javaFixtureFactory.
- Extend(FixtureWithPrebuiltApis(map[string][]string{"14": {"foo"}})).
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest, FixtureWithPrebuiltApis(map[string][]string{"14": {"foo"}})).
RunTestWithBp(t, `
java_library {
name: "foo",
@@ -1731,7 +1726,8 @@
}
func TestJavaSdkLibrary(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithPrebuiltApis(map[string][]string{
"28": {"foo"},
@@ -1856,7 +1852,8 @@
}
func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
).RunTestWithBp(t, `
@@ -1892,7 +1889,8 @@
}
func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
@@ -1920,7 +1918,8 @@
}
func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
- javaFixtureFactory.Extend(
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
@@ -1941,11 +1940,11 @@
}
func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) {
- javaFixtureFactory.
- Extend(
- PrepareForTestWithJavaSdkLibraryFiles,
- FixtureWithLastReleaseApis("foo"),
- ).
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ ).
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`"foo" does not provide api scope system`)).
RunTestWithBp(t, `
java_sdk_library {
@@ -1965,7 +1964,8 @@
}
func TestJavaSdkLibrary_Deps(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
).RunTestWithBp(t, `
@@ -1990,7 +1990,7 @@
}
func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
- javaFixtureFactory.RunTestWithBp(t, `
+ prepareForJavaTest.RunTestWithBp(t, `
java_sdk_library_import {
name: "foo",
public: {
@@ -2023,7 +2023,7 @@
`
t.Run("stubs.source", func(t *testing.T) {
- javaFixtureFactory.
+ prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`stubs.source not available for api scope public`)).
RunTestWithBp(t, bp+`
java_library {
@@ -2038,7 +2038,7 @@
})
t.Run("api.txt", func(t *testing.T) {
- javaFixtureFactory.
+ prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`api.txt not available for api scope public`)).
RunTestWithBp(t, bp+`
java_library {
@@ -2052,7 +2052,7 @@
})
t.Run("removed-api.txt", func(t *testing.T) {
- javaFixtureFactory.
+ prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`removed-api.txt not available for api scope public`)).
RunTestWithBp(t, bp+`
java_library {
@@ -2067,7 +2067,7 @@
}
func TestJavaSdkLibrary_InvalidScopes(t *testing.T) {
- javaFixtureFactory.
+ prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": enabled api scope "system" depends on disabled scope "public"`)).
RunTestWithBp(t, `
java_sdk_library {
@@ -2087,7 +2087,8 @@
}
func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
- javaFixtureFactory.Extend(
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
@@ -2104,7 +2105,8 @@
}
func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
- javaFixtureFactory.Extend(
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
@@ -2123,7 +2125,8 @@
}
func TestJavaSdkLibrary_SystemServer(t *testing.T) {
- javaFixtureFactory.Extend(
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
@@ -2142,7 +2145,7 @@
}
func TestJavaSdkLibrary_MissingScope(t *testing.T) {
- javaFixtureFactory.
+ prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`requires api scope module-lib from foo but it only has \[\] available`)).
RunTestWithBp(t, `
java_sdk_library {
@@ -2163,7 +2166,8 @@
}
func TestJavaSdkLibrary_FallbackScope(t *testing.T) {
- javaFixtureFactory.Extend(
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
@@ -2186,7 +2190,8 @@
}
func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) {
- result := javaFixtureFactory.Extend(
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
diff --git a/java/sdk_test.go b/java/sdk_test.go
index ff0a203..028c4fe 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -349,7 +349,8 @@
android.AssertPathsRelativeToTopEquals(t, "implicits", deps, javac.Implicits)
}
- fixtureFactory := javaFixtureFactory.Extend(
+ fixtureFactory := android.GroupFixturePreparers(
+ prepareForJavaTest,
FixtureWithPrebuiltApis(map[string][]string{
"29": {},
"30": {},
diff --git a/java/system_modules_test.go b/java/system_modules_test.go
index 3d9f398..7d8935a 100644
--- a/java/system_modules_test.go
+++ b/java/system_modules_test.go
@@ -50,7 +50,7 @@
`)
func TestJavaSystemModules(t *testing.T) {
- result := javaFixtureFactory.RunTest(t, addSourceSystemModules)
+ result := prepareForJavaTest.RunTest(t, addSourceSystemModules)
// check the existence of the source module
sourceSystemModules := result.ModuleForTests("system-modules", "android_common")
@@ -77,7 +77,7 @@
`)
func TestJavaSystemModulesImport(t *testing.T) {
- result := javaFixtureFactory.RunTest(t, addPrebuiltSystemModules)
+ result := prepareForJavaTest.RunTest(t, addPrebuiltSystemModules)
// check the existence of the renamed prebuilt module
prebuiltSystemModules := result.ModuleForTests("system-modules", "android_common")
@@ -89,7 +89,7 @@
}
func TestJavaSystemModulesMixSourceAndPrebuilt(t *testing.T) {
- result := javaFixtureFactory.RunTest(t,
+ result := prepareForJavaTest.RunTest(t,
addSourceSystemModules,
addPrebuiltSystemModules,
)