[Reproducible-commits] [diffoscope] 05/05: Fix placeholder encoding issue when trimming stderr

Jérémy Bobbio lunar at moszumanska.debian.org
Thu Sep 24 09:38:08 UTC 2015


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

lunar pushed a commit to branch master
in repository diffoscope.

commit 3b7a4609569bd23fbd5571cb1c35f1aaf4626924
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Thu Sep 24 09:36:12 2015 +0000

    Fix placeholder encoding issue when trimming stderr
    
    And a test while we are at it.
    
    Closes: #799863
---
 diffoscope/comparators/utils.py |  2 +-
 tests/comparators/test_utils.py | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/diffoscope/comparators/utils.py b/diffoscope/comparators/utils.py
index 6b586bc..e2aed5b 100644
--- a/diffoscope/comparators/utils.py
+++ b/diffoscope/comparators/utils.py
@@ -117,7 +117,7 @@ class Command(object, metaclass=ABCMeta):
             if self._stderr_line_count <= Command.MAX_STDERR_LINES:
                 self._stderr.write(line)
         if self._stderr_line_count > Command.MAX_STDERR_LINES:
-            self._stderr.write('[ %d lines ignored ]\n' % (self._stderr_line_count - Command.MAX_STDERR_LINES))
+            self._stderr.write('[ {} lines ignored ]\n'.format(self._stderr_line_count - Command.MAX_STDERR_LINES).encode('utf-8'))
         self._process.stderr.close()
 
     @property
diff --git a/tests/comparators/test_utils.py b/tests/comparators/test_utils.py
index 9c69474..1957e71 100644
--- a/tests/comparators/test_utils.py
+++ b/tests/comparators/test_utils.py
@@ -22,7 +22,10 @@ import os.path
 import pytest
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+from diffoscope.comparators.utils import Command
 from diffoscope.config import Config
+from diffoscope.difference import Difference
+from conftest import tool_missing
 
 @pytest.fixture
 def fuzzy_tar1():
@@ -70,3 +73,15 @@ def test_no_fuzzy_matching_new_file(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in
     assert len(difference.details) == 3
     assert difference.details[1].source2 == '/dev/null'
     assert difference.details[2].source1 == '/dev/null'
+
+ at pytest.mark.skipif(tool_missing('tee'), reason='missing tee')
+def test_trim_stderr_in_command():
+    class FillStderr(Command):
+        def cmdline(self):
+            return ['tee', '/dev/stderr']
+
+        def feed_stdin(self, stdin):
+            for dummy in range(0, Command.MAX_STDERR_LINES + 1):
+                stdin.write('error {}\n'.format(self.path).encode('utf-8'))
+    difference = Difference.from_command(FillStderr, 'dummy1', 'dummy2')
+    assert '[ 1 lines ignored ]' in difference.comment

-- 
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