Merge "Correctly serialize class loader context for "any" SDK version to JSON." am: 1b60bb4fe1
am: 63015df873
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2077659 Change-Id: I79e5a0f919530bf00159e4c6f8b7856ad08287ac Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -678,6 +678,9 @@ func toJsonClassLoaderContext(clcMap ClassLoaderContextMap) jsonClassLoaderConte
|
|||||||
jClcMap := make(jsonClassLoaderContextMap)
|
jClcMap := make(jsonClassLoaderContextMap)
|
||||||
for sdkVer, clcs := range clcMap {
|
for sdkVer, clcs := range clcMap {
|
||||||
sdkVerStr := fmt.Sprintf("%d", sdkVer)
|
sdkVerStr := fmt.Sprintf("%d", sdkVer)
|
||||||
|
if sdkVer == AnySdkVersion {
|
||||||
|
sdkVerStr = "any"
|
||||||
|
}
|
||||||
jClcMap[sdkVerStr] = toJsonClassLoaderContextRec(clcs)
|
jClcMap[sdkVerStr] = toJsonClassLoaderContextRec(clcs)
|
||||||
}
|
}
|
||||||
return jClcMap
|
return jClcMap
|
||||||
|
@@ -389,6 +389,38 @@ func TestCLCMExcludeLibs(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that CLC is correctly serialized to JSON.
|
||||||
|
func TestCLCtoJSON(t *testing.T) {
|
||||||
|
ctx := testContext()
|
||||||
|
optional := false
|
||||||
|
implicit := true
|
||||||
|
m := make(ClassLoaderContextMap)
|
||||||
|
m.AddContext(ctx, 28, "a", optional, implicit, buildPath(ctx, "a"), installPath(ctx, "a"), nil)
|
||||||
|
m.AddContext(ctx, AnySdkVersion, "b", optional, implicit, buildPath(ctx, "b"), installPath(ctx, "b"), nil)
|
||||||
|
android.AssertStringEquals(t, "output CLCM ", `{
|
||||||
|
"28": [
|
||||||
|
{
|
||||||
|
"Name": "a",
|
||||||
|
"Optional": false,
|
||||||
|
"Implicit": true,
|
||||||
|
"Host": "out/soong/a.jar",
|
||||||
|
"Device": "/system/a.jar",
|
||||||
|
"Subcontexts": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"any": [
|
||||||
|
{
|
||||||
|
"Name": "b",
|
||||||
|
"Optional": false,
|
||||||
|
"Implicit": true,
|
||||||
|
"Host": "out/soong/b.jar",
|
||||||
|
"Device": "/system/b.jar",
|
||||||
|
"Subcontexts": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`, m.Dump())
|
||||||
|
}
|
||||||
|
|
||||||
func checkError(t *testing.T, have error, want string) {
|
func checkError(t *testing.T, have error, want string) {
|
||||||
if have == nil {
|
if have == nil {
|
||||||
t.Errorf("\nwant error: '%s'\nhave: none", want)
|
t.Errorf("\nwant error: '%s'\nhave: none", want)
|
||||||
|
Reference in New Issue
Block a user