Remove uses of FixtureFactory from android package
Bug: 183235980 Test: m nothing Change-Id: I72898ada020ee1a73fd534c61afb5c22fa00c1e5
This commit is contained in:
@@ -22,5 +22,3 @@ import (
|
|||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
var emptyTestFixtureFactory = NewFixtureFactory(nil)
|
|
||||||
|
@@ -141,14 +141,14 @@ func customModuleFactory() Module {
|
|||||||
// bp module and then returns the config and the custom module called "foo".
|
// bp module and then returns the config and the custom module called "foo".
|
||||||
func buildContextAndCustomModuleFoo(t *testing.T, bp string) (*TestContext, *customModule) {
|
func buildContextAndCustomModuleFoo(t *testing.T, bp string) (*TestContext, *customModule) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
// Enable androidmk Singleton
|
// Enable androidmk Singleton
|
||||||
PrepareForTestWithAndroidMk,
|
PrepareForTestWithAndroidMk,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
module := result.ModuleForTests("foo", "").Module().(*customModule)
|
module := result.ModuleForTests("foo", "").Module().(*customModule)
|
||||||
return result.TestContext, module
|
return result.TestContext, module
|
||||||
|
@@ -358,12 +358,12 @@ func TestArchMutator(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range testCases {
|
for _, tt := range testCases {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
prepareForArchTest,
|
prepareForArchTest,
|
||||||
// Test specific preparer
|
// Test specific preparer
|
||||||
OptionalFixturePreparer(tt.preparer),
|
OptionalFixturePreparer(tt.preparer),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
ctx := result.TestContext
|
ctx := result.TestContext
|
||||||
|
|
||||||
if g, w := enabledVariants(ctx, "foo"), tt.fooVariants; !reflect.DeepEqual(w, g) {
|
if g, w := enabledVariants(ctx, "foo"), tt.fooVariants; !reflect.DeepEqual(w, g) {
|
||||||
@@ -441,7 +441,7 @@ func TestArchMutatorNativeBridge(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range testCases {
|
for _, tt := range testCases {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
prepareForArchTest,
|
prepareForArchTest,
|
||||||
// Test specific preparer
|
// Test specific preparer
|
||||||
OptionalFixturePreparer(tt.preparer),
|
OptionalFixturePreparer(tt.preparer),
|
||||||
@@ -455,7 +455,7 @@ func TestArchMutatorNativeBridge(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
ctx := result.TestContext
|
ctx := result.TestContext
|
||||||
|
|
||||||
|
@@ -19,14 +19,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCSuiteConfig(t *testing.T) {
|
func TestCSuiteConfig(t *testing.T) {
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
PrepareForTestWithArchMutator,
|
PrepareForTestWithArchMutator,
|
||||||
FixtureRegisterWithContext(registerCSuiteBuildComponents),
|
FixtureRegisterWithContext(registerCSuiteBuildComponents),
|
||||||
FixtureWithRootAndroidBp(`
|
FixtureWithRootAndroidBp(`
|
||||||
csuite_config { name: "plain"}
|
csuite_config { name: "plain"}
|
||||||
csuite_config { name: "with_manifest", test_config: "manifest.xml" }
|
csuite_config { name: "with_manifest", test_config: "manifest.xml" }
|
||||||
`),
|
`),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
variants := result.ModuleVariantsForTests("plain")
|
variants := result.ModuleVariantsForTests("plain")
|
||||||
if len(variants) > 1 {
|
if len(variants) > 1 {
|
||||||
|
@@ -83,10 +83,10 @@ func TestDefaults(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
prepareForDefaultsTest,
|
prepareForDefaultsTest,
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
foo := result.Module("foo", "").(*defaultsTestModule)
|
foo := result.Module("foo", "").(*defaultsTestModule)
|
||||||
|
|
||||||
@@ -114,11 +114,11 @@ func TestDefaultsAllowMissingDependencies(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
prepareForDefaultsTest,
|
prepareForDefaultsTest,
|
||||||
PrepareForTestWithAllowMissingDependencies,
|
PrepareForTestWithAllowMissingDependencies,
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
missingDefaults := result.ModuleForTests("missing_defaults", "").Output("out")
|
missingDefaults := result.ModuleForTests("missing_defaults", "").Output("out")
|
||||||
missingTransitiveDefaults := result.ModuleForTests("missing_transitive_defaults", "").Output("out")
|
missingTransitiveDefaults := result.ModuleForTests("missing_transitive_defaults", "").Output("out")
|
||||||
|
@@ -80,13 +80,13 @@ func TestInstallDependencyTag(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
PrepareForTestWithArchMutator,
|
PrepareForTestWithArchMutator,
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("test_module", testInstallDependencyTagModuleFactory)
|
ctx.RegisterModuleType("test_module", testInstallDependencyTagModuleFactory)
|
||||||
}),
|
}),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
config := result.Config
|
config := result.Config
|
||||||
|
|
||||||
|
@@ -97,13 +97,14 @@ var licenseKindTests = []struct {
|
|||||||
func TestLicenseKind(t *testing.T) {
|
func TestLicenseKind(t *testing.T) {
|
||||||
for _, test := range licenseKindTests {
|
for _, test := range licenseKindTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
licenseTestFixtureFactory.
|
GroupFixturePreparers(
|
||||||
Extend(
|
prepareForLicenseTest,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("mock_license", newMockLicenseModule)
|
ctx.RegisterModuleType("mock_license", newMockLicenseModule)
|
||||||
}),
|
}),
|
||||||
test.fs.AddToFixture(),
|
test.fs.AddToFixture(),
|
||||||
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)).
|
).
|
||||||
|
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)).
|
||||||
RunTest(t)
|
RunTest(t)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Common test set up for license tests.
|
// Common test set up for license tests.
|
||||||
var licenseTestFixtureFactory = emptyTestFixtureFactory.Extend(
|
var prepareForLicenseTest = GroupFixturePreparers(
|
||||||
// General preparers in alphabetical order.
|
// General preparers in alphabetical order.
|
||||||
PrepareForTestWithDefaults,
|
PrepareForTestWithDefaults,
|
||||||
prepareForTestWithLicenses,
|
prepareForTestWithLicenses,
|
||||||
@@ -179,7 +179,8 @@ func TestLicense(t *testing.T) {
|
|||||||
for _, test := range licenseTests {
|
for _, test := range licenseTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
// Customize the common license text fixture factory.
|
// Customize the common license text fixture factory.
|
||||||
licenseTestFixtureFactory.Extend(
|
GroupFixturePreparers(
|
||||||
|
prepareForLicenseTest,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("rule", newMockRuleModule)
|
ctx.RegisterModuleType("rule", newMockRuleModule)
|
||||||
}),
|
}),
|
||||||
|
@@ -470,7 +470,8 @@ func TestLicenses(t *testing.T) {
|
|||||||
for _, test := range licensesTests {
|
for _, test := range licensesTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
// Customize the common license text fixture factory.
|
// Customize the common license text fixture factory.
|
||||||
result := licenseTestFixtureFactory.Extend(
|
result := GroupFixturePreparers(
|
||||||
|
prepareForLicenseTest,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("mock_bad_module", newMockLicensesBadModule)
|
ctx.RegisterModuleType("mock_bad_module", newMockLicensesBadModule)
|
||||||
ctx.RegisterModuleType("mock_library", newMockLicensesLibraryModule)
|
ctx.RegisterModuleType("mock_library", newMockLicensesLibraryModule)
|
||||||
|
@@ -179,11 +179,9 @@ func TestErrorDependsOnDisabledModule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
emptyTestFixtureFactory.
|
prepareForModuleTests.
|
||||||
ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": depends on disabled module "bar"`)).
|
ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": depends on disabled module "bar"`)).
|
||||||
RunTest(t,
|
RunTestWithBp(t, bp)
|
||||||
prepareForModuleTests,
|
|
||||||
FixtureWithRootAndroidBp(bp))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCorrectBuildParams(t *testing.T) {
|
func TestValidateCorrectBuildParams(t *testing.T) {
|
||||||
@@ -268,9 +266,7 @@ func TestDistErrorChecking(t *testing.T) {
|
|||||||
"\\QAndroid.bp:18:17: module \"foo\": dists[1].suffix: Suffix may not contain a '/' character.\\E",
|
"\\QAndroid.bp:18:17: module \"foo\": dists[1].suffix: Suffix may not contain a '/' character.\\E",
|
||||||
}
|
}
|
||||||
|
|
||||||
emptyTestFixtureFactory.
|
prepareForModuleTests.
|
||||||
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(expectedErrs)).
|
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(expectedErrs)).
|
||||||
RunTest(t,
|
RunTestWithBp(t, bp)
|
||||||
prepareForModuleTests,
|
|
||||||
FixtureWithRootAndroidBp(bp))
|
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ func TestMutatorAddMissingDependencies(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
PrepareForTestWithAllowMissingDependencies,
|
PrepareForTestWithAllowMissingDependencies,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
||||||
@@ -74,7 +74,7 @@ func TestMutatorAddMissingDependencies(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
foo := result.ModuleForTests("foo", "").Module().(*mutatorTestModule)
|
foo := result.ModuleForTests("foo", "").Module().(*mutatorTestModule)
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ func TestModuleString(t *testing.T) {
|
|||||||
|
|
||||||
var moduleStrings []string
|
var moduleStrings []string
|
||||||
|
|
||||||
emptyTestFixtureFactory.RunTest(t,
|
GroupFixturePreparers(
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
|
|
||||||
ctx.PreArchMutators(func(ctx RegisterMutatorsContext) {
|
ctx.PreArchMutators(func(ctx RegisterMutatorsContext) {
|
||||||
@@ -128,7 +128,7 @@ func TestModuleString(t *testing.T) {
|
|||||||
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
want := []string{
|
want := []string{
|
||||||
// Initial name.
|
// Initial name.
|
||||||
@@ -187,7 +187,7 @@ func TestFinalDepsPhase(t *testing.T) {
|
|||||||
|
|
||||||
finalGot := map[string]int{}
|
finalGot := map[string]int{}
|
||||||
|
|
||||||
emptyTestFixtureFactory.RunTest(t,
|
GroupFixturePreparers(
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
dep1Tag := struct {
|
dep1Tag := struct {
|
||||||
blueprint.BaseDependencyTag
|
blueprint.BaseDependencyTag
|
||||||
@@ -224,7 +224,7 @@ func TestFinalDepsPhase(t *testing.T) {
|
|||||||
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
finalWant := map[string]int{
|
finalWant := map[string]int{
|
||||||
"common_dep_1{variant:a}": 1,
|
"common_dep_1{variant:a}": 1,
|
||||||
@@ -249,7 +249,7 @@ func TestNoCreateVariationsInFinalDeps(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emptyTestFixtureFactory.RunTest(t,
|
GroupFixturePreparers(
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.FinalDepsMutators(func(ctx RegisterMutatorsContext) {
|
ctx.FinalDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||||
ctx.BottomUp("vars", func(ctx BottomUpMutatorContext) {
|
ctx.BottomUp("vars", func(ctx BottomUpMutatorContext) {
|
||||||
@@ -265,5 +265,5 @@ func TestNoCreateVariationsInFinalDeps(t *testing.T) {
|
|||||||
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(`test {name: "foo"}`),
|
FixtureWithRootAndroidBp(`test {name: "foo"}`),
|
||||||
)
|
).RunTest(t)
|
||||||
}
|
}
|
||||||
|
@@ -633,21 +633,21 @@ func mockFiles(bps map[string]string) (files map[string][]byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupTestFromFiles(t *testing.T, bps MockFS) (ctx *TestContext, errs []error) {
|
func setupTestFromFiles(t *testing.T, bps MockFS) (ctx *TestContext, errs []error) {
|
||||||
result := emptyTestFixtureFactory.
|
result := GroupFixturePreparers(
|
||||||
|
FixtureModifyContext(func(ctx *TestContext) {
|
||||||
|
ctx.RegisterModuleType("test_module", newTestModule)
|
||||||
|
ctx.RegisterModuleType("soong_namespace", NamespaceFactory)
|
||||||
|
ctx.Context.RegisterModuleType("blueprint_test_module", newBlueprintTestModule)
|
||||||
|
ctx.PreArchMutators(RegisterNamespaceMutator)
|
||||||
|
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||||
|
ctx.BottomUp("rename", renameMutator)
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
bps.AddToFixture(),
|
||||||
|
).
|
||||||
// Ignore errors for now so tests can check them later.
|
// Ignore errors for now so tests can check them later.
|
||||||
ExtendWithErrorHandler(FixtureIgnoreErrors).
|
ExtendWithErrorHandler(FixtureIgnoreErrors).
|
||||||
RunTest(t,
|
RunTest(t)
|
||||||
FixtureModifyContext(func(ctx *TestContext) {
|
|
||||||
ctx.RegisterModuleType("test_module", newTestModule)
|
|
||||||
ctx.RegisterModuleType("soong_namespace", NamespaceFactory)
|
|
||||||
ctx.Context.RegisterModuleType("blueprint_test_module", newBlueprintTestModule)
|
|
||||||
ctx.PreArchMutators(RegisterNamespaceMutator)
|
|
||||||
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
|
||||||
ctx.BottomUp("rename", renameMutator)
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
bps.AddToFixture(),
|
|
||||||
)
|
|
||||||
|
|
||||||
return result.TestContext, result.Errs
|
return result.TestContext, result.Errs
|
||||||
}
|
}
|
||||||
|
@@ -299,18 +299,17 @@ var prepareForNeverAllowTest = GroupFixturePreparers(
|
|||||||
func TestNeverallow(t *testing.T) {
|
func TestNeverallow(t *testing.T) {
|
||||||
for _, test := range neverallowTests {
|
for _, test := range neverallowTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
emptyTestFixtureFactory.
|
GroupFixturePreparers(
|
||||||
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)).
|
prepareForNeverAllowTest,
|
||||||
RunTest(t,
|
FixtureModifyConfig(func(config Config) {
|
||||||
prepareForNeverAllowTest,
|
// If the test has its own rules then use them instead of the default ones.
|
||||||
FixtureModifyConfig(func(config Config) {
|
if test.rules != nil {
|
||||||
// If the test has its own rules then use them instead of the default ones.
|
SetTestNeverallowRules(config, test.rules)
|
||||||
if test.rules != nil {
|
}
|
||||||
SetTestNeverallowRules(config, test.rules)
|
}),
|
||||||
}
|
test.fs.AddToFixture(),
|
||||||
}),
|
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)).
|
||||||
test.fs.AddToFixture(),
|
RunTest(t)
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,13 +57,13 @@ func TestNinjaDeps(t *testing.T) {
|
|||||||
"test_ninja_deps/exists": nil,
|
"test_ninja_deps/exists": nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterSingletonType("test_ninja_deps_singleton", testNinjaDepsSingletonFactory)
|
ctx.RegisterSingletonType("test_ninja_deps_singleton", testNinjaDepsSingletonFactory)
|
||||||
ctx.RegisterSingletonType("ninja_deps_singleton", ninjaDepsSingletonFactory)
|
ctx.RegisterSingletonType("ninja_deps_singleton", ninjaDepsSingletonFactory)
|
||||||
}),
|
}),
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
// Verify that the ninja file has a dependency on the test_ninja_deps directory.
|
// Verify that the ninja file has a dependency on the test_ninja_deps directory.
|
||||||
if g, w := result.NinjaDeps, "test_ninja_deps"; !InList(w, g) {
|
if g, w := result.NinjaDeps, "test_ninja_deps"; !InList(w, g) {
|
||||||
|
@@ -61,13 +61,13 @@ var packageTests = []struct {
|
|||||||
func TestPackage(t *testing.T) {
|
func TestPackage(t *testing.T) {
|
||||||
for _, test := range packageTests {
|
for _, test := range packageTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
emptyTestFixtureFactory.
|
GroupFixturePreparers(
|
||||||
|
PrepareForTestWithArchMutator,
|
||||||
|
PrepareForTestWithPackageModule,
|
||||||
|
test.fs.AddToFixture(),
|
||||||
|
).
|
||||||
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)).
|
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)).
|
||||||
RunTest(t,
|
RunTest(t)
|
||||||
PrepareForTestWithArchMutator,
|
|
||||||
PrepareForTestWithPackageModule,
|
|
||||||
test.fs.AddToFixture(),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -96,14 +96,14 @@ func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []stri
|
|||||||
moduleFactory = packageTestModuleFactory
|
moduleFactory = packageTestModuleFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
PrepareForTestWithArchMutator,
|
PrepareForTestWithArchMutator,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("component", componentTestModuleFactory)
|
ctx.RegisterModuleType("component", componentTestModuleFactory)
|
||||||
ctx.RegisterModuleType("package_module", moduleFactory)
|
ctx.RegisterModuleType("package_module", moduleFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
p := result.Module("package", archVariant).(*packageTestModule)
|
p := result.Module("package", archVariant).(*packageTestModule)
|
||||||
actual := p.entries
|
actual := p.entries
|
||||||
|
@@ -157,14 +157,14 @@ func TestPathDepsMutator(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
PrepareForTestWithArchMutator,
|
PrepareForTestWithArchMutator,
|
||||||
PrepareForTestWithFilegroup,
|
PrepareForTestWithFilegroup,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("test", pathDepsMutatorTestModuleFactory)
|
ctx.RegisterModuleType("test", pathDepsMutatorTestModuleFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
m := result.Module("foo", "android_arm64_armv8-a").(*pathDepsMutatorTestModule)
|
m := result.Module("foo", "android_arm64_armv8-a").(*pathDepsMutatorTestModule)
|
||||||
|
|
||||||
|
@@ -1005,14 +1005,14 @@ func testPathForModuleSrc(t *testing.T, tests []pathForModuleSrcTestCase) {
|
|||||||
"foo/src_special/$": nil,
|
"foo/src_special/$": nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
|
ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
|
||||||
ctx.RegisterModuleType("output_file_provider", pathForModuleSrcOutputFileProviderModuleFactory)
|
ctx.RegisterModuleType("output_file_provider", pathForModuleSrcOutputFileProviderModuleFactory)
|
||||||
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
||||||
}),
|
}),
|
||||||
mockFS.AddToFixture(),
|
mockFS.AddToFixture(),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
m := result.ModuleForTests("foo", "").Module().(*pathForModuleSrcTestModule)
|
m := result.ModuleForTests("foo", "").Module().(*pathForModuleSrcTestModule)
|
||||||
|
|
||||||
@@ -1203,13 +1203,13 @@ func TestPathsForModuleSrc_AllowMissingDependencies(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
PrepareForTestWithAllowMissingDependencies,
|
PrepareForTestWithAllowMissingDependencies,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
|
ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
foo := result.ModuleForTests("foo", "").Module().(*pathForModuleSrcTestModule)
|
foo := result.ModuleForTests("foo", "").Module().(*pathForModuleSrcTestModule)
|
||||||
|
|
||||||
|
@@ -284,7 +284,7 @@ func TestPrebuilts(t *testing.T) {
|
|||||||
t.Errorf("windows is assumed to be disabled by default")
|
t.Errorf("windows is assumed to be disabled by default")
|
||||||
}
|
}
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.Extend(
|
result := GroupFixturePreparers(
|
||||||
PrepareForTestWithArchMutator,
|
PrepareForTestWithArchMutator,
|
||||||
PrepareForTestWithPrebuilts,
|
PrepareForTestWithPrebuilts,
|
||||||
PrepareForTestWithOverrides,
|
PrepareForTestWithOverrides,
|
||||||
|
@@ -542,11 +542,11 @@ func TestRuleBuilder_Build(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
prepareForRuleBuilderTest,
|
prepareForRuleBuilderTest,
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
check := func(t *testing.T, params TestingBuildParams, wantCommand, wantOutput, wantDepfile string, wantRestat bool, extraImplicits, extraCmdDeps []string) {
|
check := func(t *testing.T, params TestingBuildParams, wantCommand, wantOutput, wantDepfile string, wantRestat bool, extraImplicits, extraCmdDeps []string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
@@ -651,10 +651,10 @@ func TestRuleBuilderHashInputs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
prepareForRuleBuilderTest,
|
prepareForRuleBuilderTest,
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
for _, test := range testcases {
|
for _, test := range testcases {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
@@ -56,11 +56,10 @@ func TestSingletonModule(t *testing.T) {
|
|||||||
name: "test_singleton_module",
|
name: "test_singleton_module",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
result := emptyTestFixtureFactory.
|
result := GroupFixturePreparers(
|
||||||
RunTest(t,
|
prepareForSingletonModuleTest,
|
||||||
prepareForSingletonModuleTest,
|
FixtureWithRootAndroidBp(bp),
|
||||||
FixtureWithRootAndroidBp(bp),
|
).RunTest(t)
|
||||||
)
|
|
||||||
|
|
||||||
ops := result.ModuleForTests("test_singleton_module", "").Module().(*testSingletonModule).ops
|
ops := result.ModuleForTests("test_singleton_module", "").Module().(*testSingletonModule).ops
|
||||||
wantOps := []string{"GenerateAndroidBuildActions", "GenerateSingletonBuildActions", "MakeVars"}
|
wantOps := []string{"GenerateAndroidBuildActions", "GenerateSingletonBuildActions", "MakeVars"}
|
||||||
@@ -78,19 +77,16 @@ func TestDuplicateSingletonModule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
emptyTestFixtureFactory.
|
prepareForSingletonModuleTest.
|
||||||
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
||||||
`\QDuplicate SingletonModule "test_singleton_module", previously used in\E`,
|
`\QDuplicate SingletonModule "test_singleton_module", previously used in\E`,
|
||||||
})).RunTest(t,
|
})).RunTestWithBp(t, bp)
|
||||||
prepareForSingletonModuleTest,
|
|
||||||
FixtureWithRootAndroidBp(bp),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnusedSingletonModule(t *testing.T) {
|
func TestUnusedSingletonModule(t *testing.T) {
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
prepareForSingletonModuleTest,
|
prepareForSingletonModuleTest,
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
singleton := result.SingletonForTests("test_singleton_module").Singleton()
|
singleton := result.SingletonForTests("test_singleton_module").Singleton()
|
||||||
sm := singleton.(*singletonModuleSingletonAdaptor).sm
|
sm := singleton.(*singletonModuleSingletonAdaptor).sm
|
||||||
@@ -113,17 +109,16 @@ func TestVariantSingletonModule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
emptyTestFixtureFactory.
|
GroupFixturePreparers(
|
||||||
|
prepareForSingletonModuleTest,
|
||||||
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
|
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||||
|
ctx.BottomUp("test_singleton_module_mutator", testVariantSingletonModuleMutator)
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
).
|
||||||
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
||||||
`\QGenerateAndroidBuildActions already called for variant\E`,
|
`\QGenerateAndroidBuildActions already called for variant\E`,
|
||||||
})).
|
})).
|
||||||
RunTest(t,
|
RunTestWithBp(t, bp)
|
||||||
prepareForSingletonModuleTest,
|
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
|
||||||
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
|
||||||
ctx.BottomUp("test_singleton_module_mutator", testVariantSingletonModuleMutator)
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
FixtureWithRootAndroidBp(bp),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
@@ -278,7 +278,7 @@ func TestSoongConfigModule(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
tc.preparer,
|
tc.preparer,
|
||||||
PrepareForTestWithDefaults,
|
PrepareForTestWithDefaults,
|
||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
@@ -291,7 +291,7 @@ func TestSoongConfigModule(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
foo := result.ModuleForTests("foo", "").Module().(*soongConfigTestModule)
|
foo := result.ModuleForTests("foo", "").Module().(*soongConfigTestModule)
|
||||||
AssertDeepEquals(t, "foo cflags", tc.fooExpectedFlags, foo.props.Cflags)
|
AssertDeepEquals(t, "foo cflags", tc.fooExpectedFlags, foo.props.Cflags)
|
||||||
|
@@ -182,7 +182,7 @@ func TestProductVariables(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
emptyTestFixtureFactory.RunTest(t,
|
GroupFixturePreparers(
|
||||||
FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||||
variables.Eng = proptools.BoolPtr(true)
|
variables.Eng = proptools.BoolPtr(true)
|
||||||
}),
|
}),
|
||||||
@@ -204,7 +204,7 @@ func TestProductVariables(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
var testProductVariableDefaultsProperties = struct {
|
var testProductVariableDefaultsProperties = struct {
|
||||||
@@ -288,7 +288,7 @@ func TestProductVariablesDefaults(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := emptyTestFixtureFactory.RunTest(t,
|
result := GroupFixturePreparers(
|
||||||
FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||||
variables.Eng = boolPtr(true)
|
variables.Eng = boolPtr(true)
|
||||||
}),
|
}),
|
||||||
@@ -299,7 +299,7 @@ func TestProductVariablesDefaults(t *testing.T) {
|
|||||||
ctx.RegisterModuleType("defaults", productVariablesDefaultsTestDefaultsFactory)
|
ctx.RegisterModuleType("defaults", productVariablesDefaultsTestDefaultsFactory)
|
||||||
}),
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
)
|
).RunTest(t)
|
||||||
|
|
||||||
foo := result.ModuleForTests("foo", "").Module().(*productVariablesDefaultsTestModule)
|
foo := result.ModuleForTests("foo", "").Module().(*productVariablesDefaultsTestModule)
|
||||||
|
|
||||||
|
@@ -1142,7 +1142,7 @@ var visibilityTests = []struct {
|
|||||||
func TestVisibility(t *testing.T) {
|
func TestVisibility(t *testing.T) {
|
||||||
for _, test := range visibilityTests {
|
for _, test := range visibilityTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
result := emptyTestFixtureFactory.Extend(
|
result := GroupFixturePreparers(
|
||||||
// General preparers in alphabetical order as test infrastructure will enforce correct
|
// General preparers in alphabetical order as test infrastructure will enforce correct
|
||||||
// registration order.
|
// registration order.
|
||||||
PrepareForTestWithArchMutator,
|
PrepareForTestWithArchMutator,
|
||||||
|
Reference in New Issue
Block a user