Remove varargs from RunTest(t *testing.T)

Use GroupFixturePreparers instead.

Bug: 182885307
Test: m nothing
Change-Id: Iaedb0ddc9d6a704f4d41363e705f3025a1291dc8
This commit is contained in:
Paul Duffin 2021-03-29 02:06:19 +01:00
parent 4f6d15465b
commit 55e740e9a6
4 changed files with 22 additions and 12 deletions

View File

@ -466,12 +466,13 @@ type FixturePreparer interface {
// Run the test, checking any errors reported and returning a TestResult instance. // Run the test, checking any errors reported and returning a TestResult instance.
// //
// Shorthand for Fixture(t, preparers...).RunTest() // Shorthand for Fixture(t).RunTest()
RunTest(t *testing.T, preparers ...FixturePreparer) *TestResult RunTest(t *testing.T) *TestResult
// Run the test with the supplied Android.bp file. // Run the test with the supplied Android.bp file.
// //
// Shorthand for RunTest(t, android.FixtureWithRootAndroidBp(bp)) // preparer.RunTestWithBp(t, bp) is shorthand for
// android.GroupFixturePreparers(preparer, android.FixtureWithRootAndroidBp(bp)).RunTest(t)
RunTestWithBp(t *testing.T, bp string) *TestResult RunTestWithBp(t *testing.T, bp string) *TestResult
// RunTestWithConfig is a temporary method added to help ease the migration of existing tests to // RunTestWithConfig is a temporary method added to help ease the migration of existing tests to
@ -750,15 +751,15 @@ func (b *baseFixturePreparer) ExtendWithErrorHandler(errorHandler FixtureErrorHa
})) }))
} }
func (b *baseFixturePreparer) RunTest(t *testing.T, preparers ...FixturePreparer) *TestResult { func (b *baseFixturePreparer) RunTest(t *testing.T) *TestResult {
t.Helper() t.Helper()
fixture := b.self.Fixture(t, preparers...) fixture := b.self.Fixture(t)
return fixture.RunTest() return fixture.RunTest()
} }
func (b *baseFixturePreparer) RunTestWithBp(t *testing.T, bp string) *TestResult { func (b *baseFixturePreparer) RunTestWithBp(t *testing.T, bp string) *TestResult {
t.Helper() t.Helper()
return b.RunTest(t, FixtureWithRootAndroidBp(bp)) return GroupFixturePreparers(b.self, FixtureWithRootAndroidBp(bp)).RunTest(t)
} }
func (b *baseFixturePreparer) RunTestWithConfig(t *testing.T, config Config) *TestResult { func (b *baseFixturePreparer) RunTestWithConfig(t *testing.T, config Config) *TestResult {

View File

@ -845,7 +845,12 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
if expectedErrorPattern != "" { if expectedErrorPattern != "" {
errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern) errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern)
} }
prepareForJavaTest.ExtendWithErrorHandler(errorHandler).RunTest(t, createPreparer(info)) android.GroupFixturePreparers(
prepareForJavaTest,
createPreparer(info),
).
ExtendWithErrorHandler(errorHandler).
RunTest(t)
}) })
} }

View File

@ -50,7 +50,7 @@ var addSourceSystemModules = android.FixtureAddTextFile("source/Android.bp", `
`) `)
func TestJavaSystemModules(t *testing.T) { func TestJavaSystemModules(t *testing.T) {
result := prepareForJavaTest.RunTest(t, addSourceSystemModules) result := android.GroupFixturePreparers(prepareForJavaTest, addSourceSystemModules).RunTest(t)
// check the existence of the source module // check the existence of the source module
sourceSystemModules := result.ModuleForTests("system-modules", "android_common") sourceSystemModules := result.ModuleForTests("system-modules", "android_common")
@ -77,7 +77,7 @@ var addPrebuiltSystemModules = android.FixtureAddTextFile("prebuilts/Android.bp"
`) `)
func TestJavaSystemModulesImport(t *testing.T) { func TestJavaSystemModulesImport(t *testing.T) {
result := prepareForJavaTest.RunTest(t, addPrebuiltSystemModules) result := android.GroupFixturePreparers(prepareForJavaTest, addPrebuiltSystemModules).RunTest(t)
// check the existence of the renamed prebuilt module // check the existence of the renamed prebuilt module
prebuiltSystemModules := result.ModuleForTests("system-modules", "android_common") prebuiltSystemModules := result.ModuleForTests("system-modules", "android_common")
@ -89,10 +89,11 @@ func TestJavaSystemModulesImport(t *testing.T) {
} }
func TestJavaSystemModulesMixSourceAndPrebuilt(t *testing.T) { func TestJavaSystemModulesMixSourceAndPrebuilt(t *testing.T) {
result := prepareForJavaTest.RunTest(t, result := android.GroupFixturePreparers(
prepareForJavaTest,
addSourceSystemModules, addSourceSystemModules,
addPrebuiltSystemModules, addPrebuiltSystemModules,
) ).RunTest(t)
// check the existence of the source module // check the existence of the source module
sourceSystemModules := result.ModuleForTests("system-modules", "android_common") sourceSystemModules := result.ModuleForTests("system-modules", "android_common")

View File

@ -95,7 +95,10 @@ 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 prepareForSdkTest.RunTest(t, fs.AddToFixture(), android.FixtureWithRootAndroidBp(bp)) return android.GroupFixturePreparers(
prepareForSdkTest,
fs.AddToFixture(),
).RunTestWithBp(t, bp)
} }
func testSdkError(t *testing.T, pattern, bp string) { func testSdkError(t *testing.T, pattern, bp string) {