diff options
author | Colin Cross <ccross@android.com> | 2017-07-28 17:51:37 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-08-01 15:12:12 -0700 |
commit | 05b3607c378dc6557d64ae6cecee3f7fe1b22b13 (patch) | |
tree | c3f9c4383f7d31fdb03778283380e21893bb31bd /unpack_test.go | |
parent | 5fe225f5f976f191e0f9fd543e7b5b74ad388bd9 (diff) | |
download | android_build_blueprint-05b3607c378dc6557d64ae6cecee3f7fe1b22b13.tar.gz android_build_blueprint-05b3607c378dc6557d64ae6cecee3f7fe1b22b13.tar.bz2 android_build_blueprint-05b3607c378dc6557d64ae6cecee3f7fe1b22b13.zip |
Replace unpack's replace semantics with append
Blueprint was using "replace" semantics when unpacking properties
into property structs, meaning if a module factory pre-set property
values they would be overwritten by whatever was in the Blueprint
file. This is different than what would happen if the same property
was updated using the Append*Properties functions in proptools, which
would use "append" semantics, which append strings and lists,
logically ORs booleans and replaces pointers to strings and booleans.
Replace unpack's semantics with append semantics for consistency.
Any previous users of pre-set properties can move to using a pointer
to a string or boolean if they want the old behavior.
Test: unpack_test.go
Test: extend_test.go
Change-Id: I02eebe80916e578938142f8e76889bd985223afc
Diffstat (limited to 'unpack_test.go')
-rw-r--r-- | unpack_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/unpack_test.go b/unpack_test.go index f470356..b65fa3f 100644 --- a/unpack_test.go +++ b/unpack_test.go @@ -498,6 +498,49 @@ var validUnpackTestCases = []struct { }, }, }, + + // Factory set properties + { + input: ` + m { + string: "abc", + string_ptr: "abc", + bool: false, + bool_ptr: false, + list: ["a", "b", "c"], + } + `, + output: []interface{}{ + struct { + String string + String_ptr *string + Bool bool + Bool_ptr *bool + List []string + }{ + String: "012abc", + String_ptr: proptools.StringPtr("abc"), + Bool: true, + Bool_ptr: proptools.BoolPtr(false), + List: []string{"0", "1", "2", "a", "b", "c"}, + }, + }, + empty: []interface{}{ + &struct { + String string + String_ptr *string + Bool bool + Bool_ptr *bool + List []string + }{ + String: "012", + String_ptr: proptools.StringPtr("012"), + Bool: true, + Bool_ptr: proptools.BoolPtr(true), + List: []string{"0", "1", "2"}, + }, + }, + }, } type EmbeddedStruct struct{ Name string } |