Intercept code-smell tests using subprocess.
Some code-smell sanity tests for ansible-base use subprocess to invoke ansible commands. Intercept these commands to make sure the correct script and python version are used.
This commit is contained in:
parent
d30fc6c0b3
commit
6c2be04b6f
4 changed files with 11 additions and 1 deletions
|
@ -34,6 +34,7 @@ from ..util import (
|
|||
|
||||
from ..util_common import (
|
||||
run_command,
|
||||
intercept_command,
|
||||
handle_layout_messages,
|
||||
)
|
||||
|
||||
|
@ -690,6 +691,7 @@ class SanityCodeSmellTest(SanityTest):
|
|||
self.files = self.config.get('files') # type: t.List[str]
|
||||
self.text = self.config.get('text') # type: t.Optional[bool]
|
||||
self.ignore_self = self.config.get('ignore_self') # type: bool
|
||||
self.intercept = self.config.get('intercept') # type: bool
|
||||
|
||||
self.__all_targets = self.config.get('all_targets') # type: bool
|
||||
self.__no_targets = self.config.get('no_targets') # type: bool
|
||||
|
@ -702,6 +704,7 @@ class SanityCodeSmellTest(SanityTest):
|
|||
self.files = []
|
||||
self.text = None # type: t.Optional[bool]
|
||||
self.ignore_self = False
|
||||
self.intercept = False
|
||||
|
||||
self.__all_targets = False
|
||||
self.__no_targets = True
|
||||
|
@ -805,7 +808,11 @@ class SanityCodeSmellTest(SanityTest):
|
|||
display.info(data, verbosity=4)
|
||||
|
||||
try:
|
||||
stdout, stderr = run_command(args, cmd, data=data, env=env, capture=True)
|
||||
if self.intercept:
|
||||
stdout, stderr = intercept_command(args, cmd, target_name='sanity.%s' % self.name, data=data, env=env, capture=True, disable_coverage=True)
|
||||
else:
|
||||
stdout, stderr = run_command(args, cmd, data=data, env=env, capture=True)
|
||||
|
||||
status = 0
|
||||
except SubprocessError as ex:
|
||||
stdout = ex.stdout
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"intercept": true,
|
||||
"prefixes": [
|
||||
"changelogs/fragments/"
|
||||
],
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"intercept": true,
|
||||
"disabled": true,
|
||||
"no_targets": true,
|
||||
"output": "path-line-column-message"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"intercept": true,
|
||||
"disabled": true,
|
||||
"all_targets": true,
|
||||
"output": "path-message"
|
||||
|
|
Loading…
Add table
Reference in a new issue