[Git][reproducible-builds/diffoscope][master] 3 commits: Tidy some unnecessary boolean logic in the ISO9660 tests.

Chris Lamb gitlab at salsa.debian.org
Sat Dec 7 14:41:31 UTC 2019



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
341b98af by Chris Lamb at 2019-12-07T14:40:02Z
Tidy some unnecessary boolean logic in the ISO9660 tests.

- - - - -
8833cc8a by Chris Lamb at 2019-12-07T14:40:05Z
Don't return a "filter" iterable from Container.compare; return a non-lazy list instead.

- - - - -
4690b572 by Chris Lamb at 2019-12-07T14:40:41Z
Include the  libarchive file listing for ISO images to ensure that timestamps (and not just dates) are visible in any difference. (Closes: reproducible-builds/diffoscope#81)

- - - - -


4 changed files:

- diffoscope/comparators/iso9660.py
- diffoscope/comparators/utils/container.py
- diffoscope/comparators/utils/libarchive.py
- tests/comparators/test_iso9660.py


Changes:

=====================================
diffoscope/comparators/iso9660.py
=====================================
@@ -25,7 +25,7 @@ from diffoscope.difference import Difference
 
 from .utils.file import File
 from .utils.command import Command
-from .utils.libarchive import LibarchiveContainer
+from .utils.libarchive import LibarchiveContainerWithFilelist
 
 
 @tool_required('isoinfo')
@@ -76,7 +76,7 @@ class ISO9660Listing(Command):
 
 class Iso9660File(File):
     DESCRIPTION = "ISO 9660 CD images"
-    CONTAINER_CLASS = LibarchiveContainer
+    CONTAINER_CLASS = LibarchiveContainerWithFilelist
     FILE_TYPE_RE = re.compile(r'\bISO 9660\b')
 
     @classmethod


=====================================
diffoscope/comparators/utils/container.py
=====================================
@@ -200,9 +200,9 @@ class Container(metaclass=abc.ABCMeta):
                 difference.add_comment(comment)
             return difference
 
-        return filter(
-            None, itertools.starmap(compare_pair, self.comparisons(other))
-        )
+        differences = itertools.starmap(compare_pair, self.comparisons(other))
+
+        return [x for x in differences if x]
 
 
 class MissingContainer(Container):


=====================================
diffoscope/comparators/utils/libarchive.py
=====================================
@@ -29,6 +29,7 @@ from diffoscope.exc import ContainerExtractionError
 from diffoscope.config import Config
 from diffoscope.excludes import any_excluded
 from diffoscope.tempfiles import get_temporary_directory
+from diffoscope.difference import Difference
 
 from ..device import Device
 from ..symlink import Symlink
@@ -340,3 +341,24 @@ class LibarchiveContainer(Archive):
             )
 
         return filter(hide_trivial_dirs, super().comparisons(other))
+
+
+class LibarchiveContainerWithFilelist(LibarchiveContainer):
+    def compare(self, other, **kwargs):
+        differences = []
+
+        # Always include the filelist
+        if other.source:
+            differences = [
+                Difference.from_text_readers(
+                    list_libarchive(self.source.path),
+                    list_libarchive(other.source.path),
+                    self.source.path,
+                    other.source.path,
+                    source="file list",
+                )
+            ]
+
+        differences.extend(super().compare(other, **kwargs))
+
+        return differences


=====================================
tests/comparators/test_iso9660.py
=====================================
@@ -33,10 +33,7 @@ iso2 = load_fixture('test2.iso')
 
 
 def is_cdrtools():
-    if b"Schilling" in subprocess.check_output(['isoinfo', '--version']):
-        return True
-    else:
-        return False
+    return b"Schilling" in subprocess.check_output(['isoinfo', '--version'])
 
 
 def test_identification(iso1):
@@ -73,17 +70,17 @@ def test_iso9660_rockridge(differences):
 
 @skip_unless_tools_exist('isoinfo')
 def test_symlink(differences):
-    assert differences[3].comment == 'symlink'
+    assert differences[4].comment == 'symlink'
     expected_diff = get_data('symlink_expected_diff')
-    assert differences[3].unified_diff == expected_diff
+    assert differences[4].unified_diff == expected_diff
 
 
 @skip_unless_tools_exist('isoinfo')
 def test_compressed_files(differences):
-    assert differences[2].source1 == 'text'
-    assert differences[2].source2 == 'text'
+    assert differences[3].source1 == 'text'
+    assert differences[3].source2 == 'text'
     expected_diff = get_data('text_ascii_expected_diff')
-    assert differences[2].unified_diff == expected_diff
+    assert differences[3].unified_diff == expected_diff
 
 
 @skip_unless_tools_exist('isoinfo')



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/f4f26dbc9a392220b2b9f5f287bee48badaf4b3b...4690b572863c24cccb33ff6fbf27606481e8131a

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/f4f26dbc9a392220b2b9f5f287bee48badaf4b3b...4690b572863c24cccb33ff6fbf27606481e8131a
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20191207/14a3ddae/attachment.htm>


More information about the rb-commits mailing list