mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-25 05:23:58 -07:00
Overhaul additional sanity tests. (#36803)
* Remove unnecessary sys.exit calls. * Add files filtering for code-smell tests. * Enhance test-constraints code-smell test. * Simplify compile sanity test. * Pass paths to importer on stdin. * Pass paths to yamllinter on stdin. * Add work-around for unicode path filtering. * Enhance configure-remoting-ps1 code-smell test. * Enhance integration-aliases code-smell test. * Enhance azure-requirements code-smell test. * Enhance no-illegal-filenames code-smell test.
This commit is contained in:
parent
5b5a79917d
commit
ac1698099d
23 changed files with 153 additions and 208 deletions
|
|
@ -6,6 +6,7 @@ import glob
|
|||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from lib.util import (
|
||||
ApplicationError,
|
||||
|
|
@ -233,6 +234,8 @@ class SanityCodeSmellTest(SanityTest):
|
|||
output = config.get('output')
|
||||
extensions = config.get('extensions')
|
||||
prefixes = config.get('prefixes')
|
||||
files = config.get('files')
|
||||
always = config.get('always')
|
||||
|
||||
if output == 'path-line-column-message':
|
||||
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
|
||||
|
|
@ -243,18 +246,29 @@ class SanityCodeSmellTest(SanityTest):
|
|||
|
||||
paths = sorted(i.path for i in targets.include)
|
||||
|
||||
if always:
|
||||
paths = []
|
||||
|
||||
# short-term work-around for paths being str instead of unicode on python 2.x
|
||||
if sys.version_info[0] == 2:
|
||||
paths = [p.decode('utf-8') for p in paths]
|
||||
|
||||
if extensions:
|
||||
paths = [p for p in paths if os.path.splitext(p)[1] in extensions or (p.startswith('bin/') and '.py' in extensions)]
|
||||
|
||||
if prefixes:
|
||||
paths = [p for p in paths if any(p.startswith(pre) for pre in prefixes)]
|
||||
|
||||
if not paths:
|
||||
if files:
|
||||
paths = [p for p in paths if os.path.basename(p) in files]
|
||||
|
||||
if not paths and not always:
|
||||
return SanitySkipped(self.name)
|
||||
|
||||
data = '\n'.join(paths)
|
||||
|
||||
display.info(data, verbosity=4)
|
||||
if data:
|
||||
display.info(data, verbosity=4)
|
||||
try:
|
||||
stdout, stderr = run_command(args, cmd, data=data, env=env, capture=True)
|
||||
status = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue