[diffoscope] 02/02: Indicate the AndroidManifest.xml type.

Maria Glukhova siamezzze-guest at moszumanska.debian.org
Wed Mar 8 00:03:16 CET 2017


This is an automated email from the git hooks/post-receive script.

siamezzze-guest pushed a commit to branch experimental
in repository diffoscope.

commit c1bf3cc783d02acad31072afe7e6252deb9d7f2c
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Mon Mar 6 06:03:27 2017 +0200

    Indicate the AndroidManifest.xml type.
    
    Show the decoded/undecoded type of AndroidManifest.xml file.
    
    Closes: #850758
---
 diffoscope/comparators/apk.py           |  8 ++++++--
 diffoscope/comparators/utils/compare.py |  4 +++-
 tests/comparators/test_apk.py           | 14 ++++++++++----
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/diffoscope/comparators/apk.py b/diffoscope/comparators/apk.py
index fc0b5f1..cd3ef21 100644
--- a/diffoscope/comparators/apk.py
+++ b/diffoscope/comparators/apk.py
@@ -116,8 +116,10 @@ class ApkContainer(Archive):
         comment = None
         diff_manifests = None
         if my_android_manifest and other_android_manifest:
+            source = 'AndroidManifest.xml (decoded)'
             diff_manifests = compare_files(my_android_manifest,
-                                           other_android_manifest)
+                                           other_android_manifest,
+                                           source=source)
             if diff_manifests is None:
                 comment = 'No difference found for decoded AndroidManifest.xml'
         else:
@@ -126,8 +128,10 @@ class ApkContainer(Archive):
         if diff_manifests:
             return diff_manifests
 
+        source = 'AndroidManifest.xml (original / undecoded)'
         diff_manifests = compare_files(self.get_original_android_manifest(),
-                                       other.get_original_android_manifest())
+                                       other.get_original_android_manifest(),
+                                       source=source)
         if diff_manifests is not None:
             diff_manifests.add_comment(comment)
         return diff_manifests
diff --git a/diffoscope/comparators/utils/compare.py b/diffoscope/comparators/utils/compare.py
index b069a0e..4259409 100644
--- a/diffoscope/comparators/utils/compare.py
+++ b/diffoscope/comparators/utils/compare.py
@@ -107,9 +107,11 @@ def bail_if_non_existing(*paths):
 
 def compare_binary_files(file1, file2, source=None):
     try:
+        if source is None:
+            source = [file1.name, file2.name]
         return Difference.from_command(
             Xxd, file1.path, file2.path,
-            source=[file1.name, file2.name], has_internal_linenos=True)
+            source=source, has_internal_linenos=True)
     except RequiredToolNotFound:
         hexdump1 = hexdump_fallback(file1.path)
         hexdump2 = hexdump_fallback(file2.path)
diff --git a/tests/comparators/test_apk.py b/tests/comparators/test_apk.py
index 262cf47..a05dc65 100644
--- a/tests/comparators/test_apk.py
+++ b/tests/comparators/test_apk.py
@@ -57,8 +57,8 @@ def test_zipinfo(differences):
 
 @skip_unless_tools_exist('apktool', 'zipinfo')
 def test_android_manifest(differences):
-    assert differences[1].source1 == 'AndroidManifest.xml'
-    assert differences[1].source2 == 'AndroidManifest.xml'
+    assert differences[1].source1 == 'AndroidManifest.xml (decoded)'
+    assert differences[1].source2 == 'AndroidManifest.xml (decoded)'
     expected_diff = get_data('apk_manifest_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
@@ -73,10 +73,16 @@ def test_skip_undecoded_android_manifest(differences):
                    for difference in differences)
     assert not any(difference.source2 == 'original/AndroidManifest.xml'
                    for difference in differences)
+    undecoded_manifest = 'AndroidManifest.xml (original / undecoded)'
+    assert not any(difference.source1 == undecoded_manifest
+                   for difference in differences)
+    assert not any(difference.source2 == undecoded_manifest
+                   for difference in differences)
 
 @skip_unless_tools_exist('apktool', 'zipinfo')
 def test_no_android_manifest(differences2):
-    assert differences2[1].source1 == 'original/AndroidManifest.xml'
-    assert differences2[1].source2 == '/dev/null'
+    undecoded_manifest = 'AndroidManifest.xml (original / undecoded)'
+    assert differences2[1].source1 == undecoded_manifest
+    assert differences2[1].source2 == undecoded_manifest
     assert differences2[1].comment == 'No decoded AndroidManifest.xml ' \
                                       'found for one of the APK files.'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list