[Reproducible-commits] [debbindiff] 01/03: Add tests for tar comparator
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Jul 29 13:10:37 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 71da3ffa1a2bdd231d529a82a0a64c935bc6c638
Author: Jérémy Bobbio <lunar at debian.org>
Date: Mon Jun 29 15:52:49 2015 +0000
Add tests for tar comparator
---
tests/comparators/test_tar.py | 47 +++++++++++++++++++++++++++++++++++
tests/data/tar_listing_expected_diff | 9 +++++++
tests/data/test1.tar | Bin 0 -> 10240 bytes
tests/data/test2.tar | Bin 0 -> 10240 bytes
4 files changed, 56 insertions(+)
diff --git a/tests/comparators/test_tar.py b/tests/comparators/test_tar.py
new file mode 100644
index 0000000..0c3a55d
--- /dev/null
+++ b/tests/comparators/test_tar.py
@@ -0,0 +1,47 @@
+#!/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.tar import compare_tar_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.tar')
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.tar')
+
+def test_no_differences():
+ difference = compare_tar_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+ assert difference is None
+
+ at pytest.fixture
+def differences():
+ return compare_tar_files(TEST_FILE1_PATH, TEST_FILE2_PATH).details
+
+def test_compressed_files(differences):
+ assert differences[0].source1 == 'dir/text'
+ assert differences[0].source2 == 'dir/text'
+ expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
+ assert differences[0].unified_diff == expected_diff
+
+def test_listing(differences):
+ expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/tar_listing_expected_diff')).read()
+ assert differences[1].unified_diff == expected_diff
+
diff --git a/tests/data/tar_listing_expected_diff b/tests/data/tar_listing_expected_diff
new file mode 100644
index 0000000..505d11a
--- /dev/null
+++ b/tests/data/tar_listing_expected_diff
@@ -0,0 +1,9 @@
+@@ -1,4 +1,4 @@
+--rwxr-xr-x lunar/lunar 0 2015-06-29 15:49:09 dir/
+--rw-r--r-- lunar/lunar 446 2015-06-29 15:49:09 dir/text
+--rw-r--r-- root/root 1,3 2015-06-29 15:49:09 dir/null
+--rwxrwxrwx lunar/lunar 0 2015-06-29 15:49:09 dir/link -> broken
++-rwxr-xr-x lunar/lunar 0 2015-06-29 15:49:41 dir/
++-rw-r--r-- lunar/lunar 671 2015-06-29 15:49:41 dir/text
++-rw-r--r-- root/root 1,3 2015-06-29 15:49:41 dir/null
++-rwxrwxrwx lunar/lunar 0 2015-06-29 15:49:41 dir/link -> really-broken
diff --git a/tests/data/test1.tar b/tests/data/test1.tar
new file mode 100644
index 0000000..623737e
Binary files /dev/null and b/tests/data/test1.tar differ
diff --git a/tests/data/test2.tar b/tests/data/test2.tar
new file mode 100644
index 0000000..48ae92b
Binary files /dev/null and b/tests/data/test2.tar 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