Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Reproducible Builds
diffoscope
Compare revisions
b99b03d581deb97d95a250ae5432758acf89f6f6...d5b9daf05dfd3b3e4cc8dd6f7f8c2fbbfcd62cc0
Commits (2)
Add some explicit return values to appease pylint, etc.
· 6a9faf80
Chris Lamb
authored
Jul 12, 2019
6a9faf80
Merge two overlapping environment variables into DIFFOSCOPE_FAIL_TESTS_ON_MISSING_TOOLS.
· d5b9daf0
Chris Lamb
authored
Jul 12, 2019
d5b9daf0
Hide whitespace changes
Inline
Side-by-side
debian/tests/pytest
View file @
d5b9daf0
...
...
@@ -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
"
...
...
tests/utils/tools.py
View file @
d5b9daf0
...
...
@@ -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.
"""
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
...
...
@@ -75,6 +75,7 @@ def skipif(*args, **kwargs):
def
inner
(
*
args2
,
**
kwargs2
):
if
args
[
0
]:
# i.e. the condition of the skipif() is True
return
pytest
.
fail
(
msg
)
return
None
return
inner
...
...
@@ -182,6 +183,8 @@ def module_is_not_importable(x):
# import ``debian`` so we must handle that failing.
return
True
return
False
def
skip_unless_module_exists
(
name
):
return
skipif
(
...
...