Loading android/variable_test.go +38 −49 Original line number Diff line number Diff line Loading @@ -181,10 +181,12 @@ func TestProductVariables(t *testing.T) { name: "baz", } ` config := TestConfig(buildDir, nil, bp, nil) config.TestProductVariables.Eng = proptools.BoolPtr(true) ctx := NewTestContext(config) emptyTestFixtureFactory.RunTest(t, FixtureModifyProductVariables(func(variables FixtureProductVariables) { variables.Eng = proptools.BoolPtr(true) }), FixtureRegisterWithContext(func(ctx RegistrationContext) { // A module type that has a srcs property but not a cflags property. ctx.RegisterModuleType("module1", testProductVariableModuleFactoryFactory(&struct { Srcs []string Loading @@ -200,13 +202,9 @@ func TestProductVariables(t *testing.T) { ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("variable", VariableMutator).Parallel() }) ctx.Register() _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) FailIfErrored(t, errs) }), FixtureWithRootAndroidBp(bp), ) } var testProductVariableDefaultsProperties = struct { Loading Loading @@ -290,32 +288,23 @@ func TestProductVariablesDefaults(t *testing.T) { } ` config := TestConfig(buildDir, nil, bp, nil) config.TestProductVariables.Eng = boolPtr(true) ctx := NewTestContext(config) result := emptyTestFixtureFactory.RunTest(t, FixtureModifyProductVariables(func(variables FixtureProductVariables) { variables.Eng = boolPtr(true) }), PrepareForTestWithDefaults, PrepareForTestWithVariables, FixtureRegisterWithContext(func(ctx RegistrationContext) { ctx.RegisterModuleType("test", productVariablesDefaultsTestModuleFactory) ctx.RegisterModuleType("defaults", productVariablesDefaultsTestDefaultsFactory) }), FixtureWithRootAndroidBp(bp), ) ctx.PreArchMutators(RegisterDefaultsPreArchMutators) ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("variable", VariableMutator).Parallel() }) ctx.Register() _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) FailIfErrored(t, errs) foo := ctx.ModuleForTests("foo", "").Module().(*productVariablesDefaultsTestModule) foo := result.ModuleForTests("foo", "").Module().(*productVariablesDefaultsTestModule) want := []string{"defaults", "module", "product_variable_defaults", "product_variable_module"} if g, w := foo.properties.Foo, want; !reflect.DeepEqual(g, w) { t.Errorf("expected foo %q, got %q", w, g) } AssertDeepEquals(t, "foo", want, foo.properties.Foo) } func BenchmarkSliceToTypeArray(b *testing.B) { Loading Loading
android/variable_test.go +38 −49 Original line number Diff line number Diff line Loading @@ -181,10 +181,12 @@ func TestProductVariables(t *testing.T) { name: "baz", } ` config := TestConfig(buildDir, nil, bp, nil) config.TestProductVariables.Eng = proptools.BoolPtr(true) ctx := NewTestContext(config) emptyTestFixtureFactory.RunTest(t, FixtureModifyProductVariables(func(variables FixtureProductVariables) { variables.Eng = proptools.BoolPtr(true) }), FixtureRegisterWithContext(func(ctx RegistrationContext) { // A module type that has a srcs property but not a cflags property. ctx.RegisterModuleType("module1", testProductVariableModuleFactoryFactory(&struct { Srcs []string Loading @@ -200,13 +202,9 @@ func TestProductVariables(t *testing.T) { ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("variable", VariableMutator).Parallel() }) ctx.Register() _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) FailIfErrored(t, errs) }), FixtureWithRootAndroidBp(bp), ) } var testProductVariableDefaultsProperties = struct { Loading Loading @@ -290,32 +288,23 @@ func TestProductVariablesDefaults(t *testing.T) { } ` config := TestConfig(buildDir, nil, bp, nil) config.TestProductVariables.Eng = boolPtr(true) ctx := NewTestContext(config) result := emptyTestFixtureFactory.RunTest(t, FixtureModifyProductVariables(func(variables FixtureProductVariables) { variables.Eng = boolPtr(true) }), PrepareForTestWithDefaults, PrepareForTestWithVariables, FixtureRegisterWithContext(func(ctx RegistrationContext) { ctx.RegisterModuleType("test", productVariablesDefaultsTestModuleFactory) ctx.RegisterModuleType("defaults", productVariablesDefaultsTestDefaultsFactory) }), FixtureWithRootAndroidBp(bp), ) ctx.PreArchMutators(RegisterDefaultsPreArchMutators) ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("variable", VariableMutator).Parallel() }) ctx.Register() _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) FailIfErrored(t, errs) foo := ctx.ModuleForTests("foo", "").Module().(*productVariablesDefaultsTestModule) foo := result.ModuleForTests("foo", "").Module().(*productVariablesDefaultsTestModule) want := []string{"defaults", "module", "product_variable_defaults", "product_variable_module"} if g, w := foo.properties.Foo, want; !reflect.DeepEqual(g, w) { t.Errorf("expected foo %q, got %q", w, g) } AssertDeepEquals(t, "foo", want, foo.properties.Foo) } func BenchmarkSliceToTypeArray(b *testing.B) { Loading