Merge "Convert TestUsesLibraries to test fixtures" am: 8a6fef4db3
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1634631 Change-Id: I9845d1bc4e2e1b8663d8d6c1fc982c4741c7b672
This commit is contained in:
@@ -2360,15 +2360,14 @@ func TestUsesLibraries(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
config := testAppConfig(nil, bp, nil)
|
||||
config.TestProductVariables.MissingUsesLibraries = []string{"baz"}
|
||||
result := javaFixtureFactory.Extend(
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.MissingUsesLibraries = []string{"baz"}
|
||||
}),
|
||||
).RunTestWithBp(t, bp)
|
||||
|
||||
ctx := testContext(config)
|
||||
|
||||
run(t, ctx, config)
|
||||
|
||||
app := ctx.ModuleForTests("app", "android_common")
|
||||
prebuilt := ctx.ModuleForTests("prebuilt", "android_common")
|
||||
app := result.ModuleForTests("app", "android_common")
|
||||
prebuilt := result.ModuleForTests("prebuilt", "android_common")
|
||||
|
||||
// Test that implicit dependencies on java_sdk_library instances are passed to the manifest.
|
||||
// This should not include explicit `uses_libs`/`optional_uses_libs` entries.
|
||||
@@ -2380,10 +2379,7 @@ func TestUsesLibraries(t *testing.T) {
|
||||
`--uses-library com.non.sdk.lib ` + // TODO(b/132357300): "com.non.sdk.lib" should not be passed to manifest_fixer
|
||||
`--uses-library bar ` + // TODO(b/132357300): "bar" should not be passed to manifest_fixer
|
||||
`--uses-library runtime-library`
|
||||
if actualManifestFixerArgs != expectManifestFixerArgs {
|
||||
t.Errorf("unexpected manifest_fixer args:\n\texpect: %q\n\tactual: %q",
|
||||
expectManifestFixerArgs, actualManifestFixerArgs)
|
||||
}
|
||||
android.AssertStringEquals(t, "manifest_fixer args", expectManifestFixerArgs, actualManifestFixerArgs)
|
||||
|
||||
// Test that all libraries are verified (library order matters).
|
||||
verifyCmd := app.Rule("verify_uses_libraries").RuleParams.Command
|
||||
@@ -2394,9 +2390,7 @@ func TestUsesLibraries(t *testing.T) {
|
||||
`--uses-library runtime-library ` +
|
||||
`--optional-uses-library bar ` +
|
||||
`--optional-uses-library baz `
|
||||
if !strings.Contains(verifyCmd, verifyArgs) {
|
||||
t.Errorf("wanted %q in %q", verifyArgs, verifyCmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "verify cmd args", verifyCmd, verifyArgs)
|
||||
|
||||
// Test that all libraries are verified for an APK (library order matters).
|
||||
verifyApkCmd := prebuilt.Rule("verify_uses_libraries").RuleParams.Command
|
||||
@@ -2405,9 +2399,7 @@ func TestUsesLibraries(t *testing.T) {
|
||||
`--uses-library android.test.runner ` +
|
||||
`--optional-uses-library bar ` +
|
||||
`--optional-uses-library baz `
|
||||
if !strings.Contains(verifyApkCmd, verifyApkArgs) {
|
||||
t.Errorf("wanted %q in %q", verifyApkArgs, verifyApkCmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "verify apk cmd args", verifyApkCmd, verifyApkArgs)
|
||||
|
||||
// Test that all present libraries are preopted, including implicit SDK dependencies, possibly stubs
|
||||
cmd := app.Rule("dexpreopt").RuleParams.Command
|
||||
@@ -2418,46 +2410,39 @@ func TestUsesLibraries(t *testing.T) {
|
||||
`PCL[/system/framework/non-sdk-lib.jar]#` +
|
||||
`PCL[/system/framework/bar.jar]#` +
|
||||
`PCL[/system/framework/runtime-library.jar]`
|
||||
if !strings.Contains(cmd, w) {
|
||||
t.Errorf("wanted %q in %q", w, cmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "dexpreopt app cmd args", cmd, w)
|
||||
|
||||
// Test conditional context for target SDK version 28.
|
||||
if w := `--target-context-for-sdk 28` +
|
||||
` PCL[/system/framework/org.apache.http.legacy.jar] `; !strings.Contains(cmd, w) {
|
||||
t.Errorf("wanted %q in %q", w, cmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "dexpreopt app cmd 28", cmd,
|
||||
`--target-context-for-sdk 28`+
|
||||
` PCL[/system/framework/org.apache.http.legacy.jar] `)
|
||||
|
||||
// Test conditional context for target SDK version 29.
|
||||
if w := `--target-context-for-sdk 29` +
|
||||
` PCL[/system/framework/android.hidl.manager-V1.0-java.jar]` +
|
||||
`#PCL[/system/framework/android.hidl.base-V1.0-java.jar] `; !strings.Contains(cmd, w) {
|
||||
t.Errorf("wanted %q in %q", w, cmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "dexpreopt app cmd 29", cmd,
|
||||
`--target-context-for-sdk 29`+
|
||||
` PCL[/system/framework/android.hidl.manager-V1.0-java.jar]`+
|
||||
`#PCL[/system/framework/android.hidl.base-V1.0-java.jar] `)
|
||||
|
||||
// Test conditional context for target SDK version 30.
|
||||
// "android.test.mock" is absent because "android.test.runner" is not used.
|
||||
if w := `--target-context-for-sdk 30` +
|
||||
` PCL[/system/framework/android.test.base.jar] `; !strings.Contains(cmd, w) {
|
||||
t.Errorf("wanted %q in %q", w, cmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "dexpreopt app cmd 30", cmd,
|
||||
`--target-context-for-sdk 30`+
|
||||
` PCL[/system/framework/android.test.base.jar] `)
|
||||
|
||||
cmd = prebuilt.Rule("dexpreopt").RuleParams.Command
|
||||
if w := `--target-context-for-sdk any` +
|
||||
` PCL[/system/framework/foo.jar]` +
|
||||
`#PCL[/system/framework/non-sdk-lib.jar]` +
|
||||
`#PCL[/system/framework/android.test.runner.jar]` +
|
||||
`#PCL[/system/framework/bar.jar] `; !strings.Contains(cmd, w) {
|
||||
t.Errorf("wanted %q in %q", w, cmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "dexpreopt prebuilt cmd", cmd,
|
||||
`--target-context-for-sdk any`+
|
||||
` PCL[/system/framework/foo.jar]`+
|
||||
`#PCL[/system/framework/non-sdk-lib.jar]`+
|
||||
`#PCL[/system/framework/android.test.runner.jar]`+
|
||||
`#PCL[/system/framework/bar.jar] `)
|
||||
|
||||
// Test conditional context for target SDK version 30.
|
||||
// "android.test.mock" is present because "android.test.runner" is used.
|
||||
if w := `--target-context-for-sdk 30` +
|
||||
` PCL[/system/framework/android.test.base.jar]` +
|
||||
`#PCL[/system/framework/android.test.mock.jar] `; !strings.Contains(cmd, w) {
|
||||
t.Errorf("wanted %q in %q", w, cmd)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "dexpreopt prebuilt cmd 30", cmd,
|
||||
`--target-context-for-sdk 30`+
|
||||
` PCL[/system/framework/android.test.base.jar]`+
|
||||
`#PCL[/system/framework/android.test.mock.jar] `)
|
||||
}
|
||||
|
||||
func TestCodelessApp(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user