[Reproducible-commits] [debbindiff] 05/07: Add tests for .class comparator
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Jun 24 11:52:25 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository debbindiff.
commit 32f9324e76eb709bae59269b57b8f93919da728f
Author: Jérémy Bobbio <lunar at debian.org>
Date: Wed Jun 24 11:39:37 2015 +0000
Add tests for .class comparator
---
tests/comparators/test_java.py | 39 +++++++++++++++++++++++++++++++++++++++
tests/data/Test1.class | Bin 0 -> 255 bytes
tests/data/Test2.class | Bin 0 -> 254 bytes
tests/data/class_expected_diff | 29 +++++++++++++++++++++++++++++
4 files changed, 68 insertions(+)
diff --git a/tests/comparators/test_java.py b/tests/comparators/test_java.py
new file mode 100644
index 0000000..c95f6b4
--- /dev/null
+++ b/tests/comparators/test_java.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff 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.
+#
+# debbindiff 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 debbindiff. If not, see <http://www.gnu.org/licenses/>.
+
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.java import compare_class_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/Test1.class')
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/Test2.class')
+
+def test_no_differences():
+ differences = compare_class_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+ assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+ return compare_class_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_diff(differences):
+ expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/class_expected_diff')).read()
+ assert differences[0].unified_diff == expected_diff
diff --git a/tests/data/Test1.class b/tests/data/Test1.class
new file mode 100644
index 0000000..d97b21f
Binary files /dev/null and b/tests/data/Test1.class differ
diff --git a/tests/data/Test2.class b/tests/data/Test2.class
new file mode 100644
index 0000000..a83088e
Binary files /dev/null and b/tests/data/Test2.class differ
diff --git a/tests/data/class_expected_diff b/tests/data/class_expected_diff
new file mode 100644
index 0000000..0d75268
--- /dev/null
+++ b/tests/data/class_expected_diff
@@ -0,0 +1,29 @@
+@@ -1,10 +1,10 @@
+-Classfile /home/lunar/Documents/Debian/reproducible-builds/debbindiff/git/tests/data/Test1.class
+- Last modified 24 juin 2015; size 255 bytes
+- MD5 checksum b21793a1a687017fda223dba41bfcbf2
++Classfile /home/lunar/Documents/Debian/reproducible-builds/debbindiff/git/tests/data/Test2.class
++ Last modified 24 juin 2015; size 254 bytes
++ MD5 checksum 01a9e334bb654f7cde2e4cae29f92a99
+ Compiled from "Test.java"
+ class Test
+ SourceFile: "Test.java"
+ minor version: 0
+ major version: 50
+ flags: ACC_SUPER
+ Constant pool:
+@@ -39,12 +39,12 @@
+ public static int main(java.lang.String[]);
+ Signature: ([Ljava/lang/String;)I
+ flags: ACC_PUBLIC, ACC_STATIC
+ LineNumberTable:
+ line 3: 0
+ Code:
+ stack=1, locals=1, args_size=1
+- 0: bipush 42
+- 2: ireturn
++ 0: iconst_m1
++ 1: ireturn
+ LineNumberTable:
+ line 3: 0
+ }
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git
More information about the Reproducible-commits
mailing list