Commit 32f9324e authored by Jérémy Bobbio's avatar Jérémy Bobbio

Add tests for .class comparator

parent edf62f25
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# debbindiff: highlight differences between two builds of Debian packages
#
# Copyright © 2015 Jérémy Bobbio <lunar@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
@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
@@ -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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment