Create sub tests for each test in TestJavaSdkLibraryEnforce am: aa6caa7fa8 am: 1094ec685f am: f2157304dd

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

Change-Id: I2cf16be39f897cc6214fef8a52f574eddbc341c3
This commit is contained in:
Paul Duffin 2021-03-15 21:21:04 +00:00 committed by Automerger Merge Worker
commit 5ca0e2e52b
1 changed files with 28 additions and 18 deletions

View File

@ -936,45 +936,55 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
return config
}
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))
}
})
}
errorMessage := "is not allowed across the partitions"
testJavaWithConfig(t, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_library",
fromPartition: "product",
toPartition: "system",
enforceVendorInterface: true,
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: false,
}))
}, "")
testJavaWithConfig(t, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_library",
fromPartition: "product",
toPartition: "system",
enforceVendorInterface: true,
enforceProductInterface: false,
enforceJavaSdkLibraryCheck: true,
}))
}, "")
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_library",
fromPartition: "product",
toPartition: "system",
enforceVendorInterface: true,
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: true,
}))
}, errorMessage)
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_library",
fromPartition: "vendor",
toPartition: "system",
enforceVendorInterface: true,
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: true,
}))
}, errorMessage)
testJavaWithConfig(t, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_library",
fromPartition: "vendor",
toPartition: "system",
@ -982,43 +992,43 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: true,
allowList: []string{"bar"},
}))
}, "")
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_library",
fromPartition: "vendor",
toPartition: "product",
enforceVendorInterface: true,
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: true,
}))
}, errorMessage)
testJavaWithConfig(t, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_sdk_library",
fromPartition: "product",
toPartition: "system",
enforceVendorInterface: true,
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: true,
}))
}, "")
testJavaWithConfig(t, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_sdk_library",
fromPartition: "vendor",
toPartition: "system",
enforceVendorInterface: true,
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: true,
}))
}, "")
testJavaWithConfig(t, createTestConfig(testConfigInfo{
runTest(t, testConfigInfo{
libraryType: "java_sdk_library",
fromPartition: "vendor",
toPartition: "product",
enforceVendorInterface: true,
enforceProductInterface: true,
enforceJavaSdkLibraryCheck: true,
}))
}, "")
}
func TestDefaults(t *testing.T) {