Remove FixturePreparer.Extend()
Use GroupFixturePreparers instead. Bug: 182885307 Test: m nothing Change-Id: Idc01d3cc5a57576a4cf417e9105d1ab851126e10
This commit is contained in:
parent
4814bb814a
commit
79abe57f53
|
@ -367,15 +367,6 @@ type FixturePreparer interface {
|
||||||
// Return the flattened and deduped list of simpleFixturePreparer pointers.
|
// Return the flattened and deduped list of simpleFixturePreparer pointers.
|
||||||
list() []*simpleFixturePreparer
|
list() []*simpleFixturePreparer
|
||||||
|
|
||||||
// Creates a copy of this instance and adds some additional preparers.
|
|
||||||
//
|
|
||||||
// Before the preparers are used they are combined with the current preparer, any groups of
|
|
||||||
// preparers are flattened, and the list is deduped so that each preparer is only used once. See
|
|
||||||
// the file documentation in android/fixture.go for more details.
|
|
||||||
//
|
|
||||||
// deprecated: Use GroupFixturePreparers() instead.
|
|
||||||
Extend(preparers ...FixturePreparer) FixturePreparer
|
|
||||||
|
|
||||||
// Create a Fixture.
|
// Create a Fixture.
|
||||||
Fixture(t *testing.T) Fixture
|
Fixture(t *testing.T) Fixture
|
||||||
|
|
||||||
|
@ -656,17 +647,12 @@ func (b *baseFixturePreparer) initBaseFixturePreparer(self FixturePreparer) {
|
||||||
b.self = self
|
b.self = self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseFixturePreparer) Extend(preparers ...FixturePreparer) FixturePreparer {
|
|
||||||
all := dedupAndFlattenPreparers(b.self.list(), preparers)
|
|
||||||
return newFixturePreparer(all)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseFixturePreparer) Fixture(t *testing.T) Fixture {
|
func (b *baseFixturePreparer) Fixture(t *testing.T) Fixture {
|
||||||
return createFixture(t, t.TempDir(), b.self.list())
|
return createFixture(t, t.TempDir(), b.self.list())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseFixturePreparer) ExtendWithErrorHandler(errorHandler FixtureErrorHandler) FixturePreparer {
|
func (b *baseFixturePreparer) ExtendWithErrorHandler(errorHandler FixtureErrorHandler) FixturePreparer {
|
||||||
return b.self.Extend(newSimpleFixturePreparer(func(fixture *fixture) {
|
return GroupFixturePreparers(b.self, newSimpleFixturePreparer(func(fixture *fixture) {
|
||||||
fixture.errorHandler = errorHandler
|
fixture.errorHandler = errorHandler
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestFixtureDedup(t *testing.T) {
|
||||||
|
|
||||||
group := GroupFixturePreparers(preparer1, preparer2, preparer1, preparer1Then2)
|
group := GroupFixturePreparers(preparer1, preparer2, preparer1, preparer1Then2)
|
||||||
|
|
||||||
extension := group.Extend(preparer4, preparer2)
|
extension := GroupFixturePreparers(group, preparer4, preparer2)
|
||||||
|
|
||||||
GroupFixturePreparers(extension, preparer1, preparer2, preparer2Then1, preparer3).Fixture(t)
|
GroupFixturePreparers(extension, preparer1, preparer2, preparer2Then1, preparer3).Fixture(t)
|
||||||
|
|
||||||
|
|
|
@ -670,7 +670,8 @@ func TestGenruleAllowMissingDependencies(t *testing.T) {
|
||||||
cmd: "cat $(in) > $(out)",
|
cmd: "cat $(in) > $(out)",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
result := prepareForGenRuleTest.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForGenRuleTest,
|
||||||
android.FixtureModifyConfigAndContext(
|
android.FixtureModifyConfigAndContext(
|
||||||
func(config android.Config, ctx *android.TestContext) {
|
func(config android.Config, ctx *android.TestContext) {
|
||||||
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
||||||
|
|
|
@ -39,7 +39,8 @@ var hiddenApiFixtureFactory = android.GroupFixturePreparers(
|
||||||
prepareForJavaTest, PrepareForTestWithHiddenApiBuildComponents)
|
prepareForJavaTest, PrepareForTestWithHiddenApiBuildComponents)
|
||||||
|
|
||||||
func TestHiddenAPISingleton(t *testing.T) {
|
func TestHiddenAPISingleton(t *testing.T) {
|
||||||
result := hiddenApiFixtureFactory.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
fixtureSetBootJarsProductVariable("platform:foo"),
|
fixtureSetBootJarsProductVariable("platform:foo"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
java_library {
|
java_library {
|
||||||
|
@ -56,7 +57,8 @@ func TestHiddenAPISingleton(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHiddenAPIIndexSingleton(t *testing.T) {
|
func TestHiddenAPIIndexSingleton(t *testing.T) {
|
||||||
result := hiddenApiFixtureFactory.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
PrepareForTestWithJavaSdkLibraryFiles,
|
PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
FixtureWithLastReleaseApis("bar"),
|
FixtureWithLastReleaseApis("bar"),
|
||||||
fixtureSetBootJarsProductVariable("platform:foo", "platform:bar"),
|
fixtureSetBootJarsProductVariable("platform:foo", "platform:bar"),
|
||||||
|
@ -115,7 +117,8 @@ func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T)
|
||||||
" replaced by the prebuilt module \"prebuilt_foo\" but unfortunately it does not provide a" +
|
" replaced by the prebuilt module \"prebuilt_foo\" but unfortunately it does not provide a" +
|
||||||
" suitable boot dex jar"
|
" suitable boot dex jar"
|
||||||
|
|
||||||
hiddenApiFixtureFactory.Extend(
|
android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
fixtureSetBootJarsProductVariable("platform:foo"),
|
fixtureSetBootJarsProductVariable("platform:foo"),
|
||||||
).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorMessage)).
|
).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorMessage)).
|
||||||
RunTestWithBp(t, `
|
RunTestWithBp(t, `
|
||||||
|
@ -134,7 +137,8 @@ func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHiddenAPISingletonWithPrebuilt(t *testing.T) {
|
func TestHiddenAPISingletonWithPrebuilt(t *testing.T) {
|
||||||
result := hiddenApiFixtureFactory.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
fixtureSetBootJarsProductVariable("platform:foo"),
|
fixtureSetBootJarsProductVariable("platform:foo"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
java_import {
|
java_import {
|
||||||
|
@ -151,7 +155,8 @@ func TestHiddenAPISingletonWithPrebuilt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) {
|
func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) {
|
||||||
result := hiddenApiFixtureFactory.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
fixtureSetBootJarsProductVariable("platform:foo"),
|
fixtureSetBootJarsProductVariable("platform:foo"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
java_library {
|
java_library {
|
||||||
|
@ -178,7 +183,8 @@ func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) {
|
func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) {
|
||||||
result := hiddenApiFixtureFactory.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
fixtureSetBootJarsProductVariable("platform:foo"),
|
fixtureSetBootJarsProductVariable("platform:foo"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
java_library {
|
java_library {
|
||||||
|
@ -236,7 +242,8 @@ func TestHiddenAPISingletonSdks(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 := hiddenApiFixtureFactory.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
tc.preparer,
|
tc.preparer,
|
||||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild)
|
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild)
|
||||||
|
@ -286,7 +293,8 @@ func TestHiddenAPISingletonWithPrebuiltCsvFile(t *testing.T) {
|
||||||
// Where to find the prebuilt hiddenapi files:
|
// Where to find the prebuilt hiddenapi files:
|
||||||
prebuiltHiddenApiDir := "path/to/prebuilt/hiddenapi"
|
prebuiltHiddenApiDir := "path/to/prebuilt/hiddenapi"
|
||||||
|
|
||||||
result := hiddenApiFixtureFactory.Extend(
|
result := android.GroupFixturePreparers(
|
||||||
|
hiddenApiFixtureFactory,
|
||||||
fixtureSetBootJarsProductVariable("platform:foo"),
|
fixtureSetBootJarsProductVariable("platform:foo"),
|
||||||
fixtureSetPrebuiltHiddenApiDirProductVariable(&prebuiltHiddenApiDir),
|
fixtureSetPrebuiltHiddenApiDirProductVariable(&prebuiltHiddenApiDir),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
|
|
|
@ -402,14 +402,16 @@ func TestClasspath(t *testing.T) {
|
||||||
|
|
||||||
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 8 -target 8
|
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 8 -target 8
|
||||||
t.Run("REL + Java language level 8", func(t *testing.T) {
|
t.Run("REL + Java language level 8", func(t *testing.T) {
|
||||||
result := fixtureFactory.Extend(prepareWithPlatformVersionRel).RunTestWithBp(t, bpJava8)
|
result := android.GroupFixturePreparers(
|
||||||
|
fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bpJava8)
|
||||||
|
|
||||||
checkClasspath(t, result, true /* isJava8 */)
|
checkClasspath(t, result, true /* isJava8 */)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9
|
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9
|
||||||
t.Run("REL + Java language level 9", func(t *testing.T) {
|
t.Run("REL + Java language level 9", func(t *testing.T) {
|
||||||
result := fixtureFactory.Extend(prepareWithPlatformVersionRel).RunTestWithBp(t, bp)
|
result := android.GroupFixturePreparers(
|
||||||
|
fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
checkClasspath(t, result, false /* isJava8 */)
|
checkClasspath(t, result, false /* isJava8 */)
|
||||||
})
|
})
|
||||||
|
|
|
@ -28,9 +28,10 @@ import (
|
||||||
// testProjectJson run the generation of rust-project.json. It returns the raw
|
// testProjectJson run the generation of rust-project.json. It returns the raw
|
||||||
// content of the generated file.
|
// content of the generated file.
|
||||||
func testProjectJson(t *testing.T, bp string) []byte {
|
func testProjectJson(t *testing.T, bp string) []byte {
|
||||||
result := prepareForRustTest.
|
result := android.GroupFixturePreparers(
|
||||||
Extend(android.FixtureMergeEnv(map[string]string{"SOONG_GEN_RUST_PROJECT": "1"})).
|
prepareForRustTest,
|
||||||
RunTestWithBp(t, bp)
|
android.FixtureMergeEnv(map[string]string{"SOONG_GEN_RUST_PROJECT": "1"}),
|
||||||
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
// The JSON file is generated via WriteFileToOutputDir. Therefore, it
|
// The JSON file is generated via WriteFileToOutputDir. Therefore, it
|
||||||
// won't appear in the Output of the TestingSingleton. Manually verify
|
// won't appear in the Output of the TestingSingleton. Manually verify
|
||||||
|
|
Loading…
Reference in New Issue