diff options
author | 2024-10-21 12:36:03 -0700 | |
---|---|---|
committer | 2024-10-29 10:52:42 -0700 | |
commit | 768b00f9001e65656b4b46dac705ba375b0b0b1b (patch) | |
tree | 174468dc9393de7b8c93a98c2cc727d5d7ae5c84 /android/config_test.go | |
parent | ec62d843de7b7fa7234e6d532081e06e44eebec6 (diff) |
Only use partial compile on eng builds
Bug: b/365536323
Test: manual
Change-Id: Ib52a7c7fc14490aa62f18408a76bec20e40c3350
Diffstat (limited to 'android/config_test.go')
-rw-r--r-- | android/config_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/android/config_test.go b/android/config_test.go index 773216844..adb5ffac5 100644 --- a/android/config_test.go +++ b/android/config_test.go @@ -212,3 +212,48 @@ func TestConfiguredJarList(t *testing.T) { 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) + } + }) + } +} |