Remove usages of FixtureFactory from misc packages

These packages have already been migrated to use per test build
directory so have no need for a FixtureFactory.

Bug: 183235980
Test: m nothing
Change-Id: I667d1d992caaf0f615de91f89efdae11c44986c2
This commit is contained in:
Paul Duffin 2021-03-20 00:36:55 +00:00
parent 30ac3e7ca7
commit 89648f98fa
9 changed files with 47 additions and 56 deletions

View file

@ -26,8 +26,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
var bpfFactory = android.NewFixtureFactory( var prepareForBpfTest = android.GroupFixturePreparers(
nil,
cc.PrepareForTestWithCcDefaultModules, cc.PrepareForTestWithCcDefaultModules,
android.FixtureMergeMockFs( android.FixtureMergeMockFs(
map[string][]byte{ map[string][]byte{
@ -53,7 +52,7 @@ func TestBpfDataDependency(t *testing.T) {
} }
` `
bpfFactory.RunTestWithBp(t, bp) prepareForBpfTest.RunTestWithBp(t, bp)
// We only verify the above BP configuration is processed successfully since the data property // We only verify the above BP configuration is processed successfully since the data property
// value is not available for testing from this package. // value is not available for testing from this package.

View file

@ -26,8 +26,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
var prebuiltEtcFixtureFactory = android.NewFixtureFactory( var prepareForPrebuiltEtcTest = android.GroupFixturePreparers(
nil,
android.PrepareForTestWithArchMutator, android.PrepareForTestWithArchMutator,
PrepareForTestWithPrebuiltEtc, PrepareForTestWithPrebuiltEtc,
android.FixtureMergeMockFs(android.MockFS{ android.FixtureMergeMockFs(android.MockFS{
@ -38,7 +37,7 @@ var prebuiltEtcFixtureFactory = android.NewFixtureFactory(
) )
func TestPrebuiltEtcVariants(t *testing.T) { func TestPrebuiltEtcVariants(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_etc { prebuilt_etc {
name: "foo.conf", name: "foo.conf",
src: "foo.conf", src: "foo.conf",
@ -72,7 +71,7 @@ func TestPrebuiltEtcVariants(t *testing.T) {
} }
func TestPrebuiltEtcOutputPath(t *testing.T) { func TestPrebuiltEtcOutputPath(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_etc { prebuilt_etc {
name: "foo.conf", name: "foo.conf",
src: "foo.conf", src: "foo.conf",
@ -85,7 +84,7 @@ func TestPrebuiltEtcOutputPath(t *testing.T) {
} }
func TestPrebuiltEtcGlob(t *testing.T) { func TestPrebuiltEtcGlob(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_etc { prebuilt_etc {
name: "my_foo", name: "my_foo",
src: "foo.*", src: "foo.*",
@ -105,7 +104,7 @@ func TestPrebuiltEtcGlob(t *testing.T) {
} }
func TestPrebuiltEtcAndroidMk(t *testing.T) { func TestPrebuiltEtcAndroidMk(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_etc { prebuilt_etc {
name: "foo", name: "foo",
src: "foo.conf", src: "foo.conf",
@ -139,7 +138,7 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) {
} }
func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) { func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_etc { prebuilt_etc {
name: "foo.conf", name: "foo.conf",
src: "foo.conf", src: "foo.conf",
@ -153,7 +152,7 @@ func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) {
} }
func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) { func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) {
prebuiltEtcFixtureFactory. prepareForPrebuiltEtcTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("relative_install_path is set. Cannot set sub_dir")). ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("relative_install_path is set. Cannot set sub_dir")).
RunTestWithBp(t, ` RunTestWithBp(t, `
prebuilt_etc { prebuilt_etc {
@ -166,7 +165,7 @@ func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) {
} }
func TestPrebuiltEtcHost(t *testing.T) { func TestPrebuiltEtcHost(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_etc_host { prebuilt_etc_host {
name: "foo.conf", name: "foo.conf",
src: "foo.conf", src: "foo.conf",
@ -181,7 +180,7 @@ func TestPrebuiltEtcHost(t *testing.T) {
} }
func TestPrebuiltUserShareInstallDirPath(t *testing.T) { func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_usr_share { prebuilt_usr_share {
name: "foo.conf", name: "foo.conf",
src: "foo.conf", src: "foo.conf",
@ -195,7 +194,7 @@ func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
} }
func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) { func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_usr_share_host { prebuilt_usr_share_host {
name: "foo.conf", name: "foo.conf",
src: "foo.conf", src: "foo.conf",
@ -210,7 +209,7 @@ func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
} }
func TestPrebuiltFontInstallDirPath(t *testing.T) { func TestPrebuiltFontInstallDirPath(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, ` result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_font { prebuilt_font {
name: "foo.conf", name: "foo.conf",
src: "foo.conf", src: "foo.conf",
@ -249,7 +248,7 @@ func TestPrebuiltFirmwareDirPath(t *testing.T) {
}} }}
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) { t.Run(tt.description, func(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, tt.config) result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath) android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
}) })
@ -283,7 +282,7 @@ func TestPrebuiltDSPDirPath(t *testing.T) {
}} }}
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) { t.Run(tt.description, func(t *testing.T) {
result := prebuiltEtcFixtureFactory.RunTestWithBp(t, tt.config) result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath) android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
}) })

View file

@ -28,8 +28,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
var genruleFixtureFactory = android.NewFixtureFactory( var prepareForGenRuleTest = android.GroupFixturePreparers(
nil,
android.PrepareForTestWithArchMutator, android.PrepareForTestWithArchMutator,
android.PrepareForTestWithDefaults, android.PrepareForTestWithDefaults,
@ -447,7 +446,8 @@ func TestGenruleCmd(t *testing.T) {
expectedErrors = append(expectedErrors, regexp.QuoteMeta(test.err)) expectedErrors = append(expectedErrors, regexp.QuoteMeta(test.err))
} }
result := genruleFixtureFactory.Extend( result := android.GroupFixturePreparers(
prepareForGenRuleTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Allow_missing_dependencies = proptools.BoolPtr(test.allowMissingDependencies) variables.Allow_missing_dependencies = proptools.BoolPtr(test.allowMissingDependencies)
}), }),
@ -523,7 +523,7 @@ func TestGenruleHashInputs(t *testing.T) {
}, },
} }
result := genruleFixtureFactory.RunTestWithBp(t, testGenruleBp()+bp) result := prepareForGenRuleTest.RunTestWithBp(t, testGenruleBp()+bp)
for _, test := range testcases { for _, test := range testcases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
@ -605,7 +605,7 @@ func TestGenSrcs(t *testing.T) {
expectedErrors = append(expectedErrors, regexp.QuoteMeta(test.err)) expectedErrors = append(expectedErrors, regexp.QuoteMeta(test.err))
} }
result := genruleFixtureFactory. result := prepareForGenRuleTest.
ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(expectedErrors)). ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(expectedErrors)).
RunTestWithBp(t, testGenruleBp()+bp) RunTestWithBp(t, testGenruleBp()+bp)
@ -642,7 +642,7 @@ func TestGenruleDefaults(t *testing.T) {
} }
` `
result := genruleFixtureFactory.RunTestWithBp(t, testGenruleBp()+bp) result := prepareForGenRuleTest.RunTestWithBp(t, testGenruleBp()+bp)
gen := result.Module("gen", "").(*Module) gen := result.Module("gen", "").(*Module)
@ -662,11 +662,12 @@ func TestGenruleWithBazel(t *testing.T) {
} }
` `
result := genruleFixtureFactory.Extend(android.FixtureModifyConfig(func(config android.Config) { result := android.GroupFixturePreparers(
config.BazelContext = android.MockBazelContext{ prepareForGenRuleTest, android.FixtureModifyConfig(func(config android.Config) {
AllFiles: map[string][]string{ config.BazelContext = android.MockBazelContext{
"//foo/bar:bar": []string{"bazelone.txt", "bazeltwo.txt"}}} AllFiles: map[string][]string{
})).RunTestWithBp(t, testGenruleBp()+bp) "//foo/bar:bar": []string{"bazelone.txt", "bazeltwo.txt"}}}
})).RunTestWithBp(t, testGenruleBp()+bp)
gen := result.Module("foo", "").(*Module) gen := result.Module("foo", "").(*Module)

View file

@ -335,13 +335,12 @@ func TestPythonModule(t *testing.T) {
} }
t.Run(d.desc, func(t *testing.T) { t.Run(d.desc, func(t *testing.T) {
result := emptyFixtureFactory. result := android.GroupFixturePreparers(
ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(errorPatterns)). android.PrepareForTestWithDefaults,
RunTest(t, PrepareForTestWithPythonBuildComponents,
android.PrepareForTestWithDefaults, d.mockFiles.AddToFixture(),
PrepareForTestWithPythonBuildComponents, ).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(errorPatterns)).
d.mockFiles.AddToFixture(), RunTest(t)
)
if len(result.Errs) > 0 { if len(result.Errs) > 0 {
return return
@ -376,8 +375,6 @@ func expectModule(t *testing.T, ctx *android.TestContext, name, variant, expecte
android.AssertPathsRelativeToTopEquals(t, "depsSrcsZips", expectedDepsSrcsZips, base.depsSrcsZips) android.AssertPathsRelativeToTopEquals(t, "depsSrcsZips", expectedDepsSrcsZips, base.depsSrcsZips)
} }
var emptyFixtureFactory = android.NewFixtureFactory(nil)
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }

View file

@ -808,7 +808,8 @@ module_exports_snapshot {
} }
func TestSnapshotWithSingleHostOsType(t *testing.T) { func TestSnapshotWithSingleHostOsType(t *testing.T) {
result := sdkFixtureFactory.Extend( result := android.GroupFixturePreparers(
prepareForSdkTest,
ccTestFs.AddToFixture(), ccTestFs.AddToFixture(),
cc.PrepareForTestOnLinuxBionic, cc.PrepareForTestOnLinuxBionic,
android.FixtureModifyConfig(func(config android.Config) { android.FixtureModifyConfig(func(config android.Config) {

View file

@ -27,8 +27,7 @@ import (
"android/soong/java" "android/soong/java"
) )
var sdkFixtureFactory = android.NewFixtureFactory( var prepareForSdkTest = android.GroupFixturePreparers(
nil,
apex.PrepareForTestWithApexBuildComponents, apex.PrepareForTestWithApexBuildComponents,
cc.PrepareForTestWithCcDefaultModules, cc.PrepareForTestWithCcDefaultModules,
genrule.PrepareForTestWithGenRuleBuildComponents, genrule.PrepareForTestWithGenRuleBuildComponents,
@ -77,12 +76,12 @@ var PrepareForTestWithSdkBuildComponents = android.GroupFixturePreparers(
func testSdkWithFs(t *testing.T, bp string, fs android.MockFS) *android.TestResult { func testSdkWithFs(t *testing.T, bp string, fs android.MockFS) *android.TestResult {
t.Helper() t.Helper()
return sdkFixtureFactory.RunTest(t, fs.AddToFixture(), android.FixtureWithRootAndroidBp(bp)) return prepareForSdkTest.RunTest(t, fs.AddToFixture(), android.FixtureWithRootAndroidBp(bp))
} }
func testSdkError(t *testing.T, pattern, bp string) { func testSdkError(t *testing.T, pattern, bp string) {
t.Helper() t.Helper()
sdkFixtureFactory. prepareForSdkTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)). ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)).
RunTestWithBp(t, bp) RunTestWithBp(t, bp)
} }

View file

@ -13,8 +13,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
var shFixtureFactory = android.NewFixtureFactory( var prepareForShTest = android.GroupFixturePreparers(
nil,
cc.PrepareForTestWithCcBuildComponents, cc.PrepareForTestWithCcBuildComponents,
PrepareForTestWithShBuildComponents, PrepareForTestWithShBuildComponents,
android.FixtureMergeMockFs(android.MockFS{ android.FixtureMergeMockFs(android.MockFS{
@ -24,19 +23,19 @@ var shFixtureFactory = android.NewFixtureFactory(
}), }),
) )
// testShBinary runs tests using the shFixtureFactory // testShBinary runs tests using the prepareForShTest
// //
// Do not add any new usages of this, instead use the shFixtureFactory directly as it makes it much // Do not add any new usages of this, instead use the prepareForShTest directly as it makes it much
// easier to customize the test behavior. // easier to customize the test behavior.
// //
// If it is necessary to customize the behavior of an existing test that uses this then please first // If it is necessary to customize the behavior of an existing test that uses this then please first
// convert the test to using shFixtureFactory first and then in a following change add the // convert the test to using prepareForShTest first and then in a following change add the
// appropriate fixture preparers. Keeping the conversion change separate makes it easy to verify // appropriate fixture preparers. Keeping the conversion change separate makes it easy to verify
// that it did not change the test behavior unexpectedly. // that it did not change the test behavior unexpectedly.
// //
// deprecated // deprecated
func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config) { func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config) {
result := shFixtureFactory.RunTestWithBp(t, bp) result := prepareForShTest.RunTestWithBp(t, bp)
return result.TestContext, result.Config return result.TestContext, result.Config
} }

View file

@ -30,8 +30,6 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
var emptyFixtureFactory = android.NewFixtureFactory(nil)
func test(t *testing.T, bp string) *android.TestResult { func test(t *testing.T, bp string) *android.TestResult {
t.Helper() t.Helper()
@ -124,7 +122,7 @@ func test(t *testing.T, bp string) *android.TestResult {
"com/android2/OdmProperties.sysprop": nil, "com/android2/OdmProperties.sysprop": nil,
} }
result := emptyFixtureFactory.RunTest(t, result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules, cc.PrepareForTestWithCcDefaultModules,
java.PrepareForTestWithJavaDefaultModules, java.PrepareForTestWithJavaDefaultModules,
PrepareForTestWithSyspropBuildComponents, PrepareForTestWithSyspropBuildComponents,
@ -135,7 +133,7 @@ func test(t *testing.T, bp string) *android.TestResult {
}), }),
mockFS.AddToFixture(), mockFS.AddToFixture(),
android.FixtureWithRootAndroidBp(bp), android.FixtureWithRootAndroidBp(bp),
) ).RunTest(t)
return result return result
} }

View file

@ -26,8 +26,6 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
var emptyFixtureFactory = android.NewFixtureFactory(nil)
func testXml(t *testing.T, bp string) *android.TestResult { func testXml(t *testing.T, bp string) *android.TestResult {
fs := android.MockFS{ fs := android.MockFS{
"foo.xml": nil, "foo.xml": nil,
@ -37,13 +35,13 @@ func testXml(t *testing.T, bp string) *android.TestResult {
"baz.xml": nil, "baz.xml": nil,
} }
return emptyFixtureFactory.RunTest(t, return android.GroupFixturePreparers(
android.PrepareForTestWithArchMutator, android.PrepareForTestWithArchMutator,
etc.PrepareForTestWithPrebuiltEtc, etc.PrepareForTestWithPrebuiltEtc,
PreparerForTestWithXmlBuildComponents, PreparerForTestWithXmlBuildComponents,
fs.AddToFixture(), fs.AddToFixture(),
android.FixtureWithRootAndroidBp(bp), android.FixtureWithRootAndroidBp(bp),
) ).RunTest(t)
} }
// Minimal test // Minimal test