[Git][reproducible-builds/diffoscope][master] 3 commits: Update "requires foo" module test messages to clarify that they are regarding Python modules.
Chris Lamb
gitlab at salsa.debian.org
Sat Sep 7 12:55:34 UTC 2019
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
73ffcdc9 by Chris Lamb at 2019-09-07T12:25:02Z
Update "requires foo" module test messages to clarify that they are regarding Python modules.
- - - - -
e5b82689 by Chris Lamb at 2019-09-07T12:25:50Z
When skipping tests due to the lack of installed tool, print the package that may provide it.
- - - - -
f7868ee0 by Chris Lamb at 2019-09-07T12:55:16Z
Build OCaml test input files on-demand rather than shipping them with the package in order to prevent test failures with OCaml 4.08 (Closes: Debian:#939386, reproducible-builds/diffoscope#67)
This is related to reproducible-builds/diffoscope#66
- - - - -
5 changed files:
- tests/comparators/test_ocaml.py
- tests/data/ocaml_expected_diff
- − tests/data/test1.cmi
- − tests/data/test2.cmi
- tests/utils/tools.py
Changes:
=====================================
tests/comparators/test_ocaml.py
=====================================
@@ -21,13 +21,32 @@ import pytest
import subprocess
from diffoscope.comparators.ocaml import OcamlInterfaceFile
+from diffoscope.comparators.binary import FilesystemFile
+from diffoscope.comparators.utils.specialize import specialize
from ..utils.data import load_fixture, get_data
from ..utils.tools import skip_unless_tool_is_at_least
from ..utils.nonexisting import assert_non_existing
-cmi1 = load_fixture('test1.cmi')
-cmi2 = load_fixture('test2.cmi')
+
+def ocaml_fixture(prefix):
+ @pytest.fixture
+ def cmi(tmpdir):
+ input_ = str(tmpdir.join('{}.mli'.format(prefix)))
+ output = str(tmpdir.join('{}.cmi'.format(prefix)))
+
+ with open(input_, 'w') as f:
+ pass
+
+ subprocess.check_call(('ocamlc', '-c', input_))
+
+ return specialize(FilesystemFile(output))
+
+ return cmi
+
+
+cmi1 = ocaml_fixture('test1')
+cmi2 = ocaml_fixture('test2')
def ocaml_version():
=====================================
tests/data/ocaml_expected_diff
=====================================
@@ -1,15 +1,8 @@
-@@ -1,5 +1,14 @@
- Unit name: Uchar
+@@ -1,5 +1,5 @@
+-Unit name: Test1
++Unit name: Test2
Interfaces imported:
- 84838649f9351de166bfa8b9f2c84db4 Uchar
+- b5f47409a5d1c32a864ea3d2fbed44db Test1
++ 9ee19396ca59dbe57206a9a88d98a7d5 Test2
07ea9e20ae94d62c35cfecbe7d66d3ea Pervasives
cbd5f2d6b649925222e1e9fb63b89db6 CamlinternalFormatBasics
-+Cmt unit name: Uchar
-+Cmt interfaces imported:
-+ cbd5f2d6b649925222e1e9fb63b89db6 CamlinternalFormatBasics
-+ 07ea9e20ae94d62c35cfecbe7d66d3ea Pervasives
-+ 84838649f9351de166bfa8b9f2c84db4 Uchar
-+Source file: uchar.mli
-+Compilation flags: ../ocamlc -strict-sequence -absname -w +a-4-9-41-42-44-45-48 -g -warn-error A -bin-annot -nostdlib -safe-string -strict-formats -c uchar.mli
-+Load path:
-+cmt interface digest: 84838649f9351de166bfa8b9f2c84db4
=====================================
tests/data/test1.cmi deleted
=====================================
Binary files a/tests/data/test1.cmi and /dev/null differ
=====================================
tests/data/test2.cmi deleted
=====================================
Binary files a/tests/data/test2.cmi and /dev/null differ
=====================================
tests/utils/tools.py
=====================================
@@ -27,6 +27,8 @@ import subprocess
from distutils.spawn import find_executable
from distutils.version import LooseVersion
+from diffoscope.tools import get_package_provider
+
def file_version():
return (
@@ -89,7 +91,7 @@ def skipif(*args, **kwargs):
def skip_unless_tools_exist(*required):
return skipif(
tools_missing(*required),
- reason="requires {}".format(" and ".join(required)),
+ reason=reason(*required),
tools=required,
check_env_for_missing_tools=True,
)
@@ -97,7 +99,7 @@ def skip_unless_tools_exist(*required):
def skip_if_tool_version_is(tool, actual_ver, target_ver, vcls=LooseVersion):
if tools_missing(tool):
- return skipif(True, reason="requires {}".format(tool), tools=(tool,))
+ return skipif(True, reason=reason(tool), tools=(tool,))
if callable(actual_ver):
actual_ver = actual_ver()
return skipif(
@@ -111,13 +113,13 @@ def skip_if_tool_version_is(tool, actual_ver, target_ver, vcls=LooseVersion):
def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
if tools_missing(tool) and module_is_not_importable(tool):
- return skipif(True, reason="requires {}".format(tool), tools=(tool,))
+ return skipif(True, reason=reason(tool), tools=(tool,))
if callable(actual_ver):
actual_ver = actual_ver()
return skipif(
vcls(str(actual_ver)) < vcls(str(min_ver)),
- reason="requires {} >= {} ({} detected)".format(
- tool, min_ver, actual_ver
+ reason="{} >= {} ({} detected)".format(
+ reason(tool), min_ver, actual_ver
),
tools=(tool,),
)
@@ -125,13 +127,13 @@ def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
def skip_unless_tool_is_at_most(tool, actual_ver, max_ver, vcls=LooseVersion):
if tools_missing(tool) and module_is_not_importable(tool):
- return skipif(True, reason="requires {}".format(tool), tools=(tool,))
+ return skipif(True, reason=reason(tool), tools=(tool,))
if callable(actual_ver):
actual_ver = actual_ver()
return skipif(
vcls(str(actual_ver)) > vcls(str(max_ver)),
- reason="requires {} <= {} ({} detected)".format(
- tool, max_ver, actual_ver
+ reason="{} <= {} ({} detected)".format(
+ reason(tool), max_ver, actual_ver
),
tools=(tool,),
)
@@ -141,14 +143,14 @@ def skip_unless_tool_is_between(
tool, actual_ver, min_ver, max_ver, vcls=LooseVersion
):
if tools_missing(tool):
- return skipif(True, reason="requires {}".format(tool), tools=(tool,))
+ return skipif(True, reason=reason(tool), tools=(tool,))
if callable(actual_ver):
actual_ver = actual_ver()
return skipif(
(vcls(str(actual_ver)) < vcls(str(min_ver)))
or (vcls(str(actual_ver)) > vcls(str(max_ver))),
- reason="requires {} >= {} >= {} ({} detected)".format(
- min_ver, tool, max_ver, actual_ver
+ reason="{} min {} >= {} ({} detected)".format(
+ reason(tool), min_ver, max_ver, actual_ver
),
tools=(tool,),
)
@@ -194,10 +196,24 @@ def module_is_not_importable(x):
def skip_unless_module_exists(name):
return skipif(
module_is_not_importable(name),
- reason="requires {} module".format(name),
+ reason="requires {} Python module".format(name),
tools=('{}_module'.format(name)),
)
def skip_unless_file_version_is_at_least(version):
return skip_unless_tool_is_at_least('file', file_version, version)
+
+
+def reason(*tools):
+ xs = []
+
+ for x in tools:
+ provider = get_package_provider(x)
+ if provider is None:
+ xs.append(x)
+ continue
+
+ xs.append('{} (try installing {})'.format(x, provider))
+
+ return "requires {}".format(" and ".join(xs))
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/4321d375903e2876a0e93e3e229adceba6a7e0d6...f7868ee0898edff15e29cb4e6e878f472a6ee186
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/4321d375903e2876a0e93e3e229adceba6a7e0d6...f7868ee0898edff15e29cb4e6e878f472a6ee186
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20190907/4335083e/attachment.html>
More information about the rb-commits
mailing list