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())
}
var bpfFactory = android.NewFixtureFactory(
nil,
var prepareForBpfTest = android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
android.FixtureMergeMockFs(
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
// value is not available for testing from this package.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,8 +13,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
var shFixtureFactory = android.NewFixtureFactory(
nil,
var prepareForShTest = android.GroupFixturePreparers(
cc.PrepareForTestWithCcBuildComponents,
PrepareForTestWithShBuildComponents,
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.
//
// 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
// that it did not change the test behavior unexpectedly.
//
// deprecated
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
}

View file

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

View file

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