diff options
author | Paul Duffin <paulduffin@google.com> | 2021-03-12 21:28:51 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2021-03-15 17:17:43 +0000 |
commit | 05f72de0837021c7f80133e22392a1a238b1c56f (patch) | |
tree | 43b2a6d2dcb699f12d5b43d3628854a127758625 /java/java_test.go | |
parent | aa6caa7fa8c3c662df82d3df950a8a6ecaf7477d (diff) |
Convert TestJavaSdkLibraryEnforce to test fixtures
Bug: 182638834
Test: m nothing
Change-Id: I99efe76008f9ca0996177f47923274ca594a6858
Diffstat (limited to 'java/java_test.go')
-rw-r--r-- | java/java_test.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/java/java_test.go b/java/java_test.go index 0a2237889..9ef23e9a9 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -900,7 +900,7 @@ func TestJavaSdkLibraryEnforce(t *testing.T) { allowList []string } - createTestConfig := func(info testConfigInfo) android.Config { + createPreparer := func(info testConfigInfo) android.FixturePreparer { bpFileTemplate := ` java_library { name: "foo", @@ -923,26 +923,26 @@ func TestJavaSdkLibraryEnforce(t *testing.T) { info.libraryType, partitionToBpOption(info.toPartition)) - config := testConfig(nil, bpFile, nil) - configVariables := config.TestProductVariables - - configVariables.EnforceProductPartitionInterface = proptools.BoolPtr(info.enforceProductInterface) - if info.enforceVendorInterface { - configVariables.DeviceVndkVersion = proptools.StringPtr("current") - } - configVariables.EnforceInterPartitionJavaSdkLibrary = proptools.BoolPtr(info.enforceJavaSdkLibraryCheck) - configVariables.InterPartitionJavaLibraryAllowList = info.allowList - - return config + return android.GroupFixturePreparers( + android.FixtureWithRootAndroidBp(bpFile), + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.EnforceProductPartitionInterface = proptools.BoolPtr(info.enforceProductInterface) + if info.enforceVendorInterface { + variables.DeviceVndkVersion = proptools.StringPtr("current") + } + variables.EnforceInterPartitionJavaSdkLibrary = proptools.BoolPtr(info.enforceJavaSdkLibraryCheck) + variables.InterPartitionJavaLibraryAllowList = info.allowList + }), + ) } runTest := func(t *testing.T, info testConfigInfo, expectedErrorPattern string) { t.Run(fmt.Sprintf("%#v", info), func(t *testing.T) { - if expectedErrorPattern == "" { - testJavaWithConfig(t, createTestConfig(info)) - } else { - testJavaErrorWithConfig(t, expectedErrorPattern, createTestConfig(info)) + errorHandler := android.FixtureExpectsNoErrors + if expectedErrorPattern != "" { + errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern) } + javaFixtureFactory.ExtendWithErrorHandler(errorHandler).RunTest(t, createPreparer(info)) }) } |