diff --git a/.gitignore b/.gitignore index 042fa4e8..612accb7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ tests/data/repo tests/data/repo-krb5-lookaside tests/_composes htmlcov/ +.coverage diff --git a/Makefile b/Makefile index b71bb8a0..b84d7b80 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,10 @@ help: @echo " clean remove python bytecode and temp files" @echo " doc build documentation" @echo " install install program on current system" - @echo " test-data build test data (requirement for running tests)" @echo " test run tests" + @echo " test-coverage run tests and generate a coverage report" + @echo " test-compose run a small teest compose (requires test data)" + @echo " test-data build test data (requirement for running tests)" @echo @echo "Available rel-eng targets are:" @echo " archive create source tarball" @@ -91,13 +93,16 @@ clean: test: - python2 setup.py test - python3 setup.py test + nosetests --exe +test-coverage: + nosetests --exe --with-cov --cov-report html --cov-config tox.ini test-data: ./tests/data/specs/build.sh +test-compose: + cd tests && ./test_compose.sh doc: cd doc; make html diff --git a/doc/contributing.rst b/doc/contributing.rst index ba42ca85..f8f084ee 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -135,22 +135,25 @@ Currently the development workflow for Pungi is on master branch: Testing ======= -You must write unit tests for any code but trivial changes. Any code without -sufficient test coverage may not be merged. +You must write unit tests for any new code (except for trivial changes). Any +code without sufficient test coverage may not be merged. To run all existing tests, suggested method is to use *nosetests*. With additional options, it can generate code coverage. To make sure even tests from executable files are run, don't forget to use the ``--exe`` option. :: - $ nosetests --exe - $ nosetests --exe --with-cov --cov pungi --cov-report html + $ make test + $ make test-cover # Running single test file - $ nosetests --exe test_arch + $ python tests/test_arch.py [TestCase...] In the ``tests/`` directory there is a shell script ``test_compose.sh`` that you can use to try and create a miniature compose on dummy data. The actual -data will be created by running ``make test-data`` in project root. +data will be created by running ``make test-data`` in project root. :: + + $ make test-data + $ make test-commpose This testing compose does not actually use all phases that are available, and there is no checking that the result is correct. It only tells you whether it diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..6a9dd4b0 --- /dev/null +++ b/tox.ini @@ -0,0 +1,7 @@ +[flake8] +exclude = doc/*,*.pyc,*.py~,*.in,*.spec,*.sh,*.rst,setup.py +filename = *.py +ignore = E501 + +[run] +omit = tests/*