[Git][reproducible-builds/diffoscope][master] 3 commits: Clarify the message when we truncate the number of lines to standard error.

Chris Lamb gitlab at salsa.debian.org
Tue May 12 08:34:31 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
ca9d589c by Chris Lamb at 2020-05-12T09:27:22+01:00
Clarify the message when we truncate the number of lines to standard error.

- - - - -
6d269b1a by Chris Lamb at 2020-05-12T09:29:10+01:00
Clarify when an external command emits for both files, otherwise it can look like diffoscope is repeating itself when it is actually being run twice.

- - - - -
a294ad1b by Chris Lamb at 2020-05-12T09:34:20+01:00
Don't repeat "stderr from {}" if both commands emit the same thing.

- - - - -


3 changed files:

- diffoscope/comparators/utils/command.py
- diffoscope/difference.py
- tests/comparators/test_utils.py


Changes:

=====================================
diffoscope/comparators/utils/command.py
=====================================
@@ -101,7 +101,8 @@ class Command(metaclass=abc.ABCMeta):
             buf += line.decode('utf-8', errors='replace')
 
         if len(lines) > Command.MAX_STDERR_LINES:
-            buf += '[ {} lines ignored ]\n'.format(
+            buf += '[ truncated after {} lines; {} ignored ]\n'.format(
+                Command.MAX_STDERR_LINES,
                 len(lines) - Command.MAX_STDERR_LINES
             )
 


=====================================
diffoscope/difference.py
=====================================
@@ -295,16 +295,29 @@ class Difference:
         if not difference:
             return None, False
 
-        if command1 and command1.stderr:
+        if (
+            command1
+            and command1.stderr
+            and command2
+            and command2.stderr
+            and command1.shell_cmdline() == command2.shell_cmdline()
+        ):
+            # Output is the same, so don't repeat the output
             difference.add_comment(
                 "stderr from `{}`:".format(command1.shell_cmdline())
             )
             difference.add_comment(command1.stderr)
-        if command2 and command2.stderr:
-            difference.add_comment(
-                "stderr from `{}`:".format(command2.shell_cmdline())
-            )
-            difference.add_comment(command2.stderr)
+        else:
+            if command1 and command1.stderr:
+                difference.add_comment(
+                    "stderr from `{}` (a):".format(command1.shell_cmdline())
+                )
+                difference.add_comment(command1.stderr)
+            if command2 and command2.stderr:
+                difference.add_comment(
+                    "stderr from `{}` (b):".format(command2.shell_cmdline())
+                )
+                difference.add_comment(command2.stderr)
 
         return difference, False
 


=====================================
tests/comparators/test_utils.py
=====================================
@@ -3,7 +3,7 @@
 # diffoscope: in-depth comparison of files, archives, and directories
 #
 # Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
-# Copyright © 2015-2019 Chris Lamb <lamby at debian.org>
+# Copyright © 2015-2020 Chris Lamb <lamby at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -131,4 +131,9 @@ def test_trim_stderr_in_command():
             return r
 
     difference = Difference.from_command(FillStderr, 'dummy1', 'dummy2')
-    assert '[ 1 lines ignored ]' in difference.comment
+    assert (
+        '[ truncated after {} lines; 1 ignored ]'.format(
+            Command.MAX_STDERR_LINES
+        )
+        in difference.comment
+    )



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/e1c29fcbe2089e7a04b3591c5936c9c42de82adc...a294ad1b0472a805e0e54f4aee0f8731ecf45892

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/e1c29fcbe2089e7a04b3591c5936c9c42de82adc...a294ad1b0472a805e0e54f4aee0f8731ecf45892
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/20200512/25e8d4e4/attachment.htm>


More information about the rb-commits mailing list