summaryrefslogtreecommitdiff
path: root/java/dex_test.go
diff options
context:
space:
mode:
author Remi NGUYEN VAN <reminv@google.com> 2022-08-04 13:19:03 +0900
committer Remi NGUYEN VAN <reminv@google.com> 2022-08-04 13:23:47 +0900
commitbdad314f978cf52a9e3f5c1db5f39169fcecc610 (patch)
tree6f32b313633db57fe0d02962a8476ee103f1117a /java/dex_test.go
parentb7873a8b0fa950bcab2e90e2e8ce3d4664e91eb2 (diff)
Make ignorewarnings optional in optimize
This allows targets to opt-in to running R8 without the -ignorewarnings flag. Ignored warnings can cause code to be optimized incorrectly, so this makes the build safer for such targets. Ideally ignore_warnings should default to false, but all targets need to be fixed for that to happen. As a first step, provide a mechanism for individual targets to ensure they do not introduce regressions. Bug: 229727645 Bug: 180878971 Bug: 226127213 Bug: 239990030 Test: m (runs dex_test) Change-Id: Ic0eef29598c1ee47e958da8a5048d9696165a235
Diffstat (limited to 'java/dex_test.go')
-rw-r--r--java/dex_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/java/dex_test.go b/java/dex_test.go
index fbdccb65d..a3e2deda4 100644
--- a/java/dex_test.go
+++ b/java/dex_test.go
@@ -59,6 +59,36 @@ func TestR8(t *testing.T) {
appR8.Args["r8Flags"], libHeader.String())
android.AssertStringDoesNotContain(t, "expected no static_lib header jar in app javac classpath",
appR8.Args["r8Flags"], staticLibHeader.String())
+ android.AssertStringDoesContain(t, "expected -ignorewarnings in app r8 flags",
+ appR8.Args["r8Flags"], "-ignorewarnings")
+}
+
+func TestR8Flags(t *testing.T) {
+ result := PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd.RunTestWithBp(t, `
+ android_app {
+ name: "app",
+ srcs: ["foo.java"],
+ platform_apis: true,
+ optimize: {
+ shrink: false,
+ optimize: false,
+ obfuscate: false,
+ ignore_warnings: false,
+ },
+ }
+ `)
+
+ app := result.ModuleForTests("app", "android_common")
+ appR8 := app.Rule("r8")
+ android.AssertStringDoesContain(t, "expected -dontshrink in app r8 flags",
+ appR8.Args["r8Flags"], "-dontshrink")
+ android.AssertStringDoesContain(t, "expected -dontoptimize in app r8 flags",
+ appR8.Args["r8Flags"], "-dontoptimize")
+ android.AssertStringDoesContain(t, "expected -dontobfuscate in app r8 flags",
+ appR8.Args["r8Flags"], "-dontobfuscate")
+ android.AssertStringDoesNotContain(t, "expected no -ignorewarnings in app r8 flags",
+ appR8.Args["r8Flags"], "-ignorewarnings")
+
}
func TestD8(t *testing.T) {