Skip to content
Commits on Source (3)
......@@ -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
......
......@@ -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):
......
......@@ -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
......@@ -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')
......