diff options
author | 2020-06-30 11:41:23 +0900 | |
---|---|---|
committer | 2020-06-30 18:44:51 +0900 | |
commit | 24d9cad56383fdc6c2c61526c44d2ffd726b8e7b (patch) | |
tree | 3918643a2507097c0c1444be601516369bdfa8fe | |
parent | 0b4fccb66dc33e6cc28c0e638ee834fbf8f53c50 (diff) |
Handle the case when non-optional props have the same value
foo=true
foo=true
foo?=false
Consider the above case: Then the duplication of foo is allowed because
they have the same value (true). However, there was a bug that the
optional assirgnment foo?=false is left unmodified.
This fixes the bug by commenting such optional assignments.
Exempt-From-Owner-Approval: fixes a broken build
Bug: 117892318
Bug: 158735147
Test: atest test_post_process_props
Test: m out/target/product/vsoc_x86/vendor/build.prop for cf_x86_auto
Exempt-From-Owner-Approval: cherry-pick from master
Merged-In: Iba9b61d9779d93e86d9bead2286f945f8d51ab1d
(cherry picked from commit 9a32636759822bfb04071c9e28b101e9714ce305)
Change-Id: Iba9b61d9779d93e86d9bead2286f945f8d51ab1d
-rwxr-xr-x | tools/post_process_props.py | 2 | ||||
-rw-r--r-- | tools/test_post_process_props.py | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/tools/post_process_props.py b/tools/post_process_props.py index 78a23fb72d..d8c9cb157f 100755 --- a/tools/post_process_props.py +++ b/tools/post_process_props.py @@ -88,6 +88,8 @@ def override_optional_props(prop_list, allow_dup=False): if len(overriding_props) > 1: # duplicated props are allowed when the all have the same value if all(overriding_props[0].value == p.value for p in overriding_props): + for p in optional_props: + p.delete("overridden by %s" % str(overriding_props[0])) continue # or if dup is explicitly allowed for compat reason if allow_dup: diff --git a/tools/test_post_process_props.py b/tools/test_post_process_props.py index 44fe957d74..12d52e566d 100644 --- a/tools/test_post_process_props.py +++ b/tools/test_post_process_props.py @@ -221,11 +221,17 @@ class PropListTestcase(unittest.TestCase): stderr_redirect = io.StringIO() with contextlib.redirect_stderr(stderr_redirect): props = PropList("hello") + optional_prop = props.get_props("foo")[2] # the last foo?=false one # we have duplicated foo=true and foo=true, but that's allowed # since they have the same value self.assertTrue(override_optional_props(props)) + # foo?=false should be commented out + self.assertEqual("# Removed by post_process_props.py because " + + "overridden by foo=true\n#foo?=false", + str(optional_prop)) + def test_allowDuplicates(self): content = """ # comment |