Reapply "Only use partial compile on eng builds"
This reverts commit bef36af55ac6f97002eb51ed251bad3cf652ff27, and avoids
reanalysis on every build for eng builds.
Bug: b/365536323
Test: manual, TH
Change-Id: Ie6eafa09494c3c2525434086f281b387da0e270d
diff --git a/android/config_test.go b/android/config_test.go
index 7732168..adb5ffa 100644
--- a/android/config_test.go
+++ b/android/config_test.go
@@ -212,3 +212,48 @@
assertStringEquals(t, "apex1:jarA", list5.String())
})
}
+
+func (p partialCompileFlags) updateEnabled(value bool) partialCompileFlags {
+ p.enabled = value
+ return p
+}
+
+func (p partialCompileFlags) updateUseD8(value bool) partialCompileFlags {
+ p.use_d8 = value
+ return p
+}
+
+func TestPartialCompile(t *testing.T) {
+ mockConfig := func(value string) *config {
+ c := &config{
+ env: map[string]string{
+ "SOONG_PARTIAL_COMPILE": value,
+ },
+ }
+ return c
+ }
+ tests := []struct {
+ value string
+ isEngBuild bool
+ expected partialCompileFlags
+ }{
+ {"", true, defaultPartialCompileFlags},
+ {"false", true, partialCompileFlags{}},
+ {"true", true, defaultPartialCompileFlags.updateEnabled(true)},
+ {"true", false, partialCompileFlags{}},
+ {"true,use_d8", true, defaultPartialCompileFlags.updateEnabled(true).updateUseD8(true)},
+ {"true,-use_d8", true, defaultPartialCompileFlags.updateEnabled(true).updateUseD8(false)},
+ {"use_d8,false", true, partialCompileFlags{}},
+ {"false,+use_d8", true, partialCompileFlags{}.updateUseD8(true)},
+ }
+
+ for _, test := range tests {
+ t.Run(test.value, func(t *testing.T) {
+ config := mockConfig(test.value)
+ flags, _ := config.parsePartialCompileFlags(test.isEngBuild)
+ if flags != test.expected {
+ t.Errorf("expected %v found %v", test.expected, flags)
+ }
+ })
+ }
+}