Commit d5b9daf0 authored by Chris Lamb's avatar Chris Lamb 💬

Merge two overlapping environment variables into DIFFOSCOPE_FAIL_TESTS_ON_MISSING_TOOLS.

parent 6a9faf80
Pipeline #55437 passed with stage
in 15 minutes and 35 seconds
......@@ -9,8 +9,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="apktool zipinfo pedump oggDump ppudump cbfstool otool lipo wasm2wat"
export DIFFOSCOPE_FAIL_TESTS_ON_MISSING_TOOLS="apktool zipinfo pedump oggDump ppudump cbfstool otool lipo wasm2wat"
fi
cp -r tests "$ADTTMP"
......
......@@ -45,28 +45,28 @@ def skipif(*args, **kwargs):
"""
Call `pytest.mark.skipif` with the specified arguments.
As a special-case, if the DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS
environment variable is exported, this alters the behaviour such that a
missing tool is treated as a failed test. For more information on the
rationale here, please see issue #35.
If the DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS environment variable is
exported this alters the behaviour such that a tool listed within this
variable is treated as a failed test instead of being skipped.
For more information on the rationale here, see issue #35.
  • But, this is not how this variable is supposed to work.

    Tools listed in the variable are allowed to be missing and cause the test to be skipped, whereas tools not listed in the variable cause the test to fail.

    I.e., it's a whitelist, not a blacklist.

  • What I'd like to know, is this just a misunderstanding on your part, and so you worded that wrongly, or is this a misunderstanding on my part on understanding your wording? Or is just everybody being confused?

Please register or sign in to reply
"""
if os.environ.get('DIFFOSCOPE_TESTS_FAIL_ON_MISSING_TOOLS', None) != '1':
key = 'DIFFOSCOPE_FAIL_TESTS_ON_MISSING_TOOLS'
val = os.environ.get(key)
if val is None:
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', ())
missing_tools = val.split() + ['/missing'] # special value used in tests
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']
)
msg = "{} ({}={})".format(kwargs['reason'], key, val)
# We cannot simply call pytest.fail here as that would result in a failure
# during the test collection phase instead when the test is actually
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment