[Reproducible-commits] [diffoscope] 08/17: XXX nomeata

Jérémy Bobbio lunar at moszumanska.debian.org
Tue Dec 8 18:15:20 UTC 2015


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

lunar pushed a commit to branch pu/parallel2
in repository diffoscope.

commit 9a0dd0997b243f78bf479ec89e654a30322f1093
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Tue Dec 8 16:51:14 2015 +0100

    XXX nomeata
---
 diffoscope/__main__.py           |  1 +
 diffoscope/comparators/binary.py |  6 ++++++
 diffoscope/comparators/tar.py    |  2 +-
 diffoscope/comparators/utils.py  |  3 ++-
 diffoscope/difference.py         | 16 ++++++++++++++--
 tests/comparators/test_bzip2.py  |  8 ++++----
 tests/comparators/test_cbfs.py   |  6 +++---
 tests/comparators/test_cpio.py   |  6 +++---
 tests/comparators/test_deb.py    | 12 ++++++------
 tests/comparators/test_debian.py | 15 ++++++++++-----
 10 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/diffoscope/__main__.py b/diffoscope/__main__.py
index 40f1ef7..5548788 100644
--- a/diffoscope/__main__.py
+++ b/diffoscope/__main__.py
@@ -125,6 +125,7 @@ def run_diffoscope(parsed_args):
     set_locale()
     difference = diffoscope.comparators.compare_root_paths(
         parsed_args.file1, parsed_args.file2)
+    difference.finish_threads()
     Config.general.executor.shutdown(wait=True)
     if difference:
         if parsed_args.html_output:
diff --git a/diffoscope/comparators/binary.py b/diffoscope/comparators/binary.py
index bc9ef03..bcf4d4c 100644
--- a/diffoscope/comparators/binary.py
+++ b/diffoscope/comparators/binary.py
@@ -209,6 +209,12 @@ class File(object, metaclass=ABCMeta):
             return difference
         return self.compare_bytes(other, source)
 
+    def synchronized_compare(self, other):
+        difference = self.compare(other)
+        if difference is not None:
+            difference.finish_threads()
+        return difference
+
 
 class FilesystemFile(File):
     def __init__(self, path):
diff --git a/diffoscope/comparators/tar.py b/diffoscope/comparators/tar.py
index 0739817..f3ba51a 100644
--- a/diffoscope/comparators/tar.py
+++ b/diffoscope/comparators/tar.py
@@ -33,7 +33,7 @@ class TarListing(Command):
 
 
 class TarFile(File):
-    CONTAINER_CLASS = TarContainer
+    CONTAINER_CLASS = LibarchiveContainer
     RE_FILE_TYPE = re.compile(r'\btar archive\b')
 
     @staticmethod
diff --git a/diffoscope/comparators/utils.py b/diffoscope/comparators/utils.py
index dbe9d56..c6f43a7 100644
--- a/diffoscope/comparators/utils.py
+++ b/diffoscope/comparators/utils.py
@@ -209,7 +209,7 @@ class Container(object, metaclass=ABCMeta):
                 yield NonExistingFile('/dev/null', other_file), other_file, NO_NOTIFICATION
 
     def compare(self, other, source=None):
-        return starmap(diffoscope.comparators.compare_files_with_notification, self.comparisons(other))
+        return [Config.general.executor.submit(diffoscope.comparators.compare_files_with_notification, *args) for args in self.comparisons(other)]
 
 
 class ArchiveMember(File):
@@ -240,6 +240,7 @@ class ArchiveMember(File):
         if self._path is not None:
             self._path = None
         if self._temp_dir is not None:
+            logger.debug('cleanup %s', self._temp_dir)
             self._temp_dir.cleanup()
             self._temp_dir = None
         super().cleanup()
diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 31af5c8..f47d57b 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -179,6 +179,7 @@ class ExThread(Thread):
         else:
             raise ex
 
+import time
 
 def feed(feeder, f, end_nl_q):
     # work-around unified diff limitation: if there's no newlines in both
@@ -355,6 +356,17 @@ class Difference(object):
         d.add_details(details)
         return d
 
+    def finish_threads(self):
+        finished_details = []
+        for detail in self._details:
+            if isinstance(detail, Future):
+                detail = detail.result()
+            if not detail:
+                continue
+            detail.finish_threads()
+            finished_details.append(detail)
+        self._details = finished_details
+
     @property
     def notification(self):
         return '\n'.join(self._notifications)
@@ -392,8 +404,8 @@ class Difference(object):
 
     @property
     def unified_diff(self):
-        if isinstance(self._unified_diff, Future):
-            self._unified_diff = self._unified_diff.result()
+        #if isinstance(self._unified_diff, Future):
+        #    self._unified_diff = self._unified_diff.result()
         return self._unified_diff
 
     @unified_diff.setter
diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
index 946b444..06c0b2c 100644
--- a/tests/comparators/test_bzip2.py
+++ b/tests/comparators/test_bzip2.py
@@ -43,12 +43,12 @@ def test_identification(bzip1):
     assert isinstance(bzip1, Bzip2File)
 
 def test_no_differences(bzip1):
-    difference = bzip1.compare(bzip1)
+    difference = bzip1.synchronized_compare(bzip1)
     assert not difference
 
 @pytest.fixture
 def differences(bzip1, bzip2):
-    return bzip1.compare(bzip2).details
+    return bzip1.synchronized_compare(bzip2).details
 
 @pytest.mark.skipif(tool_missing('bzip2'), reason='missing bzip2')
 def test_content_source(differences):
@@ -63,7 +63,7 @@ def test_content_source_without_extension(tmpdir):
     shutil.copy(TEST_FILE2_PATH, path2)
     bzip1 = specialize(FilesystemFile(path1))
     bzip2 = specialize(FilesystemFile(path2))
-    differences = bzip1.compare(bzip2).details
+    differences = bzip1.synchronized_compare(bzip2).details
     assert differences[0].source1 == 'test1-content'
     assert differences[0].source2 == 'test2-content'
 
@@ -75,5 +75,5 @@ def test_content_diff(differences):
 @pytest.mark.skipif(tool_missing('bzip2'), reason='missing bzip2')
 def test_compare_non_existing(monkeypatch, bzip1):
     monkeypatch.setattr(Config, 'new_file', True)
-    difference = bzip1.compare(NonExistingFile('/nonexisting', bzip1))
+    difference = bzip1.synchronized_compare(NonExistingFile('/nonexisting', bzip1))
     assert difference.source2 == '/nonexisting'
diff --git a/tests/comparators/test_cbfs.py b/tests/comparators/test_cbfs.py
index f9b8646..b87fee4 100644
--- a/tests/comparators/test_cbfs.py
+++ b/tests/comparators/test_cbfs.py
@@ -64,12 +64,12 @@ def test_identification_without_offset(rom2):
 
 @pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
 def test_no_differences(rom1):
-    difference = rom1.compare(rom1)
+    difference = rom1.synchronized_compare(rom1)
     assert not difference
 
 @pytest.fixture
 def differences(rom1, rom2):
-    difference = rom1.compare(rom2)
+    difference = rom1.synchronized_compare(rom2)
     output_text(difference, print_func=print)
     return difference.details
 
@@ -88,6 +88,6 @@ def test_content(differences):
 @pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
 def test_compare_non_existing(monkeypatch, rom1):
     monkeypatch.setattr(Config.general, 'new_file', True)
-    difference = rom1.compare(NonExistingFile('/nonexisting', rom1))
+    difference = rom1.synchronized_compare(NonExistingFile('/nonexisting', rom1))
     assert difference.source2 == '/nonexisting'
     assert difference.details[-1].source2 == '/dev/null'
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
index 869855a..2b0d4f5 100644
--- a/tests/comparators/test_cpio.py
+++ b/tests/comparators/test_cpio.py
@@ -40,12 +40,12 @@ def test_identification(cpio1):
     assert isinstance(cpio1, CpioFile)
 
 def test_no_differences(cpio1):
-    difference = cpio1.compare(cpio1)
+    difference = cpio1.synchronized_compare(cpio1)
     assert not difference
 
 @pytest.fixture
 def differences(cpio1, cpio2):
-    return cpio1.compare(cpio2).details
+    return cpio1.synchronized_compare(cpio2).details
 
 @pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
 def test_listing(differences):
@@ -69,6 +69,6 @@ def test_compressed_files(differences):
 @pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
 def test_compare_non_existing(monkeypatch, cpio1):
     monkeypatch.setattr(Config.general, 'new_file', True)
-    difference = cpio1.compare(NonExistingFile('/nonexisting', cpio1))
+    difference = cpio1.synchronized_compare(NonExistingFile('/nonexisting', cpio1))
     assert difference.source2 == '/nonexisting'
     assert difference.details[-1].source2 == '/dev/null'
diff --git a/tests/comparators/test_deb.py b/tests/comparators/test_deb.py
index 5689b45..bf0d8e5 100644
--- a/tests/comparators/test_deb.py
+++ b/tests/comparators/test_deb.py
@@ -41,12 +41,12 @@ def test_identification(deb1):
     assert isinstance(deb1, DebFile)
 
 def test_no_differences(deb1):
-    difference = deb1.compare(deb1)
+    difference = deb1.synchronized_compare(deb1)
     assert not difference
 
 @pytest.fixture
 def differences(deb1, deb2):
