Skip to content

Commit

Permalink
tests become windows compatible
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skuschel committed Jan 21, 2015
1 parent e42c546 commit 3389180
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ install:

# run tests
script:
- ./run-tests
- ./run-tests.py
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <del>go</del> 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 <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.
* 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.

Expand Down
26 changes: 21 additions & 5 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -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 <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:

# 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,
Expand All @@ -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
Expand Down
32 changes: 0 additions & 32 deletions run-tests

This file was deleted.

56 changes: 56 additions & 0 deletions run-tests.py
Original file line number Diff line number Diff line change
@@ -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 <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()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3389180

Please sign in to comment.