Your message dated Sun, 26 Feb 2017 21:21:38 +0000 with message-id <E1ci6GA-0000jl-DU@respighi.debian.org> and subject line unblock diffoscope has caused the Debian Bug report #855608, regarding unblock: diffoscope/78 (preapproval) to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@bugs.debian.org immediately.) -- 855608: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855608 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: unblock: diffoscope/78 (preapproval)
- From: Mattia Rizzolo <mattia@debian.org>
- Date: Mon, 20 Feb 2017 20:13:12 +0100
- Message-id: <[🔎] 20170220191310.l65qoznoevnyvxpe@mapreri.org>
Package: release.debian.org User: release.debian.org@packages.debian.org Usertags: unblock Hi. I'm pondering uploading these changes (+ the changelog entry) in diffoscope. They are just fixing tests to be able to run those in jessie, and a change to improve freebsd compatibility. I've been forced to pick those "fix tests" commits to be able to build the backport I've just uploaded, and I'd rather not have such deltas in my backports. diffoscope/comparators/directory.py | 44 +++++++++++++++++++++++++------------------- diffoscope/comparators/json.py | 2 +- tests/comparators/test_binary.py | 6 +----- tests/comparators/test_device.py | 6 +++--- tests/comparators/test_rpm.py | 4 ++-- tests/comparators/utils/data.py | 12 ++++++++++++ 6 files changed, 44 insertions(+), 30 deletions(-) Thanks for considering. -- regards, Mattia Rizzolo GPG Key: 66AE 2B4A FCCF 3F52 DA18 4D18 4B04 3FCD B944 4540 .''`. more about me: https://mapreri.org : :' : Launchpad user: https://launchpad.net/~mapreri `. `'` Debian QA page: https://qa.debian.org/developer.php?login=mattia `-diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py index d30cb64..1327912 100644 --- a/diffoscope/comparators/directory.py +++ b/diffoscope/comparators/directory.py @@ -45,25 +45,31 @@ def list_files(path): return all_files -class Stat(Command): - @tool_required('stat') - def cmdline(self): - return ['stat', self.path] - - FILE_RE = re.compile(r'^\s*File:.*$') - DEVICE_RE = re.compile(r'Device: [0-9a-f]+h/[0-9]+d\s+') - INODE_RE = re.compile(r'Inode: [0-9]+\s+') - ACCESS_TIME_RE = re.compile(r'^Access: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$') - CHANGE_TIME_RE = re.compile(r'^Change: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$') - - def filter(self, line): - line = line.decode('utf-8') - line = Stat.FILE_RE.sub('', line) - line = Stat.DEVICE_RE.sub('', line) - line = Stat.INODE_RE.sub('', line) - line = Stat.ACCESS_TIME_RE.sub('', line) - line = Stat.CHANGE_TIME_RE.sub('', line) - return line.encode('utf-8') +if os.uname()[0] == 'FreeBSD': + class Stat(Command): + @tool_required('stat') + def cmdline(self): + return ['stat', '-t', '%Y-%m-%d %H:%M:%S', '-f', '%Sp %l %Su %Sg %z %Sm %k %b %#Xf', self.path] +else: + class Stat(Command): + @tool_required('stat') + def cmdline(self): + return ['stat', self.path] + + FILE_RE = re.compile(r'^\s*File:.*$') + DEVICE_RE = re.compile(r'Device: [0-9a-f]+h/[0-9]+d\s+') + INODE_RE = re.compile(r'Inode: [0-9]+\s+') + ACCESS_TIME_RE = re.compile(r'^Access: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$') + CHANGE_TIME_RE = re.compile(r'^Change: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$') + + def filter(self, line): + line = line.decode('utf-8') + line = Stat.FILE_RE.sub('', line) + line = Stat.DEVICE_RE.sub('', line) + line = Stat.INODE_RE.sub('', line) + line = Stat.ACCESS_TIME_RE.sub('', line) + line = Stat.CHANGE_TIME_RE.sub('', line) + return line.encode('utf-8') @tool_required('lsattr') diff --git a/diffoscope/comparators/json.py b/diffoscope/comparators/json.py index d46c830..943ec64 100644 --- a/diffoscope/comparators/json.py +++ b/diffoscope/comparators/json.py @@ -37,7 +37,7 @@ class JSONFile(File): with open(file.path) as f: try: file.parsed = json.load(f, object_pairs_hook=collections.OrderedDict) - except json.JSONDecodeError: + except ValueError: return False return True diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py index aee0e19..3a0e90d 100644 --- a/tests/comparators/test_binary.py +++ b/tests/comparators/test_binary.py @@ -32,7 +32,7 @@ from diffoscope.comparators.utils.file import File from diffoscope.comparators.missing_file import MissingFile from diffoscope.comparators.utils.compare import Xxd -from utils.data import data, init_fixture, get_data +from utils.data import data, init_fixture, get_data, normalize_zeros from utils.tools import skip_unless_tools_exist @@ -46,10 +46,6 @@ TEST_ISO8859_PATH = data('text_iso8859') binary1 = init_fixture(TEST_FILE1_PATH) binary2 = init_fixture(TEST_FILE2_PATH) -def normalize_zeros(s): - # older xxd had one zero less. Make sure there are always 8. - return s.replace('-0000000:', '-00000000:').replace('+0000000:', '+00000000:') - def test_same_content(binary1): assert binary1.has_same_content_as(binary1) is True diff --git a/tests/comparators/test_device.py b/tests/comparators/test_device.py index 4ab1710..9866e40 100644 --- a/tests/comparators/test_device.py +++ b/tests/comparators/test_device.py @@ -23,7 +23,7 @@ from diffoscope.comparators.binary import FilesystemFile from diffoscope.comparators.device import Device from diffoscope.comparators.utils.specialize import specialize -from utils.data import load_fixture, get_data +from utils.data import load_fixture, get_data, normalize_zeros from utils.tools import skip_unless_tools_exist @@ -47,9 +47,9 @@ def test_identification(devnull): @skip_unless_tools_exist('xxd') def test_diff(differences): expected_diff = get_data('device_expected_diff') - assert differences.unified_diff == expected_diff + assert normalize_zeros(differences.unified_diff) == expected_diff @skip_unless_tools_exist('xxd') def test_diff_reverse(differences_reverse): expected_diff = get_data('device_expected_diff_reverse') - assert differences_reverse.unified_diff == expected_diff + assert normalize_zeros(differences_reverse.unified_diff) == expected_diff diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py index 0c13fd2..c374714 100644 --- a/tests/comparators/test_rpm.py +++ b/tests/comparators/test_rpm.py @@ -23,7 +23,7 @@ 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 +from utils.data import load_fixture, data, get_data, normalize_zeros from utils.tools import skip_unless_tools_exist, skip_unless_module_exists from utils.nonexisting import assert_non_existing @@ -92,4 +92,4 @@ def test_fallback_comparison(monkeypatch): assert rpm2.compare(rpm2) is None expected_diff = get_data('rpm_fallback_expected_diff') - assert rpm1.compare(rpm2).unified_diff == expected_diff + assert normalize_zeros(rpm1.compare(rpm2).unified_diff) == expected_diff diff --git a/tests/comparators/utils/data.py b/tests/comparators/utils/data.py index c1d2c2c..fb6a1f5 100644 --- a/tests/comparators/utils/data.py +++ b/tests/comparators/utils/data.py @@ -19,11 +19,16 @@ # along with diffoscope. If not, see <https://www.gnu.org/licenses/>. import os +import re import pytest from diffoscope.comparators.binary import FilesystemFile from diffoscope.comparators.utils.specialize import specialize +re_normalize_zeros = re.compile( + r'^(?P<prefix>[ \-\+])(?P<offset>[0-9a-f]+)(?=: )', re.MULTILINE, +) + def init_fixture(filename): return pytest.fixture( @@ -47,3 +52,10 @@ def get_data(filename): def load_fixture(filename): return init_fixture(data(filename)) + + +def normalize_zeros(s): + # older xxd had one zero less. Make sure there are always 8. + def repl(x): + return '{}{:08x}'.format(x.group('prefix'), int(x.group('offset'), 16)) + return re_normalize_zeros.sub(repl, s)Attachment: signature.asc
Description: PGP signature
--- End Message ---
--- Begin Message ---
- To: 855608-done@bugs.debian.org
- Subject: unblock diffoscope
- From: Ivo De Decker <ivodd@respighi.debian.org>
- Date: Sun, 26 Feb 2017 21:21:38 +0000
- Message-id: <E1ci6GA-0000jl-DU@respighi.debian.org>
Unblocked diffoscope.
--- End Message ---