-    return deb1.compare(deb2).details
+    return deb1.synchronized_compare(deb2).details
 
 @pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_metadata(differences):
@@ -75,7 +75,7 @@ def test_identification_of_md5sums_in_deb(deb1, deb2, monkeypatch):
         return ret
     test_identification_of_md5sums_in_deb.found = False
     monkeypatch.setattr(Md5sumsFile, 'recognizes', probe)
-    deb1.compare(deb2)
+    deb1.synchronized_compare(deb2)
     assert test_identification_of_md5sums_in_deb.found
 
 @pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
@@ -98,7 +98,7 @@ def test_identification_of_data_tar(deb1, deb2, monkeypatch):
         return ret
     test_identification_of_data_tar.found = False
     monkeypatch.setattr(DebDataTarFile, 'recognizes', probe)
-    deb1.compare(deb2)
+    deb1.synchronized_compare(deb2)
     assert test_identification_of_data_tar.found
 
 @pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
@@ -109,12 +109,12 @@ def test_skip_comparison_of_known_identical_files(deb1, deb2, monkeypatch):
         compared.add(file1.name)
         return orig_func(file1, file2, source=None)
     monkeypatch.setattr(diffoscope.comparators, 'compare_files', probe)
-    deb1.compare(deb2)
+    deb1.synchronized_compare(deb2)
     assert './usr/share/doc/test/README.Debian' not in compared
 
 @pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_compare_non_existing(monkeypatch, deb1):
     monkeypatch.setattr(Config.general, 'new_file', True)
-    difference = deb1.compare(NonExistingFile('/nonexisting', deb1))
+    difference = deb1.synchronized_compare(NonExistingFile('/nonexisting', deb1))
     assert difference.source2 == '/nonexisting'
     assert difference.details[-1].source2 == '/dev/null'
diff --git a/tests/comparators/test_debian.py b/tests/comparators/test_debian.py
index 07d89d0..f42d9ef 100644
--- a/tests/comparators/test_debian.py
+++ b/tests/comparators/test_debian.py
@@ -65,12 +65,12 @@ def test_dot_changes_invalid(tmpdir):
     assert not isinstance(identified, DotChangesFile)
 
 def test_dot_changes_no_differences(dot_changes1):
-    difference = dot_changes1.compare(dot_changes1)
+    difference = dot_changes1.synchronized_compare(dot_changes1)
     assert not difference
 
 @pytest.fixture
 def dot_changes_differences(dot_changes1, dot_changes2):
-    difference = dot_changes1.compare(dot_changes2)
+    difference = dot_changes1.synchronized_compare(dot_changes2)
     output_text(difference, print_func=print)
     return difference.details
 
@@ -87,7 +87,7 @@ def test_dot_changes_internal_diff(dot_changes_differences):
 @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed')
 def test_dot_changes_compare_non_existing(monkeypatch, dot_changes1):
     monkeypatch.setattr(Config.general, 'new_file', True)
-    difference = dot_changes1.compare(NonExistingFile('/nonexisting', dot_changes1))
+    difference = dot_changes1.synchronized_compare(NonExistingFile('/nonexisting', dot_changes1))
     output_text(difference, print_func=print)
     assert difference.source2 == '/nonexisting'
     assert difference.details[-1].source2 == '/dev/null'
@@ -126,12 +126,17 @@ def test_dot_dsc_invalid(tmpdir, dot_dsc2):
     assert not isinstance(identified, DotDscFile)
 
 def test_dot_dsc_no_differences(dot_dsc1):
+<<<<<<< HEAD
     difference = dot_dsc1.compare(dot_dsc1)
     assert not difference
+=======
+    difference = dot_dsc1.synchronized_compare(dot_dsc1)
+    assert difference is None
+>>>>>>> acf14b9... XXX nomeata
 
 @pytest.fixture
 def dot_dsc_differences(dot_dsc1, dot_dsc2):
-    difference = dot_dsc1.compare(dot_dsc2)
+    difference = dot_dsc1.synchronized_compare(dot_dsc2)
     output_text(difference, print_func=print)
     return difference.details
 
@@ -142,7 +147,7 @@ def test_dot_dsc_internal_diff(dot_dsc_differences):
 @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed')
 def test_dot_dsc_compare_non_existing(monkeypatch, dot_dsc1):
     monkeypatch.setattr(Config.general, 'new_file', True)
-    difference = dot_dsc1.compare(NonExistingFile('/nonexisting', dot_dsc1))
+    difference = dot_dsc1.synchronized_compare(NonExistingFile('/nonexisting', dot_dsc1))
     output_text(difference, print_func=print)
     assert difference.source2 == '/nonexisting'
     assert difference.details[-1].source2 == '/dev/null'

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



More information about the Reproducible-commits mailing list