Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python nose-ification and with coverage support #3

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ pyshtables.py
/bin/bitbakec
*.swp
tags
.coverage
htmlcov/
44 changes: 28 additions & 16 deletions bin/bitbake-selftest
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,36 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import os
import sys, logging
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))
"""

Prerequirements:
% pip install nose
% pip install coverage

* bitbake-selftest Usage:

* Code coverage analysis

import unittest
try:
import bb
except RuntimeError as exc:
sys.exit(str(exc))
Run all tests with coverage from bitbake top dir:
% ./bin/bitbake-selftest --with-coverage

tests = ["bb.tests.codeparser",
"bb.tests.cow",
"bb.tests.data",
"bb.tests.fetch",
"bb.tests.utils"]
Generate HTML coverage reports under htmlcov (default):
% coverage html && firefox htmlcov/index.html

for t in tests:
__import__(t)
* Has same options as nosetests

unittest.main(argv=["bitbake-selftest"] + tests)
Specify a specific unit testsuite:
% ./bin/bitbake-selftest -v lib/bb/tests/test_data.py

Specify a specific testcase from a test suite:
% ./bin/bitbake-selftest -v lib/bb/tests/test_fetch.py:FetcherNetworkTest.test_gitfetch

"""

import os
import sys
import nose
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + '/lib')

if __name__ == '__main__':
nose.run(argv=sys.argv)
Loading