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

Commit 4b49b768 authored by Colin Cross's avatar Colin Cross
Browse files

Make TestContext.RegisterModuleType take an android.ModuleFactory

Avoid having to pass ModuleFactoryAdaptor to every call to
RegisterModuleType in a test by wrapping RegisterModuleType.

Test: all soong tests
Change-Id: If8847d16487de0479cc3020b728256922b3cadba
parent 62835fd8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ func TestAndroidMkSingleton_PassesUpdatedAndroidMkDataToCustomCallback(t *testin
	config.inMake = true // Enable androidmk Singleton

	ctx := NewTestContext()
	ctx.RegisterSingletonType("androidmk", SingletonFactoryAdaptor(AndroidMkSingleton))
	ctx.RegisterModuleType("custom", ModuleFactoryAdaptor(customModuleFactory))
	ctx.RegisterSingletonType("androidmk", AndroidMkSingleton)
	ctx.RegisterModuleType("custom", customModuleFactory)
	ctx.Register()

	bp := `
+1 −1
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ func TestArchMutator(t *testing.T) {
	for _, tt := range testCases {
		t.Run(tt.name, func(t *testing.T) {
			ctx := NewTestArchContext()
			ctx.RegisterModuleType("module", ModuleFactoryAdaptor(archTestModuleFactory))
			ctx.RegisterModuleType("module", archTestModuleFactory)
			ctx.MockFileSystem(mockFS)
			ctx.Register()
			config := TestArchConfig(buildDir, nil)
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ func testCSuiteConfig(test *testing.T, bpFileContents string) *TestContext {
	config := TestArchConfig(buildDir, nil)

	ctx := NewTestArchContext()
	ctx.RegisterModuleType("csuite_config", ModuleFactoryAdaptor(CSuiteConfigFactory))
	ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory)
	ctx.Register()
	mockFiles := map[string][]byte{
		"Android.bp": []byte(bpFileContents),
+2 −2
Original line number Diff line number Diff line
@@ -64,8 +64,8 @@ func TestDefaultsAllowMissingDependencies(t *testing.T) {
	ctx := NewTestContext()
	ctx.SetAllowMissingDependencies(true)

	ctx.RegisterModuleType("test", ModuleFactoryAdaptor(defaultsTestModuleFactory))
	ctx.RegisterModuleType("defaults", ModuleFactoryAdaptor(defaultsTestDefaultsFactory))
	ctx.RegisterModuleType("test", defaultsTestModuleFactory)
	ctx.RegisterModuleType("defaults", defaultsTestDefaultsFactory)

	ctx.PreArchMutators(RegisterDefaultsPreArchMutators)

+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ func depsModuleFactory() Module {

func TestErrorDependsOnDisabledModule(t *testing.T) {
	ctx := NewTestContext()
	ctx.RegisterModuleType("deps", ModuleFactoryAdaptor(depsModuleFactory))
	ctx.RegisterModuleType("deps", depsModuleFactory)

	bp := `
		deps {
Loading