[Reproducible-commits] [debbindiff] 05/06: Add tests for cpio comparator
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Jun 24 17:37:05 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 571b9d46b2f61f32d16945e532e498f3056e890f
Author: Jérémy Bobbio <lunar at debian.org>
Date: Wed Jun 24 17:22:31 2015 +0000
Add tests for cpio comparator
---
tests/comparators/test_cpio.py | 46 ++++++++++++++++++++++++++++++++++
tests/data/cpio_listing_expected_diff | 8 ++++++
tests/data/test1.cpio | Bin 0 -> 1024 bytes
tests/data/test2.cpio | Bin 0 -> 1024 bytes
4 files changed, 54 insertions(+)
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
new file mode 100644
index 0000000..3e99e05
--- /dev/null
+++ b/tests/comparators/test_cpio.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.cpio import compare_cpio_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.cpio')
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.cpio')
+
+def test_no_differences():
+ differences = compare_cpio_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+ assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+ return compare_cpio_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_listing(differences):
+ expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/cpio_listing_expected_diff')).read()
+ assert differences[0].unified_diff == expected_diff
+
+def test_compressed_files(differences):
+ assert differences[1].source1 == 'dir/text'
+ assert differences[1].source2 == 'dir/text'
+ expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
+ assert differences[1].unified_diff == expected_diff
diff --git a/tests/data/cpio_listing_expected_diff b/tests/data/cpio_listing_expected_diff
new file mode 100644
index 0000000..8b9be77
--- /dev/null
+++ b/tests/data/cpio_listing_expected_diff
@@ -0,0 +1,8 @@
+@@ -1,4 +1,4 @@
+-lrwxrwxrwx 1 lunar lunar 6 Jun 24 15:10 dir/link -> broken
++lrwxrwxrwx 1 lunar lunar 13 Jun 24 15:11 dir/link -> really-broken
+ crw-r--r-- 1 root root 1, 3 Jun 24 14:47 dir/null
+--rw-r--r-- 1 lunar lunar 446 Jun 24 15:10 dir/text
+-drwxr-xr-x 2 lunar lunar 0 Jun 24 15:10 dir
++-rw-r--r-- 1 lunar lunar 671 Jun 24 15:11 dir/text
++drwxr-xr-x 2 lunar lunar 0 Jun 24 15:11 dir
diff --git a/tests/data/test1.cpio b/tests/data/test1.cpio
new file mode 100644
index 0000000..fac9707
Binary files /dev/null and b/tests/data/test1.cpio differ
diff --git a/tests/data/test2.cpio b/tests/data/test2.cpio
new file mode 100644
index 0000000..6c8c980
Binary files /dev/null and b/tests/data/test2.cpio 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