aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):