Chris,

I see. Seems like file ordering differs for some reason. I should not have
relied on it, anyway.
Rewrote it so file ordering is not taken into account. Does it work now?

Thank you,
Maria

вс, 15 янв. 2017 г. в 2:43, Chris Lamb <la...@debian.org>:

> Maria,
>
> Thank you so much for these :)
>
> > Added some tests for APK comparator, see attached patch.
>
> Unfortunately I'm seeing:
>
> differences = [<Difference zipinfo {} -- zipinfo {} []>, <Difference APK
> metadata -- APK metadata []>, <Difference AndroidManifest.xml --
> AndroidManifest.xml []>, <Difference original/AndroidManifest.xml --
> original/AndroidManifest.xml []>]
>
>     @skip_unless_tools_exist('apktool', 'zipinfo')
>     def test_android_manifest(differences):
> >       assert differences[1].source1 == 'AndroidManifest.xml'
> E       assert 'APK metadata' == 'AndroidManifest.xml'
> E         - APK metadata
> E         + AndroidManifest.xml
>
> Any ideas?
>
> > However, please keep in mind apktool takes a lot of time to run even on
> toy
> > examples
>
> Whilst I am not a fan of it slowing down this much, I think I'd
> prefer to see some tests in there (that we can speed up later)
> rather than none.
>
>
> Regards,
>
> --
>       ,''`.
>      : :'  :     Chris Lamb
>      `. `'`      la...@debian.org / chris-lamb.co.uk
>        `-
>
From 67e0ca7b632699f54aec27069efd4e0c547ab708 Mon Sep 17 00:00:00 2001
From: Maria Glukhova <siamez...@gmail.com>
Date: Fri, 13 Jan 2017 23:22:10 +0200
Subject: [PATCH] Add some tests for APK comarator.

---
 tests/comparators/test_apk.py         |  66 ++++++++++++++++++++++++++++++++++
 tests/data/apk_manifest_expected_diff |  11 ++++++
 tests/data/apk_zipinfo_expected_diff  |   6 ++++
 tests/data/test1.apk                  | Bin 0 -> 866 bytes
 tests/data/test2.apk                  | Bin 0 -> 864 bytes
 5 files changed, 83 insertions(+)
 create mode 100644 tests/comparators/test_apk.py
 create mode 100644 tests/data/apk_manifest_expected_diff
 create mode 100644 tests/data/apk_zipinfo_expected_diff
 create mode 100644 tests/data/test1.apk
 create mode 100644 tests/data/test2.apk

diff --git a/tests/comparators/test_apk.py b/tests/comparators/test_apk.py
new file mode 100644
index 0000000..3093027
--- /dev/null
+++ b/tests/comparators/test_apk.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2017 Maria Glukhova <siammez...@gmail.com>
+#
+# diffoscope is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# diffoscope is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
+
+import pytest
+
+from diffoscope.comparators.apk import ApkFile
+
+from utils import skip_unless_tools_exist, data, load_fixture, \
+    assert_non_existing
+
+apk1 = load_fixture(data('test1.apk'))
+apk2 = load_fixture(data('test2.apk'))
+
+def test_identification(apk1):
+    assert isinstance(apk1, ApkFile)
+
+def test_no_differences(apk1):
+    difference = apk1.compare(apk1)
+    assert difference is None
+
+@pytest.fixture
+def differences(apk1, apk2):
+    return apk1.compare(apk2).details
+
+@skip_unless_tools_exist('apktool', 'zipinfo')
+def test_compare_non_existing(monkeypatch, apk1):
+    assert_non_existing(monkeypatch, apk1)
+
+@skip_unless_tools_exist('apktool', 'zipinfo')
+def test_zipinfo(differences):
+    assert differences[0].source1 == 'zipinfo {}'
+    assert differences[0].source2 == 'zipinfo {}'
+    expected_diff = open(data('apk_zipinfo_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+@skip_unless_tools_exist('apktool', 'zipinfo')
+def test_android_manifest(differences):
+    manifest_diff = next((d for d in differences
+                          if d.source1 == 'AndroidManifest.xml'), None)
+    assert manifest_diff is not None
+    assert manifest_diff.source2 == 'AndroidManifest.xml'
+    expected_diff = open(data('apk_manifest_expected_diff')).read()
+    assert manifest_diff.unified_diff == expected_diff
+
+@skip_unless_tools_exist('apktool', 'zipinfo')
+def test_apk_metadata_source(differences):
+    metadata_diff = next((d for d in differences
+                          if d.source1 == 'APK metadata'), None)
+    assert metadata_diff is not None
+    assert metadata_diff.source2 == 'APK metadata'
diff --git a/tests/data/apk_manifest_expected_diff b/tests/data/apk_manifest_expected_diff
new file mode 100644
index 0000000..9d37a92
--- /dev/null
+++ b/tests/data/apk_manifest_expected_diff
@@ -0,0 +1,11 @@
+@@ -1,9 +1,9 @@
+ <?xml version="1.0" encoding="utf-8"?>
+-<manifest android:versionCode="1" android:versionName="1.0" package="com.any.any" platformBuildVersionCode="24" platformBuildVersionName="7.0.0"
++<manifest android:versionCode="2" android:versionName="2.0" package="com.any.any" platformBuildVersionCode="24" platformBuildVersionName="7.0.0"
+   xmlns:android="http://schemas.android.com/apk/res/android";>
+     <uses-permission android:name="android.permission.INTERNET" />
+     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+     <application>
+         <activity android:name="com.any.any.SomeActivity">
+             <intent-filter>
diff --git a/tests/data/apk_zipinfo_expected_diff b/tests/data/apk_zipinfo_expected_diff
new file mode 100644
index 0000000..d1810dc
--- /dev/null
+++ b/tests/data/apk_zipinfo_expected_diff
@@ -0,0 +1,6 @@
+@@ -1,3 +1,3 @@
+-Zip file size: 866 bytes, number of entries: 1
++Zip file size: 864 bytes, number of entries: 1
+ -rw----     2.0 fat     2096 bl defN 80-Jan-01 02:00 AndroidManifest.xml
+-1 file, 2096 bytes uncompressed, 714 bytes compressed:  65.9%
++1 file, 2096 bytes uncompressed, 712 bytes compressed:  66.0%
diff --git a/tests/data/test1.apk b/tests/data/test1.apk
new file mode 100644
index 0000000000000000000000000000000000000000..45876d61fab82fc0c492af2cf60e56a3792f820f
GIT binary patch
literal 866
zcmWIWW@Zs#;Nak3U=UDbKnB7<j$>X*QGRBMZ(?3%T555LUPW%s+z|hKAxD|o!%laj
zG@=hQi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!q_;s;VSHjGjvvg`m
ztg5qh`j4r?TWSwK%V{ce%?$6U0vfwL<HKprs?eq3reAXG&pux(WfH%kYSGU{SN+fG
zCw`GG(uu1tu4fGJX6INgC_Uu_69a<*F!cv`Gct)VAhH6o94ITG0xTILz?+o~q=*p+
L9f33_Gl&NOgqe-F

literal 0
HcmV?d00001

-- 
2.11.0

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to