diff options
| author | 2022-04-07 17:40:07 -0700 | |
|---|---|---|
| committer | 2022-04-11 11:50:34 -0700 | |
| commit | 412436f7fed2137591745ef597bb25e3a2d90d48 (patch) | |
| tree | affe93a4fecb987ea4a799774519623549650ec0 /java/app_test.go | |
| parent | abc0dab4770b4fe27147388d90c9ef5f1f49feca (diff) | |
Don't panic if no certificates found
Getting the first certificate will panic if there are no certificates,
which can happen when AllowMissingDependencies is set and the
certificate property is a module reference to a missing module.
Only get the first certificate if the list is not nil.
Bug: 228379411
Test: TestAppMissingCertificateAllowMissingDependencies
Change-Id: I046d75dbbd4f21f4a2b6851f558e430e9879fcff
Diffstat (limited to 'java/app_test.go')
| -rw-r--r-- | java/app_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go index 08baf5434..6a4508cd6 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2948,3 +2948,24 @@ func TestTargetSdkVersionManifestFixer(t *testing.T) { android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected) } } + +func TestAppMissingCertificateAllowMissingDependencies(t *testing.T) { + result := android.GroupFixturePreparers( + PrepareForTestWithJavaDefaultModules, + android.PrepareForTestWithAllowMissingDependencies, + android.PrepareForTestWithAndroidMk, + ).RunTestWithBp(t, ` + android_app { + name: "foo", + srcs: ["a.java"], + certificate: ":missing_certificate", + sdk_version: "current", + }`) + + foo := result.ModuleForTests("foo", "android_common") + fooApk := foo.Output("foo.apk") + if fooApk.Rule != android.ErrorRule { + t.Fatalf("expected ErrorRule for foo.apk, got %s", fooApk.Rule.String()) + } + android.AssertStringDoesContain(t, "expected error rule message", fooApk.Args["error"], "missing dependencies: missing_certificate\n") +} |