[Git][reproducible-builds/diffoscope][master] 3 commits: tests: allow specifying which tools are known missing using...

Mattia Rizzolo gitlab at salsa.debian.org
Tue May 21 10:53:03 UTC 2019



Mattia Rizzolo pushed to branch master at Reproducible Builds / diffoscope


Commits:
3d742408 by Mattia Rizzolo at 2019-05-21T10:50:42Z
tests: allow specifying which tools are known missing using DIFFOSCOPE_TESTS_MISSING_TOOLS, to override a DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -
f584fa23 by Mattia Rizzolo at 2019-05-21T10:50:52Z
tests: with DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS=1, actually fail only tests that are missing the required tools

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -
c022b028 by Mattia Rizzolo at 2019-05-21T10:52:32Z
Debian: ack some missing tools during autopkgtest

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -


2 changed files:

- debian/tests/pytest
- tests/utils/tools.py


Changes:

=====================================
debian/tests/pytest
=====================================
@@ -10,6 +10,7 @@ fi
 export LIBGUESTFS_MEMSIZE=128
 if [ "$(basename "$0")" = "pytest-with-recommends" ]; then
     export DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS=1
+    export DIFFOSCOPE_TESTS_MISSING_TOOLS="cbfstool procyon otool lipo oggDump wasm2wat"
 fi
 
 cp -r tests "$ADTTMP"


=====================================
tests/utils/tools.py
=====================================
@@ -54,6 +54,16 @@ def skipif(*args, **kwargs):
     if os.environ.get('DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS', None) != '1':
         return pytest.mark.skipif(*args, **kwargs)
 
+    missing_tools = os.environ.get(
+        'DIFFOSCOPE_TESTS_MISSING_TOOLS', ''
+    ).split()
+    missing_tools.append('/missing')  # special value used in tests
+    tools_required = kwargs.get('tools', ())
+    if not tools_required or any(
+        x for x in tools_required if x in missing_tools
+    ):
+        return pytest.mark.skipif(*args, **kwargs)
+
     msg = "{} (DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS=1)".format(
         kwargs['reason']
     )
@@ -63,7 +73,8 @@ def skipif(*args, **kwargs):
     # executed.
     def outer(*args1, **kwargs1):
         def inner(*args2, **kwargs2):
-            return pytest.fail(msg)
+            if args[0]:  # i.e. the condition of the skipif() is True
+                return pytest.fail(msg)
 
         return inner
 
@@ -74,12 +85,13 @@ def skip_unless_tools_exist(*required):
     return skipif(
         tools_missing(*required),
         reason="requires {}".format(" and ".join(required)),
+        tools=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))
+        return skipif(True, reason="requires {}".format(tool), tools=(tool,))
     if callable(actual_ver):
         actual_ver = actual_ver()
     return skipif(
@@ -87,12 +99,13 @@ def skip_if_tool_version_is(tool, actual_ver, target_ver, vcls=LooseVersion):
         reason="requires {} != {} ({} detected)".format(
             tool, target_ver, actual_ver
         ),
+        tools=(tool,),
     )
 
 
 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))
+        return skipif(True, reason="requires {}".format(tool), tools=(tool,))
     if callable(actual_ver):
         actual_ver = actual_ver()
     return skipif(
@@ -100,12 +113,13 @@ def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
         reason="requires {} >= {} ({} detected)".format(
             tool, min_ver, actual_ver
         ),
+        tools=(tool,),
     )
 
 
 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))
+        return skipif(True, reason="requires {}".format(tool), tools=(tool,))
     if callable(actual_ver):
         actual_ver = actual_ver()
     return skipif(
@@ -113,6 +127,7 @@ def skip_unless_tool_is_at_most(tool, actual_ver, max_ver, vcls=LooseVersion):
         reason="requires {} <= {} ({} detected)".format(
             tool, max_ver, actual_ver
         ),
+        tools=(tool,),
     )
 
 
@@ -120,7 +135,7 @@ 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))
+        return skipif(True, reason="requires {}".format(tool), tools=(tool,))
     if callable(actual_ver):
         actual_ver = actual_ver()
     return skipif(
@@ -129,6 +144,7 @@ def skip_unless_tool_is_between(
         reason="requires {} >= {} >= {} ({} detected)".format(
             min_ver, tool, max_ver, actual_ver
         ),
+        tools=(tool,),
     )
 
 
@@ -139,6 +155,7 @@ def skip_if_binutils_does_not_support_x86():
     return skipif(
         'elf64-x86-64' not in get_supported_elf_formats(),
         reason="requires a binutils capable of reading x86-64 binaries",
+        tools=('objdump',),
     )
 
 
@@ -170,6 +187,7 @@ def skip_unless_module_exists(name):
     return skipif(
         module_is_not_importable(name),
         reason="requires {} module".format(name),
+        tools=('{}_module'.format(name)),
     )
 
 



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/2e111824754b0bb076adece41c2e18f821a24b30...c022b028a9b83da61b47f158bef2b086a189a7f3

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/2e111824754b0bb076adece41c2e18f821a24b30...c022b028a9b83da61b47f158bef2b086a189a7f3
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/20190521/4fcdd354/attachment.html>


More information about the rb-commits mailing list