diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2017-01-18 10:04:09 -0500 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2017-01-18 13:46:39 -0500 |
commit | 11a6465965af445f2cc2b8eaf91caaa2860b935c (patch) | |
tree | bcd23442e4b5c7ffb3c57924d619e3124805af43 | |
parent | 2b73c9713cd816a6095e40e10d664eff68c8e206 (diff) | |
download | openshift-11a6465965af445f2cc2b8eaf91caaa2860b935c.tar.gz openshift-11a6465965af445f2cc2b8eaf91caaa2860b935c.tar.bz2 openshift-11a6465965af445f2cc2b8eaf91caaa2860b935c.tar.xz openshift-11a6465965af445f2cc2b8eaf91caaa2860b935c.zip |
Adding tox tests for generated code.
-rw-r--r-- | setup.py | 44 | ||||
-rw-r--r-- | tox.ini | 1 |
2 files changed, 44 insertions, 1 deletions
@@ -6,7 +6,7 @@ from __future__ import print_function import os import fnmatch import re - +import subprocess import yaml # Always prefer setuptools over distutils @@ -146,6 +146,47 @@ class OpenShiftAnsiblePylint(PylintCommand): return func(*func_args, **func_kwargs) +class OpenShiftAnsibleGenerateValidation(Command): + ''' Command to run generated module validation''' + description = "Run generated module validation" + user_options = [] + + def initialize_options(self): + ''' initialize_options ''' + pass + + def finalize_options(self): + ''' finalize_options ''' + pass + + # self isn't used but I believe is required when it is called. + # pylint: disable=no-self-use + def run(self): + ''' run command ''' + # find the files that call generate + generate_files = find_files('roles', + ['inventory', + 'test', + 'playbooks', + 'utils'], + None, + 'generate.py') + + # call them with --verify + errors = False + for gen in generate_files: + print('Checking generated module code: {0}'.format(gen)) + try: + subprocess.call([gen, '--verify']) + except subprocess.CalledProcessError as cpe: + print(cpe) + errors = True + + if errors: + print('Found errors while generating module code.') + raise SystemExit(1) + + class UnsupportedCommand(Command): ''' Basic Command to override unsupported commands ''' user_options = [] @@ -188,6 +229,7 @@ setup( 'sdist': UnsupportedCommand, 'lint': OpenShiftAnsiblePylint, 'yamllint': OpenShiftAnsibleYamlLint, + 'generate_validation': OpenShiftAnsibleGenerateValidation, }, packages=[], ) @@ -16,3 +16,4 @@ commands = pylint: python setup.py lint yamllint: python setup.py yamllint unit: nosetests + generate_validation: python setup.py generate_validation |