[Git][reproducible-builds/diffoscope][master] 2 commits: Drop accidentally-duplicated copy of the --diff-mask tests.

Chris Lamb gitlab at salsa.debian.org
Mon Jun 29 09:50:01 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
3cfc880d by Chris Lamb at 2020-06-29T10:49:44+01:00
Drop accidentally-duplicated copy of the --diff-mask tests.

Double the test coverage!

- - - - -
f6ad0fbb by Chris Lamb at 2020-06-29T10:49:44+01:00
Replace strings with "[masked]" when using --diff-mask instead of "[filtered]". (Re. reproducible-builds/diffoscope!51)

Suggested by Jean-Romain Garnier in:

    https://salsa.debian.org/reproducible-builds/diffoscope/-/merge_requests/51#note_177808

- - - - -


3 changed files:

- diffoscope/feeders.py
- tests/test_diff_mask.py
- − tests/test_exclude_substrings.py


Changes:

=====================================
diffoscope/feeders.py
=====================================
@@ -55,10 +55,10 @@ def filter_reader(buf, additional_filter=None):
     # Use either str or bytes objects depending on buffer type
     if isinstance(buf, str):
         compile_func = compile_string_regex
-        replace = "[filtered]"
+        replace = "[masked]"
     else:
         compile_func = compile_bytes_regex
-        replace = b"[filtered]"
+        replace = b"[masked]"
 
     for regex in Config().diff_masks:
         buf = compile_func(regex).sub(replace, buf)


=====================================
tests/test_diff_mask.py
=====================================
@@ -43,29 +43,29 @@ def run(capsys, *args):
 
 def test_none(capsys):
     ret, out = run(capsys)
-    # Make sure the output doesn't contain any [filtered]
-    assert re.search(r"\[filtered\]", out) is None
+    # Make sure the output doesn't contain any [masked]
+    assert re.search(r"\[masked\]", out) is None
     assert ret == 1
 
 
 def test_all(capsys):
     ret, out = run(capsys, "--diff-mask=.*")
 
-    # Make sure the correct sections were filtered
+    # Make sure the correct sections were masked
     assert "file list" not in out
     assert "dir/link" not in out
 
-    # Make sure the output contains only [filtered]
+    # Make sure the output contains only [masked]
     # Lines of content start with "│ ", and then either have a +, a - or a space
     # depending on the type of change
-    # It should then only contain "[filtered]" until the end of the string
-    assert re.search(r"│\s[\s\+\-](?!(\[filtered\])+)", out) is None
+    # It should then only contain "[masked]" until the end of the string
+    assert re.search(r"│\s[\s\+\-](?!(\[masked\])+)", out) is None
     assert ret == 1
 
 
 def test_specific(capsys):
     ret, out = run(capsys, "--diff-mask=^Lorem")
-    # Make sure only the Lorem ipsum at the start of the line was filtered
-    assert "[filtered] ipsum dolor sit amet" in out
+    # Make sure only the Lorem ipsum at the start of the line was masked
+    assert "[masked] ipsum dolor sit amet" in out
     assert '"Lorem ipsum"' in out
     assert ret == 1


=====================================
tests/test_exclude_substrings.py deleted
=====================================
@@ -1,71 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# diffoscope: in-depth comparison of files, archives, and directories
-#
-# Copyright © 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
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# diffoscope is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
-
-import os
-import re
-import pytest
-
-from diffoscope.main import main
-
-
-def run(capsys, *args):
-    with pytest.raises(SystemExit) as exc:
-        main(
-            args
-            + tuple(
-                os.path.join(os.path.dirname(__file__), "data", x)
-                for x in ("test1.tar", "test2.tar")
-            )
-        )
-
-    out, err = capsys.readouterr()
-
-    assert err == ""
-
-    return exc.value.code, out
-
-
-def test_none(capsys):
-    ret, out = run(capsys)
-    # Make sure the output doesn't contain any [filtered]
-    assert re.search(r"\[filtered\]", out) is None
-    assert ret == 1
-
-
-def test_all(capsys):
-    ret, out = run(capsys, "--diff-mask=.*")
-
-    # Make sure the correct sections were filtered
-    assert "file list" not in out
-    assert "dir/link" not in out
-
-    # Make sure the output contains only [filtered]
-    # Lines of content start with "│ ", and then either have a +, a - or a space
-    # depending on the type of change
-    # It should then only contain "[filtered]" until the end of the string
-    assert re.search(r"│\s[\s\+\-](?!(\[filtered\])+)", out) is None
-    assert ret == 1
-
-
-def test_specific(capsys):
-    ret, out = run(capsys, "--diff-mask=^Lorem")
-    # Make sure only the Lorem ipsum at the start of the line was filtered
-    assert "[filtered] ipsum dolor sit amet" in out
-    assert '"Lorem ipsum"' in out
-    assert ret == 1



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/7d597414be93278616b9ea81c47f783b2515915e...f6ad0fbb9eeba4889b1468be61f1d48844d432d2

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/7d597414be93278616b9ea81c47f783b2515915e...f6ad0fbb9eeba4889b1468be61f1d48844d432d2
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/20200629/1620b8e2/attachment.htm>


More information about the rb-commits mailing list