Convert android/variable_test.go to test fixtures
Bug: 182885307
Test: m nothing
Change-Id: I51d3651244b110bf41cb0e4c331ac663bf816f84
diff --git a/android/variable_test.go b/android/variable_test.go
index 393fe01..d16e458 100644
--- a/android/variable_test.go
+++ b/android/variable_test.go
@@ -181,32 +181,30 @@
name: "baz",
}
`
- config := TestConfig(buildDir, nil, bp, nil)
- config.TestProductVariables.Eng = proptools.BoolPtr(true)
- ctx := NewTestContext(config)
- // A module type that has a srcs property but not a cflags property.
- ctx.RegisterModuleType("module1", testProductVariableModuleFactoryFactory(&struct {
- Srcs []string
- }{}))
- // A module type that has a cflags property but not a srcs property.
- ctx.RegisterModuleType("module2", testProductVariableModuleFactoryFactory(&struct {
- Cflags []string
- }{}))
- // A module type that does not have any properties that match product_variables.
- ctx.RegisterModuleType("module3", testProductVariableModuleFactoryFactory(&struct {
- Foo []string
- }{}))
- 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)
+ 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
+ }{}))
+ // A module type that has a cflags property but not a srcs property.
+ ctx.RegisterModuleType("module2", testProductVariableModuleFactoryFactory(&struct {
+ Cflags []string
+ }{}))
+ // A module type that does not have any properties that match product_variables.
+ ctx.RegisterModuleType("module3", testProductVariableModuleFactoryFactory(&struct {
+ Foo []string
+ }{}))
+ ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
+ ctx.BottomUp("variable", VariableMutator).Parallel()
+ })
+ }),
+ FixtureWithRootAndroidBp(bp),
+ )
}
var testProductVariableDefaultsProperties = struct {
@@ -290,32 +288,23 @@
}
`
- config := TestConfig(buildDir, nil, bp, nil)
- config.TestProductVariables.Eng = boolPtr(true)
+ 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 := NewTestContext(config)
-
- ctx.RegisterModuleType("test", productVariablesDefaultsTestModuleFactory)
- ctx.RegisterModuleType("defaults", productVariablesDefaultsTestDefaultsFactory)
-
- 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) {