[diffoscope] 02/04: Add tests for cross-container comparison.
Maria Glukhova
siamezzze-guest at moszumanska.debian.org
Sat Jan 21 17:07:31 CET 2017
This is an automated email from the git hooks/post-receive script.
siamezzze-guest pushed a commit to branch siamezzze/containers
in repository diffoscope.
commit d00362b84ffdc2709d0948a6aa3a6c134a46d56a
Author: Maria Glukhova <siamezzze at gmail.com>
Date: Sat Jan 21 05:21:59 2017 +0200
Add tests for cross-container comparison.
---
tests/comparators/test_containers.py | 81 +++++++++++++++++++++
tests/data/containers_content_expected_diff | 3 +
tests/data/containers_filelist_expected_diff | 8 ++
tests/data/containers_types_expected_diff | 3 +
.../data/nested_containers_filelist_expected_diff | 7 ++
tests/data/nested_containers_types_expected_diff | 3 +
tests/data/test1.tar.bz2 | Bin 0 -> 986 bytes
tests/data/test1.tar.gz | Bin 0 -> 1000 bytes
tests/data/test3.cpio | Bin 0 -> 512 bytes
tests/data/test3.tar | Bin 0 -> 10240 bytes
10 files changed, 105 insertions(+)
diff --git a/tests/comparators/test_containers.py b/tests/comparators/test_containers.py
new file mode 100644
index 0000000..d9de749
--- /dev/null
+++ b/tests/comparators/test_containers.py
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2017 Maria Glukhova <siammezzze at gmail.com>
+#
+# diffoscope 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.
+#
+# diffoscope 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 diffoscope. If not, see <https://www.gnu.org/licenses/>.
+
+import pytest
+
+try:
+ import tlsh
+ tlsh_found = True
+except ImportError:
+ tlsh_found = False
+
+from diffoscope.comparators.utils.compare import compare_files
+
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
+test_tar_gz = load_fixture('test1.tar.gz')
+test_zip_bz2 = load_fixture('test1.tar.bz2')
+test_tar = load_fixture('test3.tar')
+test_cpio = load_fixture('test3.cpio')
+
+ at pytest.fixture
+def differences_containers(test_tar, test_cpio):
+ return compare_files(test_tar, test_cpio).details
+
+ at pytest.fixture
+def differences_nested(test_tar_gz, test_zip_bz2):
+ return compare_files(test_tar_gz, test_zip_bz2).details
+
+ at skip_unless_tools_exist('cpio')
+def test_file_list(differences_containers):
+ expected_diff = open(data('containers_filelist_expected_diff')).read()
+ assert differences_containers[1].source1 == 'file list'
+ assert differences_containers[1].source2 == 'file list'
+ assert differences_containers[1].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('cpio')
+def test_types(differences_containers):
+ expected_diff = open(data('containers_types_expected_diff')).read()
+ assert differences_containers[0].source1 == 'container type'
+ assert differences_containers[0].source2 == 'container type'
+ assert differences_containers[0].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('cpio')
+def test_content(differences_containers):
+ expected_diff = open(data('containers_content_expected_diff')).read()
+ assert differences_containers[2].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('bzip2', 'gzip', 'zipinfo')
+ at pytest.mark.skipif(not tlsh_found, reason='tlsh is missing')
+def test_types_nested(differences_nested):
+ expected_diff = \
+ open(data('nested_containers_types_expected_diff')).read()
+ assert differences_nested[0].source1 == 'container type'
+ assert differences_nested[0].source2 == 'container type'
+ assert differences_nested[0].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('bzip2', 'gzip')
+ at pytest.mark.skipif(not tlsh_found, reason='tlsh is missing')
+def test_file_list_nested2(differences_nested):
+ expected_diff = \
+ open(data('nested_containers_filelist_expected_diff')).read()
+ assert differences_nested[1].details[0].source1 == 'file list'
+ assert differences_nested[1].details[0].source2 == 'file list'
+ assert differences_nested[1].details[0].unified_diff == expected_diff
diff --git a/tests/data/containers_content_expected_diff b/tests/data/containers_content_expected_diff
new file mode 100644
index 0000000..049140e
--- /dev/null
+++ b/tests/data/containers_content_expected_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-Some content.
++Some content!
diff --git a/tests/data/containers_filelist_expected_diff b/tests/data/containers_filelist_expected_diff
new file mode 100644
index 0000000..68ad9c3
--- /dev/null
+++ b/tests/data/containers_filelist_expected_diff
@@ -0,0 +1,8 @@
+@@ -1,5 +1,5 @@
+-t0/
+-t0/t00/
++t0
++t0/t00
+ t0/t00/test2
+ t0/test1
+ t0/test2.lnk
diff --git a/tests/data/containers_types_expected_diff b/tests/data/containers_types_expected_diff
new file mode 100644
index 0000000..a430c2c
--- /dev/null
+++ b/tests/data/containers_types_expected_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-TarContainer
++LibarchiveContainer
diff --git a/tests/data/nested_containers_filelist_expected_diff b/tests/data/nested_containers_filelist_expected_diff
new file mode 100644
index 0000000..3d410a5
--- /dev/null
+++ b/tests/data/nested_containers_filelist_expected_diff
@@ -0,0 +1,7 @@
+@@ -1,5 +1,5 @@
+ drwxr-xr-x 0 siamezzze (1000) siamezzze (1000) 0 2017-01-21 02:39:53.000000 t0/
+ drwxr-xr-x 0 siamezzze (1000) siamezzze (1000) 0 2017-01-21 02:39:53.000000 t0/t00/
+ -rw-r--r-- 0 siamezzze (1000) siamezzze (1000) 14 2017-01-21 02:39:53.000000 t0/t00/test2
+ lrwxrwxrwx 0 siamezzze (1000) siamezzze (1000) 0 2017-01-21 02:39:53.000000 t0/test2.lnk -> t0/t00/test2
+--rw-r--r-- 0 siamezzze (1000) siamezzze (1000) 1277 2017-01-21 02:39:53.000000 t0/test1
++-rw-r--r-- 0 siamezzze (1000) siamezzze (1000) 1279 2017-01-21 02:39:53.000000 t0/test1
diff --git a/tests/data/nested_containers_types_expected_diff b/tests/data/nested_containers_types_expected_diff
new file mode 100644
index 0000000..329fc94
--- /dev/null
+++ b/tests/data/nested_containers_types_expected_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-GzipContainer
++Bzip2Container
diff --git a/tests/data/test1.tar.bz2 b/tests/data/test1.tar.bz2
new file mode 100644
index 0000000..8499693
Binary files /dev/null and b/tests/data/test1.tar.bz2 differ
diff --git a/tests/data/test1.tar.gz b/tests/data/test1.tar.gz
new file mode 100644
index 0000000..078af17
Binary files /dev/null and b/tests/data/test1.tar.gz differ
diff --git a/tests/data/test3.cpio b/tests/data/test3.cpio
new file mode 100644
index 0000000..046f59b
Binary files /dev/null and b/tests/data/test3.cpio differ
diff --git a/tests/data/test3.tar b/tests/data/test3.tar
new file mode 100644
index 0000000..412be12
Binary files /dev/null and b/tests/data/test3.tar differ
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list