diff --git a/.travis.yml b/.travis.yml index 52e0d743..2c329c43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ install: # run tests script: - - ./run-tests + - ./run-tests.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d10d0139..479f8da2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,13 +34,13 @@ The typical workflow should be: `git pull --rebase upstream master` - 0. Make sure all tests are running smoothly (the `run-tests` script also involves pep8 style verification!) + 0. Make sure all tests are running smoothly (the `run-tests.py` script also involves pep8 style verification!) 0. push to your fork and create a [pull request](https://help.github.com/articles/using-pull-requests/) to merge your changes into the codebase. ## Coding and general remaks - * Make sure, that the `run-tests` script exits without error on EVERY commit. To do so, it is HIGHLY RECOMMENDED to add the `pre-commit` script as the git pre-commit hook. For instructions see [pre-commit](../master/pre-commit). - * The Coding style is according to slightly simplified pep8 rules. This is included in the `run-tests` script. If that script runs without error, you should be good to go commit. + * Make sure, that the `run-tests.py` script exits without error on EVERY commit. To do so, it is HIGHLY RECOMMENDED to add the `pre-commit` script as the git pre-commit hook. For instructions see [pre-commit](../master/pre-commit). + * The Coding style is according to slightly simplified pep8 rules. This is included in the `run-tests.py` script. If that script runs without error, you should be good to go commit. * If your implemented feature works as expected you can send the pull request to the master branch. Additional branches should be used only if there are unfinished or experimental features. * Add the GPLv3+ licence notice on top of every new file. If you add a new file you are free to add your name as a author. This will let other people know that you are in charge if there is any trouble with the code. This is only useful if the file you provide adds functionality like a new datareader. Thats why the `__init__.py` files typically do not have a name written. In doubt, the git revision history will always show who added which line. diff --git a/pre-commit b/pre-commit index f7a93aeb..0c39048e 100755 --- a/pre-commit +++ b/pre-commit @@ -1,14 +1,30 @@ #!/bin/bash +# +# This file is part of postpic. +# +# postpic is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# postpic is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with postpic. If not, see . +# +# Copyright Stephan Kuschel, 2014-2015 -# This script is a wrapper around the run-tests script. +# This script is a wrapper around the run-tests.py script. # It is highly recommended to link it as the git pre-commit hook via: # ln -s ../../pre-commit .git/hooks/pre-commit -# The difference to the run-tests script is that this script stashes +# The difference to the run-tests.py script is that this script stashes # unstaged changes before testing (see below). Thus only the changeset to be # commited will be tested. No worries, "git commit -a" will still work ;) -# Stephan Kuschel, 2014 # Stash unstaged changes if and only if(!) necessary (=possible): # if you dont check that you might uninentionally apply an older stash, @@ -18,12 +34,12 @@ # there were no changes, that could be stashed. if git diff-index --quiet HEAD --; then #echo "pre-commit hook without stashing" - ./run-tests + ./run-tests.py exitcode=$? else #echo "pre-commit hook with stashing" git stash -q --keep-index - ./run-tests + ./run-tests.py exitcode=$? git stash pop -q fi diff --git a/run-tests b/run-tests deleted file mode 100755 index 310a46b7..00000000 --- a/run-tests +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# run all tests and pep8 changes of this project. - -# For development, please see pre-commit for -# instructions how to add this as a git pre-commit hook. - -# Stephan Kuschel, 2014 - -exitonfailure () { - if [ $1 -ne 0 ]; then - echo '"./run-tests" failed. Aborting.' - exit $1 - fi -} - -# run actual tests -if command -v nosetests2; then - nosetests2 -else - nosetests -fi -exitonfailure $? - -examples/simpleexample.py -exitonfailure $? - -pep8 postpic --statistics --count --show-source --ignore=W391,E123,E226,E24 --max-line-length=99 -exitonfailure $? - -exit 0 - diff --git a/run-tests.py b/run-tests.py new file mode 100755 index 00000000..dab2d293 --- /dev/null +++ b/run-tests.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python2 +# +# This file is part of postpic. +# +# postpic is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# postpic is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with postpic. If not, see . +# +# Copyright Stephan Kuschel, 2014-2015 + +# run all tests and pep8 verification of this project. +# It is HIGHLY RECOMMENDED to link it as a git pre-commit hook! +# Please see pre-commit for instructions. + +# THIS FILE MUST RUN WITHOUT ERROR ON EVERY COMMIT! + +import os + + +def exitonfailure(exitstatus, cmd=None): + if exitstatus == 0: + print('OK') + else: + print('run-tests.py failed. aborting.') + if cmd is not None: + print('The failing command was:') + print(cmd) + exit(exitstatus) + + +def main(): + # run nose tests + import nose + ex = nose.run() # returns True on success + exitonfailure(not ex, cmd='nosetests') + + cmds = ['pep8 postpic --statistics --count --show-source ' + '--ignore=W391,E123,E226,E24 --max-line-length=99', + os.path.join('examples', 'simpleexample.py')] + for cmd in cmds: + print('===== running next command =====') + print(cmd) + exitonfailure(os.system(cmd), cmd=cmd) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 2ceea47f..c4e00d45 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ description='The open source particle-in-cell post processor.', url='http://github.com/skuschel/postpic', packages=['postpic'], - licence='GPLv3+', + license='GPLv3+', install_requires=['matplotlib', 'numpy>=1.7', 'scipy'], classifiers=[ 'Development Status :: 3 - Alpha',