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

tests become windows compatible

instead of `run-tests` there is a `run-tests.py` now,
that runs all the tests on execution. Tested with the latest
pythonxy on windows 7.
parent e42c546e
No related branches found
No related tags found
No related merge requests found
...@@ -24,4 +24,4 @@ install: ...@@ -24,4 +24,4 @@ install:
# run tests # run tests
script: script:
- ./run-tests - ./run-tests.py
...@@ -34,13 +34,13 @@ The typical workflow should be: ...@@ -34,13 +34,13 @@ The typical workflow should be:
`git pull --rebase upstream master` `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. 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 ## 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). * 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` script. If that script runs without error, you should be good to <del>go</del> 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 <del>go</del> 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. * 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. * 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.
......
#!/bin/bash #!/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 <http://www.gnu.org/licenses/>.
#
# 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: # It is highly recommended to link it as the git pre-commit hook via:
# ln -s ../../pre-commit .git/hooks/pre-commit # 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 # unstaged changes before testing (see below). Thus only the changeset to be
# commited will be tested. No worries, "git commit -a" will still work ;) # commited will be tested. No worries, "git commit -a" will still work ;)
# Stephan Kuschel, 2014
# Stash unstaged changes if and only if(!) necessary (=possible): # Stash unstaged changes if and only if(!) necessary (=possible):
# if you dont check that you might uninentionally apply an older stash, # if you dont check that you might uninentionally apply an older stash,
...@@ -18,12 +34,12 @@ ...@@ -18,12 +34,12 @@
# there were no changes, that could be stashed. # there were no changes, that could be stashed.
if git diff-index --quiet HEAD --; then if git diff-index --quiet HEAD --; then
#echo "pre-commit hook without stashing" #echo "pre-commit hook without stashing"
./run-tests ./run-tests.py
exitcode=$? exitcode=$?
else else
#echo "pre-commit hook with stashing" #echo "pre-commit hook with stashing"
git stash -q --keep-index git stash -q --keep-index
./run-tests ./run-tests.py
exitcode=$? exitcode=$?
git stash pop -q git stash pop -q
fi fi
......
#!/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
#!/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 <http://www.gnu.org/licenses/>.
#
# 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()
...@@ -24,7 +24,7 @@ setup(name='postpic', ...@@ -24,7 +24,7 @@ setup(name='postpic',
description='The open source particle-in-cell post processor.', description='The open source particle-in-cell post processor.',
url='http://github.com/skuschel/postpic', url='http://github.com/skuschel/postpic',
packages=['postpic'], packages=['postpic'],
licence='GPLv3+', license='GPLv3+',
install_requires=['matplotlib', 'numpy>=1.7', 'scipy'], install_requires=['matplotlib', 'numpy>=1.7', 'scipy'],
classifiers=[ classifiers=[
'Development Status :: 3 - Alpha', 'Development Status :: 3 - Alpha',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment