[diffoscope] 01/01: Skip the java tests if javap is older than 1.8

Mattia Rizzolo mattia at debian.org
Fri Sep 30 00:45:20 CEST 2016


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

mattia pushed a commit to branch master
in repository diffoscope.

commit 02a3b04f27de1c675e81f03c57a0bdeb22759586
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Fri Sep 30 01:15:43 2016 +0300

    Skip the java tests if javap is older than 1.8
    
    This fixes test_java and test_dex failing in jessie-backports.
    These tests were failing because of slight behavior change between "javap"
    tools versions.  The change was purely cosmetic, so no changes are made to
    comparator itself, just the relevant tests are now skipped if "javap" is not
    new enough.
    
    See #838984 for more background.
    
    Signed-off-by: Mattia Rizzolo <mattia at debian.org>
---
 tests/comparators/test_dex.py  |  4 +++-
 tests/comparators/test_java.py | 12 ++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tests/comparators/test_dex.py b/tests/comparators/test_dex.py
index 4087134..deac9e0 100644
--- a/tests/comparators/test_dex.py
+++ b/tests/comparators/test_dex.py
@@ -23,7 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.dex import DexFile
 from diffoscope.comparators.binary import NonExistingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_older_than
+from test_java import javap_version
 
 
 dex1 = load_fixture(data('test1.dex'))
@@ -41,6 +42,7 @@ def differences(dex1, dex2):
     return dex1.compare(dex2).details
 
 @skip_unless_tools_exist('enjarify', 'zipinfo', 'javap')
+ at skip_unless_tool_is_older_than('javap', javap_version, '1.8')
 def test_differences(differences):
     assert differences[0].source1 == 'test1.jar'
     assert differences[0].source2 == 'test2.jar'
diff --git a/tests/comparators/test_java.py b/tests/comparators/test_java.py
index 22914a7..db5abce 100644
--- a/tests/comparators/test_java.py
+++ b/tests/comparators/test_java.py
@@ -18,16 +18,24 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import pytest
+import subprocess
 
 from diffoscope.config import Config
 from diffoscope.comparators.java import ClassFile
 from diffoscope.comparators.binary import  NonExistingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_older_than
 
 class1 = load_fixture(data('Test1.class'))
 class2 = load_fixture(data('Test2.class'))
 
+def javap_version():
+    try:
+        out = subprocess.check_output(['javap', '-version'])
+    except subprocess.CalledProcessError as e:
+        out = e.output
+    return out.decode('UTF-8').strip()
+
 def test_identification(class1):
     assert isinstance(class1, ClassFile)
 
@@ -39,7 +47,7 @@ def test_no_differences(class1):
 def differences(class1, class2):
     return class1.compare(class2).details
 
- at skip_unless_tools_exist('javap')
+ at skip_unless_tool_is_older_than('javap', javap_version, '1.8')
 def test_diff(differences):
     expected_diff = open(data('class_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff

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


More information about the diffoscope mailing list