Add "force-read-only" mode to xx_aconfig_library build rules

Test: added unit tests and CI
Bug: 317115655
Change-Id: Ia72159ffe072f9b4997f0d4d55a7b3db5356f5ed
This commit is contained in:
Zhi Dou 2023-12-20 23:14:34 +00:00
parent 412b33a6e7
commit 70e2124c88
6 changed files with 10 additions and 1 deletions

View file

@ -40,6 +40,7 @@ type CcAconfigLibraryProperties struct {
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
// "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}

View file

@ -29,6 +29,7 @@ var ccCodegenModeTestData = []struct {
{"mode: `production`,", "production"},
{"mode: `test`,", "test"},
{"mode: `exported`,", "exported"},
{"mode: `force-read-only`,", "force-read-only"},
}
func TestCCCodegenMode(t *testing.T) {

View file

@ -30,7 +30,7 @@ type declarationsTagType struct {
var declarationsTag = declarationsTagType{}
var aconfigSupportedModes = []string{"production", "test", "exported"}
var aconfigSupportedModes = []string{"production", "test", "exported", "force-read-only"}
type JavaAconfigDeclarationsLibraryProperties struct {
// name of the aconfig_declarations module to generate a library for
@ -39,6 +39,7 @@ type JavaAconfigDeclarationsLibraryProperties struct {
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
// "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}

View file

@ -227,6 +227,10 @@ func TestExportedMode(t *testing.T) {
testCodegenMode(t, "mode: `exported`,", "exported")
}
func TestForceReadOnlyMode(t *testing.T) {
testCodegenMode(t, "mode: `force-read-only`,", "force-read-only")
}
func TestUnsupportedMode(t *testing.T) {
testCodegenModeWithError(t, "mode: `unsupported`,", "mode: \"unsupported\" is not a supported mode")
}

View file

@ -23,6 +23,7 @@ type RustAconfigLibraryProperties struct {
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
// "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}

View file

@ -72,6 +72,7 @@ var rustCodegenModeTestData = []struct {
{"mode: `production`,", "production"},
{"mode: `test`,", "test"},
{"mode: `exported`,", "exported"},
{"mode: `force-read-only`,", "force-read-only"},
}
func TestRustCodegenMode(t *testing.T) {