|
|
@ -14,6 +14,11 @@ from fnmatch import fnmatch
|
|
|
|
from ansible.executor.module_common import REPLACER_WINDOWS
|
|
|
|
from ansible.executor.module_common import REPLACER_WINDOWS
|
|
|
|
from ansible.utils.module_docs import get_docstring, BLACKLIST_MODULES
|
|
|
|
from ansible.utils.module_docs import get_docstring, BLACKLIST_MODULES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
from cStringIO import StringIO
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
|
|
|
|
from StringIO import StringIO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BLACKLIST_DIRS = frozenset(('.git',))
|
|
|
|
BLACKLIST_DIRS = frozenset(('.git',))
|
|
|
|
INDENT_REGEX = re.compile(r'(^[ \t]*)', flags=re.M)
|
|
|
|
INDENT_REGEX = re.compile(r'(^[ \t]*)', flags=re.M)
|
|
|
@ -32,12 +37,18 @@ class Validator(object):
|
|
|
|
"""Reset the test results"""
|
|
|
|
"""Reset the test results"""
|
|
|
|
self.errors = []
|
|
|
|
self.errors = []
|
|
|
|
self.warnings = []
|
|
|
|
self.warnings = []
|
|
|
|
|
|
|
|
self.traces = []
|
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractproperty
|
|
|
|
@abc.abstractproperty
|
|
|
|
def object_name(self):
|
|
|
|
def object_name(self):
|
|
|
|
"""Name of the object we validated"""
|
|
|
|
"""Name of the object we validated"""
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractproperty
|
|
|
|
|
|
|
|
def object_path(self):
|
|
|
|
|
|
|
|
"""Path of the object we validated"""
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
@abc.abstractmethod
|
|
|
|
def validate(self, reset=True):
|
|
|
|
def validate(self, reset=True):
|
|
|
|
"""Run this method to generate the test results"""
|
|
|
|
"""Run this method to generate the test results"""
|
|
|
@ -53,6 +64,8 @@ class Validator(object):
|
|
|
|
|
|
|
|
|
|
|
|
ret = []
|
|
|
|
ret = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for trace in self.traces:
|
|
|
|
|
|
|
|
print(trace.replace(self._root, '').lstrip('/'))
|
|
|
|
for error in self.errors:
|
|
|
|
for error in self.errors:
|
|
|
|
print('ERROR: %s' % error)
|
|
|
|
print('ERROR: %s' % error)
|
|
|
|
ret.append(1)
|
|
|
|
ret.append(1)
|
|
|
@ -299,7 +312,15 @@ class ModuleValidator(Validator):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if self._python_module():
|
|
|
|
if self._python_module():
|
|
|
|
|
|
|
|
sys_stdout = sys.stdout
|
|
|
|
|
|
|
|
sys_stderr = sys.stderr
|
|
|
|
|
|
|
|
sys.stdout = sys.stderr = StringIO()
|
|
|
|
doc, examples, ret = get_docstring(self.path)
|
|
|
|
doc, examples, ret = get_docstring(self.path)
|
|
|
|
|
|
|
|
trace = sys.stdout.getvalue()
|
|
|
|
|
|
|
|
sys.stdout = sys_stdout
|
|
|
|
|
|
|
|
sys.stderr = sys.stderr
|
|
|
|
|
|
|
|
if trace:
|
|
|
|
|
|
|
|
self.traces.append(trace)
|
|
|
|
if not bool(doc):
|
|
|
|
if not bool(doc):
|
|
|
|
self.errors.append('Invalid or no DOCUMENTATION provided')
|
|
|
|
self.errors.append('Invalid or no DOCUMENTATION provided')
|
|
|
|
if not bool(examples):
|
|
|
|
if not bool(examples):
|
|
|
|