Add RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS
This build flag causes us to create aconfig flag artifacts for the given extra release configs. Bug: 298444886 Test: manual Change-Id: I10148f6e7318b0477438ed1d8baafbf4dc594c90
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package aconfig
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -134,3 +135,95 @@ func TestMandatoryProperties(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAssembleFileName(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
releaseConfig string
|
||||
path string
|
||||
expectedValue string
|
||||
}{
|
||||
{
|
||||
name: "active release config",
|
||||
path: "file.path",
|
||||
expectedValue: "file.path",
|
||||
},
|
||||
{
|
||||
name: "release config FOO",
|
||||
releaseConfig: "FOO",
|
||||
path: "file.path",
|
||||
expectedValue: "file-FOO.path",
|
||||
},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
actualValue := assembleFileName(test.releaseConfig, test.path)
|
||||
if actualValue != test.expectedValue {
|
||||
t.Errorf("Expected %q found %q", test.expectedValue, actualValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateAndroidBuildActions(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
buildFlags map[string]string
|
||||
bp string
|
||||
errorHandler android.FixtureErrorHandler
|
||||
}{
|
||||
{
|
||||
name: "generate extra",
|
||||
buildFlags: map[string]string{
|
||||
"RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS": "config2",
|
||||
"RELEASE_ACONFIG_VALUE_SETS": "aconfig_value_set-config1",
|
||||
"RELEASE_ACONFIG_VALUE_SETS_config2": "aconfig_value_set-config2",
|
||||
},
|
||||
bp: `
|
||||
aconfig_declarations {
|
||||
name: "module_name",
|
||||
package: "com.example.package",
|
||||
container: "com.android.foo",
|
||||
srcs: [
|
||||
"foo.aconfig",
|
||||
"bar.aconfig",
|
||||
],
|
||||
}
|
||||
aconfig_value_set {
|
||||
name: "aconfig_value_set-config1",
|
||||
values: []
|
||||
}
|
||||
aconfig_value_set {
|
||||
name: "aconfig_value_set-config2",
|
||||
values: []
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
fixture := PrepareForTest(t, addBuildFlagsForTest(test.buildFlags))
|
||||
if test.errorHandler != nil {
|
||||
fixture = fixture.ExtendWithErrorHandler(test.errorHandler)
|
||||
}
|
||||
result := fixture.RunTestWithBp(t, test.bp)
|
||||
module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)
|
||||
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigReleaseDeclarationsProviderKey)
|
||||
expectedKeys := []string{""}
|
||||
for _, rc := range strings.Split(test.buildFlags["RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS"], " ") {
|
||||
expectedKeys = append(expectedKeys, rc)
|
||||
}
|
||||
slices.Sort(expectedKeys)
|
||||
actualKeys := []string{}
|
||||
for rc := range depData {
|
||||
actualKeys = append(actualKeys, rc)
|
||||
}
|
||||
slices.Sort(actualKeys)
|
||||
android.AssertStringEquals(t, "provider keys", strings.Join(expectedKeys, " "), strings.Join(actualKeys, " "))
|
||||
for _, rc := range actualKeys {
|
||||
if !strings.HasSuffix(depData[rc].IntermediateCacheOutputPath.String(), assembleFileName(rc, "/intermediate.pb")) {
|
||||
t.Errorf("Incorrect intermediates proto path in provider for release config %s: %s", rc, depData[rc].IntermediateCacheOutputPath.String())
|
||||
}
|
||||
if !strings.HasSuffix(depData[rc].IntermediateDumpOutputPath.String(), assembleFileName(rc, "/intermediate.txt")) {
|
||||
t.Errorf("Incorrect intermediates text path in provider for release config %s: %s", rc, depData[rc].IntermediateDumpOutputPath.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user