[Reproducible-commits] [debbindiff] 03/03: Add tests for RPM comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 18:26:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository debbindiff.

commit a1e2842d535914b4345cd9c87ddf5866793f8814
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 18:23:05 2015 +0000

    Add tests for RPM comparator
---
 tests/comparators/test_rpm.py       |  46 +++++++++++++++++++++++++++++++++++
 tests/data/rpm_header_expected_diff |  47 ++++++++++++++++++++++++++++++++++++
 tests/data/test1.rpm                | Bin 0 -> 5975 bytes
 tests/data/test2.rpm                | Bin 0 -> 6114 bytes
 4 files changed, 93 insertions(+)

diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py
new file mode 100644
index 0000000..c2f3b14
--- /dev/null
+++ b/tests/comparators/test_rpm.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff 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.
+#
+# debbindiff 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 debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+import codecs
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.rpm import compare_rpm_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.rpm')
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.rpm')
+
+def test_no_differences():
+    differences = compare_rpm_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_rpm_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_header(differences):
+    assert differences[0].source1 == 'header'
+    open('/tmp/output', 'w').write(differences[0].unified_diff)
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/rpm_header_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+def test_content(differences):
+    assert differences[1].source1 == 'CONTENTS.cpio'
+    assert differences[1].details[1].source1 == './dir/text'
diff --git a/tests/data/rpm_header_expected_diff b/tests/data/rpm_header_expected_diff
new file mode 100644
index 0000000..01d5329
--- /dev/null
+++ b/tests/data/rpm_header_expected_diff
@@ -0,0 +1,47 @@
+@@ -1,36 +1,36 @@
+-HEADERIMMUTABLE: 00000030000001b00000003f00000007000001a00000001000000064000000080000000000000001000003e8000000060000000200000001000003e9000000060000000700000001000003ea000000060000000900000001000003ec000000090000000b00000001000003ed000000090000002700000001000003ee000000040000003400000001000003ef000000060000003800000001000003f1000000040000004000000001000003f6000000060000004400000001000003f8000000090000004b00000001000003fd000000060000005f00000001000003fe0000000600000065000000010000040400 [...]
++HEADERIMMUTABLE: 00000030000001b00000003f00000007000001a00000001000000064000000080000000000000001000003e8000000060000000200000001000003e9000000060000000700000001000003ea000000060000000900000001000003ec000000090000000b00000001000003ed000000090000002700000001000003ee000000040000003400000001000003ef000000060000003800000001000003f1000000040000004000000001000003f6000000060000004400000001000003f8000000090000004b00000001000003fd000000060000005f00000001000003fe0000000600000065000000010000040400 [...]
+ HEADERI18NTABLE: ['C']
+-SIGSIZE: 1583
+-SIGMD5: 06166011d2d66f8433d50b417358a31d
+-SHA1HEADER: 331667229aa7e4d600f682e9cd0c6372b93b082a
++SIGSIZE: 1722
++SIGMD5: 746686e44fc68a5836e8043f722e436a
++SHA1HEADER: 2780015bd7bd365949d05e29618fa833e62e4604
+ NAME: test
+ VERSION: 0
+ RELEASE: 0
+ SUMMARY: Test package for debbindiff
+ DESCRIPTION: Test package
+-BUILDTIME: 1435168523
++BUILDTIME: 1435168561
+ BUILDHOST: loar
+-SIZE: 446
++SIZE: 671
+ LICENSE: Public
+ GROUP: Applications/System
+ OS: linux
+ ARCH: x86_64
+-FILESIZES: [446L]
++FILESIZES: [671L]
+ FILEMODES: [33188L]
+ FILERDEVS: [0L]
+-FILEMTIMES: [1435168518L]
+-FILEMD5S: ['7873b606429a70284d63f0674e6787bc']
++FILEMTIMES: [1435168559L]
++FILEMD5S: ['17866262a0c60d916e3cf3219724b2e7']
+ FILELINKTOS: ['']
+ FILEFLAGS: [0L]
+ FILEUSERNAME: ['root']
+ FILEGROUPNAME: ['root']
+ SOURCERPM: test-0-0.src.rpm
+ FILEVERIFYFLAGS: [4294967295L]
+-ARCHIVESIZE: 696
++ARCHIVESIZE: 920
+ PROVIDES: ['test', 'test(x86-64)']
+ REQUIREFLAGS: [16777226L, 16777226L]
+ REQUIRES: ['rpmlib(CompressedFileNames)', 'rpmlib(PayloadFilesHavePrefix)']
+ REQUIREVERSION: ['3.0.4-1', '4.0-1']
+ RPMVERSION: 4.12.0.1
+ FILEDEVICES: [1L]
+ FILEINODES: [1L]
diff --git a/tests/data/test1.rpm b/tests/data/test1.rpm
new file mode 100644
index 0000000..31c2566
Binary files /dev/null and b/tests/data/test1.rpm differ
diff --git a/tests/data/test2.rpm b/tests/data/test2.rpm
new file mode 100644
index 0000000..f0e8c0e
Binary files /dev/null and b/tests/data/test2.rpm differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git



More information about the Reproducible-commits mailing list