Skip to content
Snippets Groups Projects
Commit a25b8619 authored by Stephan Kuschel's avatar Stephan Kuschel
Browse files

add --autopep8 option to ./run-tests.py

parent 694ffeda
Branches
Tags
No related merge requests found
......@@ -37,8 +37,22 @@ def exitonfailure(exitstatus, cmd=None):
print(cmd)
exit(exitstatus)
def run_autopep8(args):
import autopep8
if autopep8.__version__ < '1.2':
print('upgrade to autopep8 >= 1.2 (installed: {:})'.format(str(autopep8.__version__)))
exit(1)
autopep8mode = '--in-place' if args.autopep8 == 'fix' else '--diff'
cmd = 'autopep8 -r postpic --ignore-local-config ' + autopep8mode + ' ' \
'--ignore=W391,E123,E226,E24 --max-line-length=99'
print('===== running autopep8 =====')
print('$ ' + cmd)
subprocess.call(cmd, shell=True)
def main():
def run_alltests():
'''
runs all tests on postpic. This function has to exit without error on every commit!
'''
# make sure .pyx sources are up to date and compiled
subprocess.call(os.path.join('.', 'setup.py build_ext --inplace'), shell=True)
# run nose tests
......@@ -56,6 +70,26 @@ def main():
print('$ ' + cmd)
exitonfailure(subprocess.call(cmd, shell=True), cmd=cmd)
def main():
import argparse
parser = argparse.ArgumentParser(description='''
Without arguments this runs all tests
on the postpic codebase.
This script MUST EXIT WITHOUT ERROR on EVERY commit!
''')
parser.add_argument('--autopep8', default='', nargs='?', metavar='fix',
help='''
run "autopep8" on the codebase.
Use "--autopep8" to preview changes. To apply them, use
"--autopep8 fix"
''')
args = parser.parse_args()
if args.autopep8 != '':
run_autopep8(args)
exit()
run_alltests()
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment