aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-23 12:29:41 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-23 12:29:41 +0000
commitd5272e50ad44ce864b73c830a32c0a0f0613b898 (patch)
treeefa708629291f076b5a35541ffe62f865d062a29
parent898bd2c110ebd3b1b4b02fe8cbfad43d3e3d3400 (diff)
parenta43439b27fac19e1384d643eba94c66ece21ebc7 (diff)
downloadplatform-compat-aml_med_331511000.tar.gz
Snap for 8863718 from a43439b27fac19e1384d643eba94c66ece21ebc7 to mainline-media-releaseaml_med_331511000aml_med_331410000aml_med_331318000aml_med_331115000aml_med_331012020
Change-Id: I2673dc1eae60dbe2c38c9e41f66108800d401a61
-rw-r--r--build/Android.bp18
-rw-r--r--build/process-compat-config-test.py26
-rwxr-xr-xbuild/process_compat_config.py1
3 files changed, 43 insertions, 2 deletions
diff --git a/build/Android.bp b/build/Android.bp
index 445718e..29131b6 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -22,6 +22,15 @@ python_binary_host {
name: "process-compat-config",
main: "process_compat_config.py",
srcs: ["process_compat_config.py"],
+ version: {
+ py2: {
+ enabled: false,
+ },
+ py3: {
+ enabled: true,
+ embedded_launcher: true,
+ },
+ },
}
python_test_host {
@@ -31,6 +40,15 @@ python_test_host {
"process_compat_config.py",
"process-compat-config-test.py",
],
+ version: {
+ py2: {
+ enabled: false,
+ },
+ py3: {
+ enabled: true,
+ embedded_launcher: true,
+ },
+ },
test_options: {
unit_test: true,
},
diff --git a/build/process-compat-config-test.py b/build/process-compat-config-test.py
index c7b4ac8..fc0f04a 100644
--- a/build/process-compat-config-test.py
+++ b/build/process-compat-config-test.py
@@ -36,9 +36,31 @@ class ProcessCompatConfigTest(unittest.TestCase):
self.merger.write_errors_to = self.stderr
self.xml = io.BytesIO()
+ def remove_white_space_text_nodes(self, node):
+ remove = []
+ # Find any child nodes that are just white space, and add them to a list
+ # to remove. Do not remove the child while iterating as that prevents
+ # the following node from being seen.
+ for child in node.childNodes:
+ if child.nodeType == node.ELEMENT_NODE:
+ self.remove_white_space_text_nodes(child)
+ elif child.nodeType == node.TEXT_NODE:
+ if str.isspace(child.data):
+ remove.append(child)
+ # Remove any child nodes that were just white space.
+ for child in remove:
+ node.removeChild(child)
+ child.unlink()
+
+ def parse_xml(self, text):
+ node = xml.dom.minidom.parseString(text)
+ # Remove any white space text nodes as they are irrelevant.
+ self.remove_white_space_text_nodes(node)
+ return node.toprettyxml()
+
def assert_same_xml(self, got, expected):
- got = xml.dom.minidom.parseString(got).toprettyxml()
- expected = xml.dom.minidom.parseString(expected).toprettyxml()
+ got = self.parse_xml(got)
+ expected = self.parse_xml(expected)
diffs = [diff for diff in difflib.ndiff(got.split('\n'), expected.split('\n')) if not diff.startswith(" ")]
self.assertEqual("", "\n".join(diffs), msg="Got unexpected diffs in XML")
diff --git a/build/process_compat_config.py b/build/process_compat_config.py
index f884092..e17b745 100755
--- a/build/process_compat_config.py
+++ b/build/process_compat_config.py
@@ -91,6 +91,7 @@ class ConfigMerger(object):
def write(self, filename):
self._check_error()
+ ET.indent(self.tree)
self.tree.write(filename, encoding='utf-8', xml_declaration=True)
def write_device_config(self, filename):