[Git][reproducible-builds/diffoscope][master] 6 commits: Add 7zip to <!nocheck> Build-Depends.
Chris Lamb (@lamby)
gitlab at salsa.debian.org
Fri May 10 12:27:20 UTC 2024
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
9b421991 by Chris Lamb at 2024-05-10T12:43:49+01:00
Add 7zip to <!nocheck> Build-Depends.
- - - - -
8443cb8c by Chris Lamb at 2024-05-10T12:46:33+01:00
Add missing text_xz_list test file that I neglected to commit.
- - - - -
a6651ded by Chris Lamb at 2024-05-10T13:05:24+01:00
Fix tests after additon of xz --list.
- - - - -
2acff705 by Chris Lamb at 2024-05-10T13:24:10+01:00
Actually append the xz --list after the container differences, as it simplifies a lot.
- - - - -
0317ad5a by James Addison at 2024-05-10T13:26:07+01:00
Salsa issue #372: add expected test output.
- - - - -
4a685bbb by James Addison at 2024-05-10T13:26:21+01:00
Maintain in-header boolean state to determine whether to drop from-file/to-file lines. (Closes: #372)
- - - - -
9 changed files:
- debian/control
- diffoscope/comparators/xz.py
- diffoscope/diff.py
- tests/comparators/test_elf.py
- tests/comparators/test_xz.py
- + tests/data/output_expected_372.html
- + tests/data/salsa-issue-372.diff.json
- + tests/data/text_xz_list
- tests/test_presenters.py
Changes:
=====================================
debian/control
=====================================
@@ -7,6 +7,7 @@ Uploaders:
Holger Levsen <holger at debian.org>,
Mattia Rizzolo <mattia at debian.org>,
Build-Depends:
+ 7zip <!nocheck>,
aapt <!nocheck>,
abootimg <!nocheck>,
androguard <!nocheck>,
=====================================
diffoscope/comparators/xz.py
=====================================
@@ -70,9 +70,15 @@ class XzFile(File):
FALLBACK_FILE_EXTENSION_SUFFIX = {".xz"}
FALLBACK_FILE_TYPE_HEADER_PREFIX = b"\xfd7zXZ\x00"
- def compare_details(self, other, source=None):
- return [
- Difference.from_operation(
+ def compare(self, other, source=None):
+ difference = super().compare(other, source)
+
+ # Append xz --list *after* showing any container differences.
+ if isinstance(other, XzFile):
+ xz_list = Difference.from_operation(
XZList, self.path, other.path, source="xz --list"
)
- ]
+ if xz_list:
+ difference.add_details([xz_list])
+
+ return difference
=====================================
diffoscope/diff.py
=====================================
@@ -661,20 +661,21 @@ class SideBySideDiff:
"""
self.reset()
- diff_lines = iter(diff_split_lines(self.unified_diff, False))
- for l in diff_lines:
+ in_header = True
+ for l in diff_split_lines(self.unified_diff, False):
self._bytes_processed += len(l) + 1
m = re.match(r"^--- ([^\s]*)", l)
- if m:
+ if m and in_header:
yield from self.empty_buffer()
continue
m = re.match(r"^\+\+\+ ([^\s]*)", l)
- if m:
+ if m and in_header:
yield from self.empty_buffer()
continue
m = re.match(r"@@ -(\d+),?(\d*) \+(\d+),?(\d*)", l)
if m:
+ in_header = False
yield from self.empty_buffer()
hunk_data = map(lambda x: x == "" and 1 or int(x), m.groups())
(
@@ -690,10 +691,8 @@ class SideBySideDiff:
self.hunk_off2,
self.hunk_size2,
)
- break
+ continue
- for l in diff_lines:
- self._bytes_processed += len(l) + 1
if re.match(r"^\[", l):
yield from self.empty_buffer()
yield "C", l
=====================================
tests/comparators/test_elf.py
=====================================
@@ -244,7 +244,7 @@ def dbgsym_differences(monkeypatch, dbgsym_dir1, dbgsym_dir2):
return dbgsym_dir1.compare(dbgsym_dir2)
- at skip_unless_tools_exist("readelf", "objdump", "objcopy")
+ at skip_unless_tools_exist("readelf", "objdump", "objcopy", "xz")
@skip_if_binutils_does_not_support_x86()
@skip_unless_module_exists("debian.deb822")
def test_differences_with_dbgsym(dbgsym_differences):
@@ -258,7 +258,7 @@ def test_differences_with_dbgsym(dbgsym_differences):
)
- at skip_unless_tools_exist("readelf", "objdump", "objcopy")
+ at skip_unless_tools_exist("readelf", "objdump", "objcopy", "xz")
@skip_if_binutils_does_not_support_x86()
@skip_unless_module_exists("debian.deb822")
def test_original_gnu_debuglink(dbgsym_differences):
=====================================
tests/comparators/test_xz.py
=====================================
@@ -48,10 +48,10 @@ def differences(xz1, xz2):
@skip_unless_tools_exist("xz")
def test_content_source(differences):
- assert differences[0].source1 == "xz --list"
- assert differences[0].source2 == "xz --list"
- assert differences[1].source1 == "test1"
- assert differences[1].source2 == "test2"
+ assert differences[0].source1 == "test1"
+ assert differences[0].source2 == "test2"
+ assert differences[1].source1 == "xz --list"
+ assert differences[1].source2 == "xz --list"
@skip_unless_tools_exist("xz")
@@ -63,14 +63,16 @@ def test_content_source_without_extension(tmpdir, xz1, xz2):
xz1 = specialize(FilesystemFile(path1))
xz2 = specialize(FilesystemFile(path2))
difference = xz1.compare(xz2).details
- assert difference[1].source1 == "test1-content"
- assert difference[1].source2 == "test2-content"
+ assert difference[0].source1 == "test1-content"
+ assert difference[0].source2 == "test2-content"
+ assert difference[1].source1 == "xz --list"
+ assert difference[1].source2 == "xz --list"
@skip_unless_tools_exist("xz")
def test_content_diff(differences):
- assert_diff(differences[0], "text_xz_list")
- assert_diff(differences[1], "text_ascii_expected_diff")
+ assert_diff(differences[0], "text_ascii_expected_diff")
+ assert_diff(differences[1], "text_xz_list")
@skip_unless_tools_exist("xz")
=====================================
tests/data/output_expected_372.html
=====================================
@@ -0,0 +1,43 @@
+ class="diffoscope">
+<div class="difference">
+ <div class="diffheader">
+ <div class="diffcontrol diffcontrol-double">⊟</div>
+ <div><span class="diffsize">296 B</span></div>
+ <div><span class="source">myfile1</span> vs.</div>
+ <div id="top"><span class="source">myfile2</span>
+ <a class="anchor" href="#top">¶</a>
+ </div>
+ </div>
+<table class="diff">
+<colgroup><col class="colines"/><col class="coldiff"/>
+<col class="colines"/><col class="coldiff"/></colgroup>
+<tr style="display:none;"><td> </td><td> </td><td> </td><td> </td></tr>
+<tr class="diffhunk"><td colspan="2">Offset 1, 11 lines modified</td><td colspan="2">Offset 1, 11 lines modified</td></tr>
+<tr class="diffunmodified"><td class="diffline">1 </td><td class="diffpresent">Line<span class="dp">·</span>1</td><td class="diffline">1 </td><td class="diffpresent">Line<span class="dp">·</span>1</td></tr>
+<tr class="diffunmodified"><td class="diffline">2 </td><td class="diffpresent">Line<span class="dp">·</span>2</td><td class="diffline">2 </td><td class="diffpresent">Line<span class="dp">·</span>2</td></tr>
+<tr class="diffunmodified"><td class="diffline">3 </td><td class="diffpresent">Line<span class="dp">·</span>3</td><td class="diffline">3 </td><td class="diffpresent">Line<span class="dp">·</span>3</td></tr>
+<tr class="diffchanged"><td class="diffline">4 </td><td class="diffpresent">Line<span class="dp">·</span>4</td><td class="diffline">4 </td><td class="diffpresent">Line<span class="dp">·</span>4<ins>b</ins></td></tr>
+<tr class="diffunmodified"><td class="diffline">5 </td><td class="diffpresent">Line<span class="dp">·</span>5</td><td class="diffline">5 </td><td class="diffpresent">Line<span class="dp">·</span>5</td></tr>
+<tr class="diffunmodified"><td class="diffline">6 </td><td class="diffpresent">Line<span class="dp">·</span>6</td><td class="diffline">6 </td><td class="diffpresent">Line<span class="dp">·</span>6</td></tr>
+<tr class="diffunmodified"><td class="diffline">7 </td><td class="diffpresent">Line<span class="dp">·</span>7</td><td class="diffline">7 </td><td class="diffpresent">Line<span class="dp">·</span>7</td></tr>
+<tr class="diffunmodified"><td class="diffline">8 </td><td class="diffpresent">Line<span class="dp">·</span>8</td><td class="diffline">8 </td><td class="diffpresent">Line<span class="dp">·</span>8</td></tr>
+<tr class="diffunmodified"><td class="diffline">9 </td><td class="diffpresent">Line<span class="dp">·</span>9</td><td class="diffline">9 </td><td class="diffpresent">Line<span class="dp">·</span>9</td></tr>
+<tr class="diffunmodified"><td class="diffline">10 </td><td class="diffpresent">Line<span class="dp">·</span>10</td><td class="diffline">10 </td><td class="diffpresent">Line<span class="dp">·</span>10</td></tr>
+<tr class="diffunmodified"><td class="diffline">11 </td><td class="diffpresent">Line<span class="dp">·</span>11</td><td class="diffline">11 </td><td class="diffpresent">Line<span class="dp">·</span>11</td></tr>
+<tr class="diffhunk"><td colspan="2">Offset 28, 15 lines modified</td><td colspan="2">Offset 28, 15 lines modified</td></tr>
+<tr class="diffunmodified"><td class="diffline">28 </td><td class="diffpresent">Line<span class="dp">·</span>28</td><td class="diffline">28 </td><td class="diffpresent">Line<span class="dp">·</span>28</td></tr>
+<tr class="diffunmodified"><td class="diffline">29 </td><td class="diffpresent">Line<span class="dp">·</span>29</td><td class="diffline">29 </td><td class="diffpresent">Line<span class="dp">·</span>29</td></tr>
+<tr class="diffunmodified"><td class="diffline">30 </td><td class="diffpresent">Line<span class="dp">·</span>30</td><td class="diffline">30 </td><td class="diffpresent">Line<span class="dp">·</span>30</td></tr>
+<tr class="diffunmodified"><td class="diffline">31 </td><td class="diffpresent">Line<span class="dp">·</span>31</td><td class="diffline">31 </td><td class="diffpresent">Line<span class="dp">·</span>31</td></tr>
+<tr class="diffunmodified"><td class="diffline">32 </td><td class="diffpresent">Line<span class="dp">·</span>32</td><td class="diffline">32 </td><td class="diffpresent">Line<span class="dp">·</span>32</td></tr>
+<tr class="diffunmodified"><td class="diffline">33 </td><td class="diffpresent">Line<span class="dp">·</span>33</td><td class="diffline">33 </td><td class="diffpresent">Line<span class="dp">·</span>33</td></tr>
+<tr class="diffunmodified"><td class="diffline">34 </td><td class="diffpresent">Line<span class="dp">·</span>34</td><td class="diffline">34 </td><td class="diffpresent">Line<span class="dp">·</span>34</td></tr>
+<tr class="diffchanged"><td class="diffline">35 </td><td class="diffpresent">Line<span class="dp">·</span>35</td><td class="diffline">35 </td><td class="diffpresent">Line<span class="dp">·</span>35<ins>b</ins></td></tr>
+<tr class="diffunmodified"><td class="diffline">36 </td><td class="diffpresent">Line<span class="dp">·</span>36</td><td class="diffline">36 </td><td class="diffpresent">Line<span class="dp">·</span>36</td></tr>
+<tr class="diffunmodified"><td class="diffline">37 </td><td class="diffpresent">Line<span class="dp">·</span>37</td><td class="diffline">37 </td><td class="diffpresent">Line<span class="dp">·</span>37</td></tr>
+<tr class="diffunmodified"><td class="diffline">38 </td><td class="diffpresent">Line<span class="dp">·</span>38</td><td class="diffline">38 </td><td class="diffpresent">Line<span class="dp">·</span>38</td></tr>
+<tr class="diffunmodified"><td class="diffline">39 </td><td class="diffpresent">Line<span class="dp">·</span>39</td><td class="diffline">39 </td><td class="diffpresent">Line<span class="dp">·</span>39</td></tr>
+<tr class="diffunmodified"><td class="diffline">40 </td><td class="diffpresent">Line<span class="dp">·</span>40</td><td class="diffline">40 </td><td class="diffpresent">Line<span class="dp">·</span>40</td></tr>
+<tr class="diffunmodified"><td class="diffline">41 </td><td class="diffpresent">Line<span class="dp">·</span>41</td><td class="diffline">41 </td><td class="diffpresent">Line<span class="dp">·</span>41</td></tr>
+<tr class="diffunmodified"><td class="diffline">42 </td><td class="diffpresent">Line<span class="dp">·</span>42</td><td class="diffline">42 </td><td class="diffpresent">Line<span class="dp">·</span>42</td></tr>
+</table></div>
=====================================
tests/data/salsa-issue-372.diff.json
=====================================
@@ -0,0 +1 @@
+{"diffoscope-json-version": 1, "source1": "myfile1", "source2": "myfile2", "unified_diff": "@@ -1,11 +1,11 @@\n Line 1\n Line 2\n Line 3\n-Line 4\n+Line 4b\n Line 5\n Line 6\n Line 7\n Line 8\n Line 9\n Line 10\n Line 11\n@@ -28,15 +28,15 @@\n Line 28\n Line 29\n Line 30\n Line 31\n Line 32\n Line 33\n Line 34\n-Line 35\n+Line 35b\n Line 36\n Line 37\n Line 38\n Line 39\n Line 40\n Line 41\n Line 42\n"}
=====================================
tests/data/text_xz_list
=====================================
@@ -0,0 +1,21 @@
+@@ -1,14 +1,14 @@
+-/home/lamby/git/debian/reproducible-builds/diffoscope/tests/data/test1.xz (1/1)
++/home/lamby/git/debian/reproducible-builds/diffoscope/tests/data/test2.xz (1/1)
+ Streams: 1
+ Blocks: 1
+- Compressed size: 388 B
+- Uncompressed size: 446 B
+- Ratio: 0.870
++ Compressed size: 532 B
++ Uncompressed size: 671 B
++ Ratio: 0.793
+ Check: CRC64
+ Stream Padding: 0 B
+ Streams:
+ Stream Blocks CompOffset UncompOffset CompSize UncompSize Ratio Check Padding
+- 1 1 0 0 388 446 0.870 CRC64 0
++ 1 1 0 0 532 671 0.793 CRC64 0
+ Blocks:
+ Stream Block CompOffset UncompOffset TotalSize UncompSize Ratio Check
+- 1 1 12 0 352 446 0.789 CRC64
++ 1 1 12 0 496 671 0.739 CRC64
=====================================
tests/test_presenters.py
=====================================
@@ -219,6 +219,25 @@ def test_html_presentation_issue_363(tmpdir, capsys):
assert extract_body(f.read()) == get_data("output_expected_363.html")
+def test_html_presentation_issue_372(tmpdir, capsys):
+ filename = "salsa-issue-372.diff.json"
+ diff_data = get_data(filename)
+ diff_path = str(tmpdir.join(filename))
+ with open(diff_path, "w") as fp:
+ fp.write(diff_data)
+ report_path = str(tmpdir.join("report.html"))
+ out = run(
+ capsys,
+ "--html",
+ report_path,
+ f"--load-existing-diff={diff_path}",
+ )
+ assert out == ""
+
+ with open(report_path, "r", encoding="utf-8") as f:
+ assert extract_body(f.read()) == get_data("output_expected_372.html")
+
+
def test_limited_print():
def fake(x):
return None
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/49871a42eb8206dc1379ca8871001ebaddf5d083...4a685bbb57caecc8d9455a2bd6fdb47f11a221ec
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/49871a42eb8206dc1379ca8871001ebaddf5d083...4a685bbb57caecc8d9455a2bd6fdb47f11a221ec
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/20240510/4645936c/attachment.htm>
More information about the rb-commits
mailing list