[diffoscope] 02/02: Update tests to prevent FTBFS under file 5.33, although this does not solve the Berkeley DB tests (see. #897153) (Closes: #897099)

Chris Lamb chris at chris-lamb.co.uk
Sun Apr 29 07:52:34 CEST 2018


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

lamby pushed a commit to branch master
in repository diffoscope.

commit f800b207a3bde7450705f205ac37993d0666be5c
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Apr 28 22:45:47 2018 -0700

    Update tests to prevent FTBFS under file 5.33, although this does not solve the Berkeley DB tests (see. #897153) (Closes: #897099)
---
 tests/comparators/test_containers.py   | 8 +++++---
 tests/comparators/test_gzip.py         | 2 ++
 tests/comparators/test_ipk.py          | 2 ++
 tests/data/archive12.diff.txt          | 4 ++--
 tests/data/containers/magic_gzip       | 2 +-
 tests/data/gzip_metadata_expected_diff | 4 ++--
 tests/data/ipk_metadata_expected_diff  | 4 ++--
 tests/data/quine_expected_diff         | 2 +-
 tests/test_presenters.py               | 3 ++-
 tests/test_quines.py                   | 2 ++
 tests/utils/tools.py                   | 9 +++++++++
 11 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/tests/comparators/test_containers.py b/tests/comparators/test_containers.py
index 0f8ee86..bb5caa8 100644
--- a/tests/comparators/test_containers.py
+++ b/tests/comparators/test_containers.py
@@ -22,7 +22,7 @@ import pytest
 import itertools
 
 from ..utils.data import load_fixture, get_data
-from ..utils.tools import skip_unless_tools_exist
+from ..utils.tools import skip_unless_tools_exist, skip_unless_file_version_is_at_least
 
 gzip1 = load_fixture('containers/a.tar.gz')
 gzip2 = load_fixture('containers/b.tar.gz')
@@ -53,6 +53,7 @@ def expected_type_diff(ext1, ext2):
 
 # Compares same content files, but with different extensions
 @skip_unless_tools_exist('xz')
+ at skip_unless_file_version_is_at_least('5.33')
 def test_equal(set1):
     for x, y in itertools.product(TYPES, TYPES):
         diff = set1[x].compare(set1[y])
@@ -60,11 +61,12 @@ def test_equal(set1):
             assert diff is None
         else:
             differences = diff.details
-            assert differences[0].unified_diff == expected_magic_diff(x, y)
+            assert differences[0].unified_diff == expected_magic_diff(x, y), "{} {}".format(x, y)
             assert differences[1].unified_diff == expected_type_diff(x, y)
 
 # Compares different content files with different extensions
 @skip_unless_tools_exist('xz')
+ at skip_unless_file_version_is_at_least('5.33')
 def test_different(set1, set2):
     for x, y in itertools.product(TYPES, TYPES):
         expected_diff = get_data('containers/different_files_expected_diff')
@@ -72,6 +74,6 @@ def test_different(set1, set2):
         if x == y:
             assert differences[0].details[1].unified_diff == expected_diff
         else:
-            assert differences[0].unified_diff == expected_magic_diff(x, y)
+            assert differences[0].unified_diff == expected_magic_diff(x, y), "{} {}".format(x, y)
             assert differences[1].unified_diff == expected_type_diff(x, y)
             assert differences[2].details[1].unified_diff == expected_diff
diff --git a/tests/comparators/test_gzip.py b/tests/comparators/test_gzip.py
index 9ce904e..dab006b 100644
--- a/tests/comparators/test_gzip.py
+++ b/tests/comparators/test_gzip.py
@@ -27,6 +27,7 @@ from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize, is_direct_instance
 
 from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_file_version_is_at_least
 
 
 gzip1 = load_fixture('test1.gz')
@@ -56,6 +57,7 @@ def differences(gzip1, gzip2):
     return gzip1.compare(gzip2).details
 
 
+ at skip_unless_file_version_is_at_least('5.33')
 def test_metadata(differences):
     assert differences[0].source1.startswith('filetype')
     assert differences[0].source2.startswith('filetype')
diff --git a/tests/comparators/test_ipk.py b/tests/comparators/test_ipk.py
index f1b430b..8f414f4 100644
--- a/tests/comparators/test_ipk.py
+++ b/tests/comparators/test_ipk.py
@@ -24,6 +24,7 @@ from diffoscope.comparators.ipk import IpkFile
 from diffoscope.comparators.missing_file import MissingFile
 
 from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_file_version_is_at_least
 
 
 ipk1 = load_fixture('base-files_157-r45695_ar71xx.ipk')
@@ -44,6 +45,7 @@ def differences(ipk1, ipk2):
     return ipk1.compare(ipk2).details
 
 
+ at skip_unless_file_version_is_at_least('5.33')
 def test_metadata(differences):
     assert differences[0].source1.startswith('filetype')
     expected_diff = get_data('ipk_metadata_expected_diff')
diff --git a/tests/data/archive12.diff.txt b/tests/data/archive12.diff.txt
index 3b861ab..24f2766 100644
--- a/tests/data/archive12.diff.txt
+++ b/tests/data/archive12.diff.txt
@@ -7,8 +7,8 @@
 ├── compressed.gz
 │ ├── filetype from file(1)
 │ │ @@ -1 +1 @@
-│ │ -gzip compressed data, max compression, from Unix
-│ │ +gzip compressed data, was "compressed", last modified: Sun Mar 19 22:27:42 2017, max compression, from Unix
+│ │ -gzip compressed data, max compression, from Unix, original size 2
+│ │ +gzip compressed data, was "compressed", last modified: Sun Mar 19 22:27:42 2017, max compression, from Unix, original size 2
 │ ├── compressed
 │ │ @@ -1 +1 @@
 │ │ -a
diff --git a/tests/data/containers/magic_gzip b/tests/data/containers/magic_gzip
index 8a2d8a2..48afccb 100644
--- a/tests/data/containers/magic_gzip
+++ b/tests/data/containers/magic_gzip
@@ -1 +1 @@
-gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix
+gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix, original size 10240
diff --git a/tests/data/gzip_metadata_expected_diff b/tests/data/gzip_metadata_expected_diff
index cee768e..2d79c23 100644
--- a/tests/data/gzip_metadata_expected_diff
+++ b/tests/data/gzip_metadata_expected_diff
@@ -1,3 +1,3 @@
 @@ -1 +1 @@
--gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, max compression, from Unix
-+gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, from Unix
+-gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, max compression, from Unix, original size 446
++gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, from Unix, original size 671
diff --git a/tests/data/ipk_metadata_expected_diff b/tests/data/ipk_metadata_expected_diff
index 9296ad7..18af9f4 100644
--- a/tests/data/ipk_metadata_expected_diff
+++ b/tests/data/ipk_metadata_expected_diff
@@ -1,3 +1,3 @@
 @@ -1 +1 @@
--gzip compressed data, last modified: Mon May 18 23:26:52 2015, from Unix
-+gzip compressed data, last modified: Mon Jun  8 17:31:21 2015, from Unix
+-gzip compressed data, last modified: Mon May 18 23:26:52 2015, from Unix, original size 61440
++gzip compressed data, last modified: Mon Jun  8 17:31:21 2015, from Unix, original size 61440
diff --git a/tests/data/quine_expected_diff b/tests/data/quine_expected_diff
index d687ad0..54c4f7a 100644
--- a/tests/data/quine_expected_diff
+++ b/tests/data/quine_expected_diff
@@ -1,3 +1,3 @@
 @@ -1 +1 @@
--gzip compressed data, was "recursive", from FAT filesystem (MS-DOS, OS/2, NT)
+-gzip compressed data, was "recursive", from FAT filesystem (MS-DOS, OS/2, NT), original size 250
 +Zip archive data, at least v2.0 to extract
diff --git a/tests/test_presenters.py b/tests/test_presenters.py
index ff751fc..e38c1b0 100644
--- a/tests/test_presenters.py
+++ b/tests/test_presenters.py
@@ -28,7 +28,7 @@ from diffoscope.presenters.json import JSONPresenter
 
 from .utils import diff_expand
 from .utils.data import cwd_data, data, get_data
-from .utils.tools import skip_unless_tools_exist
+from .utils.tools import skip_unless_tools_exist, skip_unless_file_version_is_at_least
 
 re_html = re.compile(r'.*<body(?P<body>.*)<div class="footer">', re.MULTILINE | re.DOTALL)
 
@@ -75,6 +75,7 @@ def test_text_option_is_default(capsys):
     assert out == get_data('output.txt')
 
 
+ at skip_unless_file_version_is_at_least('5.33')
 def test_text_proper_indentation(capsys):
     out = run(capsys, pair=('archive1.tar', 'archive2.tar'))
 
diff --git a/tests/test_quines.py b/tests/test_quines.py
index 14e00c3..66705b8 100644
--- a/tests/test_quines.py
+++ b/tests/test_quines.py
@@ -24,6 +24,7 @@ from diffoscope.comparators.zip import ZipFile
 from diffoscope.comparators.gzip import GzipFile
 
 from .utils.data import load_fixture, get_data
+from .utils.tools import skip_unless_file_version_is_at_least
 
 quine1 = load_fixture('quine.gz')
 quine2 = load_fixture('quine.zip')
@@ -51,6 +52,7 @@ def differences(quine1, quine2):
     return quine1.compare(quine2).details
 
 
+ at skip_unless_file_version_is_at_least('5.33')
 def test_difference(differences):
     expected_diff = get_data('quine_expected_diff')
     assert differences[0].unified_diff == expected_diff
diff --git a/tests/utils/tools.py b/tests/utils/tools.py
index 16e1b92..1482962 100644
--- a/tests/utils/tools.py
+++ b/tests/utils/tools.py
@@ -26,6 +26,11 @@ import subprocess
 from distutils.spawn import find_executable
 from distutils.version import LooseVersion
 
+def file_version():
+    return subprocess.check_output(
+        ('file', '-v'),
+    ).decode('utf-8').splitlines()[0].split('-')[-1]
+
 
 def tools_missing(*required):
     return not required or any(find_executable(x) is None for x in required)
@@ -119,3 +124,7 @@ def skip_unless_module_exists(name):
         module_is_not_importable(name),
         reason="requires {} module".format(name),
     )
+
+
+def skip_unless_file_version_is_at_least(version):
+    return skip_unless_tool_is_at_least('file', file_version, version)

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


More information about the rb-commits mailing list