Add python.py coverage injector for ansible-test.
This can be used to run Python scripts from the repository with the
correct interpreter and allow collection of code coverage.
Useful for testing contrib inventory scripts.
(cherry picked from commit 45b5685037
)
This commit is contained in:
parent
f5c9977771
commit
d779f25fa1
2 changed files with 17 additions and 0 deletions
|
@ -110,6 +110,8 @@ def main():
|
|||
args, env, require_cwd = cover()
|
||||
else:
|
||||
args, env = runner()
|
||||
elif os.path.basename(__file__) == 'python.py':
|
||||
args, env = python() # run arbitrary python commands using the correct python and with optional code coverage
|
||||
else:
|
||||
args, env = injector()
|
||||
|
||||
|
@ -142,6 +144,20 @@ def main():
|
|||
raise
|
||||
|
||||
|
||||
def python():
|
||||
"""
|
||||
:rtype: list[str], dict[str, str]
|
||||
"""
|
||||
if config.coverage_file:
|
||||
args, env = coverage_command()
|
||||
else:
|
||||
args, env = [config.python_interpreter], os.environ.copy()
|
||||
|
||||
args += config.arguments[1:]
|
||||
|
||||
return args, env
|
||||
|
||||
|
||||
def injector():
|
||||
"""
|
||||
:rtype: list[str], dict[str, str]
|
||||
|
|
1
test/runner/injector/python.py
Symbolic link
1
test/runner/injector/python.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
injector.py
|
Loading…
Reference in a new issue