Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55e740e9 authored by Paul Duffin's avatar Paul Duffin
Browse files

Remove varargs from RunTest(t *testing.T)

Use GroupFixturePreparers instead.

Bug: 182885307
Test: m nothing
Change-Id: Iaedb0ddc9d6a704f4d41363e705f3025a1291dc8
parent 4f6d1546
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -466,12 +466,13 @@ type FixturePreparer interface {

	// Run the test, checking any errors reported and returning a TestResult instance.
	//
	// Shorthand for Fixture(t, preparers...).RunTest()
	RunTest(t *testing.T, preparers ...FixturePreparer) *TestResult
	// Shorthand for Fixture(t).RunTest()
	RunTest(t *testing.T) *TestResult

	// 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

	// 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()
	fixture := b.self.Fixture(t, preparers...)
	fixture := b.self.Fixture(t)
	return fixture.RunTest()
}

func (b *baseFixturePreparer) RunTestWithBp(t *testing.T, bp string) *TestResult {
	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 {
+6 −1
Original line number Diff line number Diff line
@@ -845,7 +845,12 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
			if expectedErrorPattern != "" {
				errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern)
			}
			prepareForJavaTest.ExtendWithErrorHandler(errorHandler).RunTest(t, createPreparer(info))
			android.GroupFixturePreparers(
				prepareForJavaTest,
				createPreparer(info),
			).
				ExtendWithErrorHandler(errorHandler).
				RunTest(t)
		})
	}

+5 −4
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ var addSourceSystemModules = android.FixtureAddTextFile("source/Android.bp", `
`)

func TestJavaSystemModules(t *testing.T) {
	result := prepareForJavaTest.RunTest(t, addSourceSystemModules)
	result := android.GroupFixturePreparers(prepareForJavaTest, addSourceSystemModules).RunTest(t)

	// check the existence of the source module
	sourceSystemModules := result.ModuleForTests("system-modules", "android_common")
@@ -77,7 +77,7 @@ var addPrebuiltSystemModules = android.FixtureAddTextFile("prebuilts/Android.bp"
`)

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
	prebuiltSystemModules := result.ModuleForTests("system-modules", "android_common")
@@ -89,10 +89,11 @@ func TestJavaSystemModulesImport(t *testing.T) {
}

func TestJavaSystemModulesMixSourceAndPrebuilt(t *testing.T) {
	result := prepareForJavaTest.RunTest(t,
	result := android.GroupFixturePreparers(
		prepareForJavaTest,
		addSourceSystemModules,
		addPrebuiltSystemModules,
	)
	).RunTest(t)

	// check the existence of the source module
	sourceSystemModules := result.ModuleForTests("system-modules", "android_common")
+4 −1
Original line number Diff line number Diff line
@@ -95,7 +95,10 @@ var PrepareForTestWithSdkBuildComponents = android.GroupFixturePreparers(

func testSdkWithFs(t *testing.T, bp string, fs android.MockFS) *android.TestResult {
	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) {