Convert TestJavaSdkLibraryEnforce to test fixtures am: 05f72de083 am: d486fc968f

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1634626

Change-Id: I3a0cbf953d393309ab2b4ee9ab4011095f0a5fc5
This commit is contained in:
Paul Duffin
2021-03-15 20:53:44 +00:00
committed by Automerger Merge Worker

View File

@@ -900,7 +900,7 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
allowList []string allowList []string
} }
createTestConfig := func(info testConfigInfo) android.Config { createPreparer := func(info testConfigInfo) android.FixturePreparer {
bpFileTemplate := ` bpFileTemplate := `
java_library { java_library {
name: "foo", name: "foo",
@@ -923,26 +923,26 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
info.libraryType, info.libraryType,
partitionToBpOption(info.toPartition)) partitionToBpOption(info.toPartition))
config := testConfig(nil, bpFile, nil) return android.GroupFixturePreparers(
configVariables := config.TestProductVariables android.FixtureWithRootAndroidBp(bpFile),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
configVariables.EnforceProductPartitionInterface = proptools.BoolPtr(info.enforceProductInterface) variables.EnforceProductPartitionInterface = proptools.BoolPtr(info.enforceProductInterface)
if info.enforceVendorInterface { if info.enforceVendorInterface {
configVariables.DeviceVndkVersion = proptools.StringPtr("current") variables.DeviceVndkVersion = proptools.StringPtr("current")
} }
configVariables.EnforceInterPartitionJavaSdkLibrary = proptools.BoolPtr(info.enforceJavaSdkLibraryCheck) variables.EnforceInterPartitionJavaSdkLibrary = proptools.BoolPtr(info.enforceJavaSdkLibraryCheck)
configVariables.InterPartitionJavaLibraryAllowList = info.allowList variables.InterPartitionJavaLibraryAllowList = info.allowList
}),
return config )
} }
runTest := func(t *testing.T, info testConfigInfo, expectedErrorPattern string) { runTest := func(t *testing.T, info testConfigInfo, expectedErrorPattern string) {
t.Run(fmt.Sprintf("%#v", info), func(t *testing.T) { t.Run(fmt.Sprintf("%#v", info), func(t *testing.T) {
if expectedErrorPattern == "" { errorHandler := android.FixtureExpectsNoErrors
testJavaWithConfig(t, createTestConfig(info)) if expectedErrorPattern != "" {
} else { errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern)
testJavaErrorWithConfig(t, expectedErrorPattern, createTestConfig(info))
} }
javaFixtureFactory.ExtendWithErrorHandler(errorHandler).RunTest(t, createPreparer(info))
}) })
} }