Migrate sdk tests away from checkAndroidBpContents

Replaces a single call to checkAndroidBpContents(...) with separate
calls to check the versioned and unversioned Android.bp files.

Test: m nothing
Bug: 179354495
Change-Id: I270bf73909958d97b2f298e8d7f6d10a1f75ae71
This commit is contained in:
Paul Duffin 2021-04-16 17:05:10 +01:00
parent 27b5e614c8
commit e1381887ae
2 changed files with 227 additions and 168 deletions

View File

@ -43,7 +43,18 @@ func TestModuleExportsSnapshot(t *testing.T) {
})
CheckSnapshot(t, result, "myexports", "package",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@ -54,18 +65,11 @@ java_import {
jars: ["java/myjavalib.jar"],
}
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
module_exports_snapshot {
name: "myexports@current",
visibility: ["//visibility:public"],
java_libs: ["myexports_myjavalib@current"],
}
`))
`),
)
}

View File

@ -179,7 +179,18 @@ func TestSnapshotWithJavaHeaderLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@ -190,20 +201,11 @@ java_import {
jars: ["java/myjavalib.jar"],
}
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
sdk_snapshot {
name: "mysdk@current",
visibility: ["//visibility:public"],
java_header_libs: ["mysdk_myjavalib@current"],
}
`),
checkAllCopyRules(`
.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar
@ -239,22 +241,25 @@ func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavalib.jar"],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
@ -296,12 +301,12 @@ func TestDeviceAndHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
host_supported: true,
@ -314,10 +319,13 @@ java_import {
},
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
host_supported: true,
@ -371,7 +379,18 @@ func TestSnapshotWithJavaImplLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "myexports", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@ -382,20 +401,11 @@ java_import {
jars: ["java/myjavalib.jar"],
}
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
module_exports_snapshot {
name: "myexports@current",
visibility: ["//visibility:public"],
java_libs: ["myexports_myjavalib@current"],
}
`),
checkAllCopyRules(`
.intermediates/myjavalib/android_common/withres/myjavalib.jar -> java/myjavalib.jar
@ -431,7 +441,18 @@ func TestSnapshotWithJavaBootLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "myexports", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@ -442,14 +463,6 @@ java_import {
jars: ["java/myjavalib.jar"],
}
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
module_exports_snapshot {
name: "myexports@current",
visibility: ["//visibility:public"],
@ -489,22 +502,25 @@ func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "myexports", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myexports_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavalib.jar"],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myjavalib",
prefer: false,
name: "myexports_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
@ -545,21 +561,24 @@ func TestSnapshotWithJavaTest(t *testing.T) {
`)
CheckSnapshot(t, result, "myexports", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
name: "myjavatests",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
name: "myjavatests",
prefer: false,
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavatests.jar"],
@ -600,12 +619,12 @@ func TestHostSnapshotWithJavaTest(t *testing.T) {
`)
CheckSnapshot(t, result, "myexports", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
name: "myjavatests",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
@ -613,10 +632,13 @@ java_test_import {
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
name: "myjavatests",
prefer: false,
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
@ -669,20 +691,41 @@ func TestSnapshotWithJavaSystemModules(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "mysdk_exported-system-module@current",
sdk_member_name: "exported-system-module",
name: "exported-system-module",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/exported-system-module.jar"],
}
java_import {
name: "exported-system-module",
name: "mysdk_system-module",
prefer: false,
visibility: ["//visibility:private"],
apex_available: ["//apex_available:platform"],
jars: ["java/system-module.jar"],
}
java_system_modules_import {
name: "my-system-modules",
prefer: false,
visibility: ["//visibility:public"],
libs: [
"mysdk_system-module",
"exported-system-module",
],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "mysdk_exported-system-module@current",
sdk_member_name: "exported-system-module",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/exported-system-module.jar"],
@ -696,14 +739,6 @@ java_import {
jars: ["java/system-module.jar"],
}
java_import {
name: "mysdk_system-module",
prefer: false,
visibility: ["//visibility:private"],
apex_available: ["//apex_available:platform"],
jars: ["java/system-module.jar"],
}
java_system_modules_import {
name: "mysdk_my-system-modules@current",
sdk_member_name: "my-system-modules",
@ -714,16 +749,6 @@ java_system_modules_import {
],
}
java_system_modules_import {
name: "my-system-modules",
prefer: false,
visibility: ["//visibility:public"],
libs: [
"mysdk_system-module",
"exported-system-module",
],
}
sdk_snapshot {
name: "mysdk@current",
visibility: ["//visibility:public"],
@ -765,12 +790,12 @@ func TestHostSnapshotWithJavaSystemModules(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "mysdk_system-module@current",
sdk_member_name: "system-module",
name: "mysdk_system-module",
prefer: false,
visibility: ["//visibility:private"],
apex_available: ["//apex_available:platform"],
device_supported: false,
@ -778,9 +803,21 @@ java_import {
jars: ["java/system-module.jar"],
}
java_import {
name: "mysdk_system-module",
java_system_modules_import {
name: "my-system-modules",
prefer: false,
visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
libs: ["mysdk_system-module"],
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "mysdk_system-module@current",
sdk_member_name: "system-module",
visibility: ["//visibility:private"],
apex_available: ["//apex_available:platform"],
device_supported: false,
@ -797,15 +834,6 @@ java_system_modules_import {
libs: ["mysdk_system-module@current"],
}
java_system_modules_import {
name: "my-system-modules",
prefer: false,
visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
libs: ["mysdk_system-module"],
}
sdk_snapshot {
name: "mysdk@current",
visibility: ["//visibility:public"],
@ -856,12 +884,12 @@ func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) {
`)
CheckSnapshot(t, result, "myexports", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myexports_hostjavalib@current",
sdk_member_name: "hostjavalib",
name: "hostjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
@ -870,10 +898,37 @@ java_import {
}
java_import {
name: "hostjavalib",
name: "androidjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/androidjavalib.jar"],
}
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
host_supported: true,
target: {
android: {
jars: ["java/android/myjavalib.jar"],
},
linux_glibc: {
jars: ["java/linux_glibc/myjavalib.jar"],
},
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
name: "myexports_hostjavalib@current",
sdk_member_name: "hostjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/hostjavalib.jar"],
@ -887,14 +942,6 @@ java_import {
jars: ["java/androidjavalib.jar"],
}
java_import {
name: "androidjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/androidjavalib.jar"],
}
java_import {
name: "myexports_myjavalib@current",
sdk_member_name: "myjavalib",
@ -911,22 +958,6 @@ java_import {
},
}
java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
host_supported: true,
target: {
android: {
jars: ["java/android/myjavalib.jar"],
},
linux_glibc: {
jars: ["java/linux_glibc/myjavalib.jar"],
},
},
}
module_exports_snapshot {
name: "myexports@current",
visibility: ["//visibility:public"],
@ -970,12 +1001,12 @@ func TestSnapshotWithJavaSdkLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: false,
@ -1001,10 +1032,13 @@ java_sdk_library_import {
sdk_version: "test_current",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: false,
@ -1071,12 +1105,12 @@ func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
shared_library: true,
@ -1088,10 +1122,13 @@ java_sdk_library_import {
sdk_version: "none",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
shared_library: true,
@ -1140,12 +1177,12 @@ func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
shared_library: true,
@ -1157,10 +1194,13 @@ java_sdk_library_import {
sdk_version: "module_current",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
shared_library: true,
@ -1212,12 +1252,12 @@ func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: true,
@ -1236,10 +1276,13 @@ java_sdk_library_import {
sdk_version: "system_current",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: true,
@ -1305,12 +1348,12 @@ func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: true,
@ -1336,10 +1379,13 @@ java_sdk_library_import {
sdk_version: "module_current",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: true,
@ -1413,12 +1459,12 @@ func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: true,
@ -1437,10 +1483,13 @@ java_sdk_library_import {
sdk_version: "system_server_current",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
shared_library: true,
@ -1501,12 +1550,12 @@ func TestSnapshotWithJavaSdkLibrary_NamingScheme(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
naming_scheme: "default",
@ -1519,10 +1568,13 @@ java_sdk_library_import {
sdk_version: "current",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:anyapex"],
naming_scheme: "default",
@ -1580,12 +1632,12 @@ func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
shared_library: true,
@ -1598,10 +1650,13 @@ java_sdk_library_import {
sdk_version: "current",
},
}
`),
checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
name: "myjavalib",
prefer: false,
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
shared_library: true,