[Git][reproducible-builds/diffoscope][master] 2 commits: tests: embed test fixture in the code

Mattia Rizzolo gitlab at salsa.debian.org
Sun May 2 14:46:19 UTC 2021



Mattia Rizzolo pushed to branch master at Reproducible Builds / diffoscope


Commits:
df737679 by Mattia Rizzolo at 2021-05-02T16:44:03+02:00
tests: embed test fixture in the code

This is to make it easier to mangle the fixture at runtime.

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -
864644f1 by Mattia Rizzolo at 2021-05-02T16:44:50+02:00
Fix recognition of XZ files with file 5.40

See: reproducible-builds/diffoscope#251

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -


5 changed files:

- diffoscope/comparators/xz.py
- tests/comparators/test_containers.py
- − tests/data/containers/magic_bzip2
- − tests/data/containers/magic_gzip
- − tests/data/containers/magic_xz


Changes:

=====================================
diffoscope/comparators/xz.py
=====================================
@@ -56,7 +56,7 @@ class XzContainer(Archive):
 class XzFile(File):
     DESCRIPTION = "XZ compressed files"
     CONTAINER_CLASSES = [XzContainer]
-    FILE_TYPE_RE = re.compile(r"^XZ compressed data$")
+    FILE_TYPE_RE = re.compile(r"^XZ compressed data\b")
 
     # Work around file(1) Debian bug #876316
     FALLBACK_FILE_EXTENSION_SUFFIX = {".xz"}


=====================================
tests/comparators/test_containers.py
=====================================
@@ -24,6 +24,7 @@ import itertools
 from ..utils.data import load_fixture, get_data
 from ..utils.tools import (
     skip_unless_tools_exist,
+    file_version_is_ge,
     skip_unless_file_version_is_at_least,
 )
 
@@ -50,9 +51,18 @@ def set2(gzip2, bzip2, xz2):
 
 
 def expected_magic_diff(ext1, ext2):
-    meta1 = get_data("containers/magic_%s" % ext1)
-    meta2 = get_data("containers/magic_%s" % ext2)
-    return "@@ -1 +1 @@\n" + "-" + meta1 + "+" + meta2
+    magic = {
+        "bzip2": "bzip2 compressed data, block size = 900k\n",
+        "gzip": "gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix\n",
+        "xz": "XZ compressed data",
+    }
+    if "xz" in (ext1, ext2):
+        if file_version_is_ge("5.40"):
+            magic["xz"] += ", checksum CRC64\n"
+        else:
+            magic["xz"] += "\n"
+
+    return "@@ -1 +1 @@\n" + "-" + magic[ext1] + "+" + magic[ext2]
 
 
 def expected_type_diff(ext1, ext2):


=====================================
tests/data/containers/magic_bzip2 deleted
=====================================
@@ -1 +0,0 @@
-bzip2 compressed data, block size = 900k


=====================================
tests/data/containers/magic_gzip deleted
=====================================
@@ -1 +0,0 @@
-gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix


=====================================
tests/data/containers/magic_xz deleted
=====================================
@@ -1 +0,0 @@
-XZ compressed data



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/7bf04a62623d234a870fd62b0ee745c9b940f5d7...864644f1a24ab619306bec08d6e44fadea12826d

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/7bf04a62623d234a870fd62b0ee745c9b940f5d7...864644f1a24ab619306bec08d6e44fadea12826d
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/20210502/818ffeb8/attachment.htm>


More information about the rb-commits mailing list