Loading debian/control +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ Build-Depends: llvm <!nocheck>, lz4 <!nocheck> | liblz4-tool <!nocheck>, mono-utils <!nocheck>, ocaml-nox <!nocheck>, odt2txt <!nocheck>, # oggvideotools [!s390x] <!nocheck>, openssh-client <!nocheck>, Loading diffoscope/comparators/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ class ComparatorManager(object): ('xz.XzFile',), ('apk.ApkFile',), ('odt.OdtFile',), ('ocaml.OcamlInterfaceFile',), ('docx.DocxFile',), ('zip.ZipFile',), ('zip.MozillaZipFile',), Loading diffoscope/comparators/ocaml.py 0 → 100644 +51 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- # # diffoscope: in-depth comparison of files, archives, and directories # # Copyright © 2018 Chris Lamb <lamby@debian.org> # # 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 re from diffoscope.tools import tool_required from diffoscope.difference import Difference from .utils.file import File from .utils.command import Command class Ocamlobjinfo(Command): @tool_required('ocamlobjinfo') def cmdline(self): return ('ocamlobjinfo', self.path) def filter(self, line): val = line.decode('utf-8') if val.startswith('File '): return b'' return line class OcamlInterfaceFile(File): DESCRIPTION = "OCaml interface files" FILE_TYPE_RE = re.compile(r'^OCaml interface file ') def compare_details(self, other, source=None): return [Difference.from_command( Ocamlobjinfo, self.path, other.path, source="ocamlobjinfo", )] diffoscope/external_tools.py +3 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,9 @@ EXTERNAL_TOOLS = { 'debian': 'binutils-multiarch', 'arch': 'binutils', }, 'ocamlobjinfo': { 'debian': 'ocaml-nox', }, 'odt2txt': { 'debian': 'odt2txt', 'arch': 'odt2txt', Loading tests/comparators/test_ocaml.py 0 → 100644 +54 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- # # diffoscope: in-depth comparison of files, archives, and directories # # Copyright © 2018 Chris Lamb <lamby@debian.org> # # 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 from diffoscope.comparators.ocaml import OcamlInterfaceFile from ..utils.data import load_fixture, get_data from ..utils.tools import skip_unless_tools_exist from ..utils.nonexisting import assert_non_existing cmi1 = load_fixture('test1.cmi') cmi2 = load_fixture('test2.cmi') def test_identification(cmi1): assert isinstance(cmi1, OcamlInterfaceFile) @pytest.fixture def differences(cmi1, cmi2): return cmi1.compare(cmi2).details def test_no_differences(cmi1): difference = cmi1.compare(cmi1) assert difference is None @skip_unless_tools_exist('ocamlobjinfo') def test_diff(differences): expected_diff = get_data('ocaml_expected_diff') assert differences[0].unified_diff == expected_diff @skip_unless_tools_exist('ocamlobjinfo') def test_compare_non_existing(monkeypatch, cmi1): assert_non_existing(monkeypatch, cmi1, has_null_source=False) Loading
debian/control +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ Build-Depends: llvm <!nocheck>, lz4 <!nocheck> | liblz4-tool <!nocheck>, mono-utils <!nocheck>, ocaml-nox <!nocheck>, odt2txt <!nocheck>, # oggvideotools [!s390x] <!nocheck>, openssh-client <!nocheck>, Loading
diffoscope/comparators/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ class ComparatorManager(object): ('xz.XzFile',), ('apk.ApkFile',), ('odt.OdtFile',), ('ocaml.OcamlInterfaceFile',), ('docx.DocxFile',), ('zip.ZipFile',), ('zip.MozillaZipFile',), Loading
diffoscope/comparators/ocaml.py 0 → 100644 +51 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- # # diffoscope: in-depth comparison of files, archives, and directories # # Copyright © 2018 Chris Lamb <lamby@debian.org> # # 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 re from diffoscope.tools import tool_required from diffoscope.difference import Difference from .utils.file import File from .utils.command import Command class Ocamlobjinfo(Command): @tool_required('ocamlobjinfo') def cmdline(self): return ('ocamlobjinfo', self.path) def filter(self, line): val = line.decode('utf-8') if val.startswith('File '): return b'' return line class OcamlInterfaceFile(File): DESCRIPTION = "OCaml interface files" FILE_TYPE_RE = re.compile(r'^OCaml interface file ') def compare_details(self, other, source=None): return [Difference.from_command( Ocamlobjinfo, self.path, other.path, source="ocamlobjinfo", )]
diffoscope/external_tools.py +3 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,9 @@ EXTERNAL_TOOLS = { 'debian': 'binutils-multiarch', 'arch': 'binutils', }, 'ocamlobjinfo': { 'debian': 'ocaml-nox', }, 'odt2txt': { 'debian': 'odt2txt', 'arch': 'odt2txt', Loading
tests/comparators/test_ocaml.py 0 → 100644 +54 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- # # diffoscope: in-depth comparison of files, archives, and directories # # Copyright © 2018 Chris Lamb <lamby@debian.org> # # 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 from diffoscope.comparators.ocaml import OcamlInterfaceFile from ..utils.data import load_fixture, get_data from ..utils.tools import skip_unless_tools_exist from ..utils.nonexisting import assert_non_existing cmi1 = load_fixture('test1.cmi') cmi2 = load_fixture('test2.cmi') def test_identification(cmi1): assert isinstance(cmi1, OcamlInterfaceFile) @pytest.fixture def differences(cmi1, cmi2): return cmi1.compare(cmi2).details def test_no_differences(cmi1): difference = cmi1.compare(cmi1) assert difference is None @skip_unless_tools_exist('ocamlobjinfo') def test_diff(differences): expected_diff = get_data('ocaml_expected_diff') assert differences[0].unified_diff == expected_diff @skip_unless_tools_exist('ocamlobjinfo') def test_compare_non_existing(monkeypatch, cmi1): assert_non_existing(monkeypatch, cmi1, has_null_source=False)