[Git][reproducible-builds/diffoscope][master] 2 commits: Move test_rpm to use assert_diff.

Chris Lamb gitlab at salsa.debian.org
Mon Mar 15 17:37:20 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
c8a5cc90 by Chris Lamb at 2021-03-15T17:34:41+00:00
Move test_rpm to use assert_diff.

- - - - -
d6955ff4 by Chris Lamb at 2021-03-15T17:36:54+00:00
Avoid frequent long lines in RPM header outputs that cause very slow HTML output. (Closes: reproducible-builds/diffoscope#245)

- - - - -


3 changed files:

- diffoscope/comparators/rpm.py
- tests/comparators/test_rpm.py
- tests/data/rpm_header_expected_diff


Changes:

=====================================
diffoscope/comparators/rpm.py
=====================================
@@ -23,6 +23,7 @@ import rpm
 import os.path
 import logging
 import binascii
+import textwrap
 import subprocess
 
 from diffoscope.tools import tool_required
@@ -40,19 +41,22 @@ def convert_header_field(io, header):
         if len(header) == 0:
             io.write(u"[]")
         else:
-            io.write(u"\n")
             for item in header:
-                io.write(u" - ")
+                io.write(u"\n - ")
                 convert_header_field(io, item)
-    elif isinstance(header, str):
-        io.write(header)
+        return
+
+    if isinstance(header, str):
+        val = header
     elif isinstance(header, bytes):
         try:
-            io.write(header.decode("utf-8"))
+            val = header.decode("utf-8")
         except UnicodeDecodeError:
-            io.write(binascii.hexlify(header).decode("us-ascii"))
+            val = binascii.hexlify(header).decode("us-ascii")
     else:
-        io.write(repr(header))
+        val = repr(header)
+
+    io.write(textwrap.fill(val, 100))
 
 
 def get_rpm_header(path, ts):


=====================================
tests/comparators/test_rpm.py
=====================================
@@ -23,7 +23,13 @@ from diffoscope.comparators import ComparatorManager
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from ..utils.data import load_fixture, data, get_data, normalize_zeros
+from ..utils.data import (
+    load_fixture,
+    data,
+    get_data,
+    normalize_zeros,
+    assert_diff,
+)
 from ..utils.tools import skip_unless_tools_exist, skip_unless_module_exists
 from ..utils.nonexisting import assert_non_existing
 
@@ -55,8 +61,7 @@ def differences(rpm1, rpm2):
 @skip_unless_tools_exist("rpm2cpio")
 def test_header(differences):
     assert differences[0].source1 == "header"
-    expected_diff = get_data("rpm_header_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "rpm_header_expected_diff")
 
 
 @skip_unless_module_exists("rpm")
@@ -64,8 +69,7 @@ def test_header(differences):
 def test_listing(differences):
     assert differences[1].source1 == "content"
     assert differences[1].details[0].source1 == "file list"
-    expected_diff = get_data("rpm_listing_expected_diff")
-    assert differences[1].details[0].unified_diff == expected_diff
+    assert_diff(differences[1].details[0], "rpm_listing_expected_diff")
 
 
 @skip_unless_module_exists("rpm")
@@ -73,8 +77,7 @@ def test_listing(differences):
 def test_content(differences):
     assert differences[1].source1 == "content"
     assert differences[1].details[1].source1 == "./dir/text"
-    expected_diff = get_data("text_ascii_expected_diff")
-    assert differences[1].details[1].unified_diff == expected_diff
+    assert_diff(differences[1].details[1], "text_ascii_expected_diff")
 
 
 @skip_unless_module_exists("rpm")


=====================================
tests/data/rpm_header_expected_diff
=====================================
@@ -1,6 +1,23 @@
-@@ -1,47 +1,47 @@
--HEADERIMMUTABLE: 00000030000001b00000003f00000007000001a00000001000000064000000080000000000000001000003e8000000060000000200000001000003e9000000060000000700000001000003ea000000060000000900000001000003ec000000090000000b00000001000003ed000000090000002700000001000003ee000000040000003400000001000003ef000000060000003800000001000003f1000000040000004000000001000003f6000000060000004400000001000003f8000000090000004b00000001000003fd000000060000005f00000001000003fe00000006000000650000000100000404000000040000006c0000000100000406000000030000007000000001000004090000000300000072000000010000040a0000000400000074000000010000040b0000000800000078000000010000040c0000000800000099000000010000040d000000040000009c000000010000040f00000008000000a0000000010000041000000008000000a5000000010000041400000006000000aa000000010000041500000004000000bc000000010000041700000008000000c0000000020000041800000004000000d4000000020000041900000008000000dc000000020000041a0000000800000117000000020000042800000006000001250000000100000447000000040000013000000001000004480000000400000134000000010000044900000008000001380000000100000458000000040000013c00000002000004590000000800000144000000020000045c000000040000014c000000010000045d0000000800000150000000010000045e00000008000001550000000100000462000000060000015b00000001000004640000000600000162000000010000046500000006000001670000000100000466000000060000016c000000010000046c000000060000016e00000001000004740000000400000184000000010000047500000004000001880000000100000476000000080000018c000000010000047700000004000001980000000100000478000000040000019c00000001430074657374003000300054657374207061636b61676520666f722064656262696e646966660054657374207061636b61676500558aef0b6c6f617200000000000001be5075626c6963004170706c69636174696f6e732f53797374656d006c696e7578007838365f363400000001be81a40000558aef0637383733623630363432396137303238346436336630363734653637383762630000000000000000726f6f7400726f6f7400746573742d302d302e7372632e72706d0000ffffffff746573740074657374287838362d3634290000000100000a0100000a72706d6c696228436f6d7072657373656446696c654e616d6573290072706d6c6962285061796c6f616446696c6573486176655072656669782900332e302e342d3100342e302d3100342e31322e302e310000000000000100000001000000000000000800000008302d3000302d30000000000074657874002f6469722f002d4f32202d67006370696f00677a69700039007838365f36342d64656269616e2d6c696e7578000000000000000000000041534349492074657874000000000000000000000000003f00000007fffffd0000000010
-+HEADERIMMUTABLE: 00000030000001b00000003f00000007000001a00000001000000064000000080000000000000001000003e8000000060000000200000001000003e9000000060000000700000001000003ea000000060000000900000001000003ec000000090000000b00000001000003ed000000090000002700000001000003ee000000040000003400000001000003ef000000060000003800000001000003f1000000040000004000000001000003f6000000060000004400000001000003f8000000090000004b00000001000003fd000000060000005f00000001000003fe00000006000000650000000100000404000000040000006c0000000100000406000000030000007000000001000004090000000300000072000000010000040a0000000400000074000000010000040b0000000800000078000000010000040c0000000800000099000000010000040d000000040000009c000000010000040f00000008000000a0000000010000041000000008000000a5000000010000041400000006000000aa000000010000041500000004000000bc000000010000041700000008000000c0000000020000041800000004000000d4000000020000041900000008000000dc000000020000041a0000000800000117000000020000042800000006000001250000000100000447000000040000013000000001000004480000000400000134000000010000044900000008000001380000000100000458000000040000013c00000002000004590000000800000144000000020000045c000000040000014c000000010000045d0000000800000150000000010000045e00000008000001550000000100000462000000060000015b00000001000004640000000600000162000000010000046500000006000001670000000100000466000000060000016c000000010000046c000000060000016e00000001000004740000000400000184000000010000047500000004000001880000000100000476000000080000018c000000010000047700000004000001980000000100000478000000040000019c00000001430074657374003000300054657374207061636b61676520666f722064656262696e646966660054657374207061636b61676500558aef316c6f6172000000000000029f5075626c6963004170706c69636174696f6e732f53797374656d006c696e7578007838365f3634000000029f81a40000558aef2f31373836363236326130633630643931366533636633323139373234623265370000000000000000726f6f7400726f6f7400746573742d302d302e7372632e72706d0000ffffffff746573740074657374287838362d3634290000000100000a0100000a72706d6c696228436f6d7072657373656446696c654e616d6573290072706d6c6962285061796c6f616446696c6573486176655072656669782900332e302e342d3100342e302d3100342e31322e302e310000000000000100000001000000000000000800000008302d3000302d30000000000074657874002f6469722f002d4f32202d67006370696f00677a69700039007838365f36342d64656269616e2d6c696e7578000000000000000000000041534349492074657874000000000000000000000000003f00000007fffffd0000000010
+@@ -10,62 +10,62 @@
+ 00dc000000020000041a00000008000001170000000200000428000000060000012500000001000004470000000400000130
+ 00000001000004480000000400000134000000010000044900000008000001380000000100000458000000040000013c0000
+ 0002000004590000000800000144000000020000045c000000040000014c000000010000045d000000080000015000000001
+ 0000045e00000008000001550000000100000462000000060000015b00000001000004640000000600000162000000010000
+ 046500000006000001670000000100000466000000060000016c000000010000046c000000060000016e0000000100000474
+ 0000000400000184000000010000047500000004000001880000000100000476000000080000018c00000001000004770000
+ 0004000001980000000100000478000000040000019c00000001430074657374003000300054657374207061636b61676520
+-666f722064656262696e646966660054657374207061636b61676500558aef0b6c6f617200000000000001be5075626c6963
+-004170706c69636174696f6e732f53797374656d006c696e7578007838365f363400000001be81a40000558aef0637383733
+-623630363432396137303238346436336630363734653637383762630000000000000000726f6f7400726f6f740074657374
++666f722064656262696e646966660054657374207061636b61676500558aef316c6f6172000000000000029f5075626c6963
++004170706c69636174696f6e732f53797374656d006c696e7578007838365f3634000000029f81a40000558aef2f31373836
++363236326130633630643931366533636633323139373234623265370000000000000000726f6f7400726f6f740074657374
+ 2d302d302e7372632e72706d0000ffffffff746573740074657374287838362d3634290000000100000a0100000a72706d6c
+ 696228436f6d7072657373656446696c654e616d6573290072706d6c6962285061796c6f616446696c657348617665507265
+ 6669782900332e302e342d3100342e302d3100342e31322e302e310000000000000100000001000000000000000800000008
+ 302d3000302d30000000000074657874002f6469722f002d4f32202d67006370696f00677a69700039007838365f36342d64
+ 656269616e2d6c696e7578000000000000000000000041534349492074657874000000000000000000000000003f00000007
+ fffffd0000000010
  HEADERI18NTABLE: 
   - C
 -SIGSIZE: 1583
@@ -50,9 +67,9 @@
 -ARCHIVESIZE: 696
 +ARCHIVESIZE: 920
  PROVIDES: 
-  - test - test(x86-64)
+  - test
+  - test(x86-64)
  REQUIREFLAGS: 
-  - 16777226 - 16777226
+  - 16777226
+  - 16777226
  REQUIRES: 
-  - rpmlib(CompressedFileNames) - rpmlib(PayloadFilesHavePrefix)
- REQUIREVERSION: 



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/248b06aacbd35f3cbec04ae3de28826b70d54338...d6955ff4fdef4c1859a90509bb5beb58a5c939f3

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/248b06aacbd35f3cbec04ae3de28826b70d54338...d6955ff4fdef4c1859a90509bb5beb58a5c939f3
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/20210315/a1aca683/attachment.htm>


More information about the rb-commits mailing list