diff options
author | kotfu <kotfu@kotfu.net> | 2018-05-28 17:55:28 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-05-28 17:55:28 -0600 |
commit | 9e598bdec40555bc9e5884017c3190c7e8158d7d (patch) | |
tree | 4e6fd6e19e71b6c55cc6a8eb567ef710e5958731 | |
parent | feb7db5c948783fcbadbad8763cb7468dbc36535 (diff) | |
download | cmd2-git-9e598bdec40555bc9e5884017c3190c7e8158d7d.tar.gz |
More updates for #408 and #399
-rw-r--r-- | CONTRIBUTING.md | 13 | ||||
-rwxr-xr-x | setup.py | 2 | ||||
-rw-r--r-- | tasks.py | 44 |
3 files changed, 23 insertions, 36 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b17e167..7f381daf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -265,7 +265,7 @@ invoke livehtml ``` You will be shown the IP address and port number where the documents are now -served. Put that into your web browser and edit away. +served (usually [http://localhost:8000](http://localhost:8000). ### Static Code Analysis @@ -281,15 +281,8 @@ invoke pytest ``` and ensure all tests pass. -#### Measuring code coverage - -Code coverage can be measured as follows: - -```shell -py.test --cov=cmd2 --cov-report=term-missing --cov-report=html -``` - -Then use your web browser of choice to look at the results which are in `<cmd2>/htmlcov/index.html`. +Running the test suite also calculates test code coverage. A summary of coverage +is shown on the screen. A full report is available in `<cmd2>/htmlcov/index.html`. ### Squash Your Commits When you make a pull request, it is preferable for all of your changes to be in one commit. @@ -73,7 +73,7 @@ EXTRAS_REQUIRE = { # install with 'pip install -e .[dev]' 'dev': [ 'pytest', 'pytest-cov', 'tox', 'pylint', 'sphinx', 'sphinx-rtd-theme', - 'sphinx-autobuild','invoke', + 'sphinx-autobuild','invoke', 'twine', ] } @@ -8,15 +8,20 @@ import shutil import invoke # shared function -def rmrf(dirs, verbose=True): - "Silently remove a list of directories" - if isinstance(dirs, str): - dirs = [dirs] +def rmrf(items, verbose=True): + "Silently remove a list of directories or files" + if isinstance(items, str): + items = [items] - for dir_ in dirs: + for item in items: if verbose: - print("Removing {}".format(dir_)) - shutil.rmtree(dir_, ignore_errors=True) + print("Removing {}".format(item)) + shutil.rmtree(item, ignore_errors=True) + # rmtree doesn't remove bare files + try: + os.remove(item) + except FileNotFoundError: + pass # create namespaces @@ -32,14 +37,14 @@ namespace.add_collection(namespace_clean, 'clean') @invoke.task def pytest(context): "Run tests and code coverage using pytest" - context.run("pytest --cov=cmd2 --cov-report=html") + context.run("pytest --cov=cmd2 --cov-report=term --cov-report=html") namespace.add_task(pytest) @invoke.task def pytest_clean(context): - "Remove pytest cache directories" + "Remove pytest cache and code coverage files and directories" #pylint: disable=unused-argument - dirs = ['.pytest-cache', '.cache', 'htmlcov'] + dirs = ['.pytest-cache', '.cache', 'htmlcov', '.coverage'] rmrf(dirs) namespace_clean.add_task(pytest_clean, 'pytest') @@ -56,17 +61,6 @@ def tox_clean(context): rmrf('.tox') namespace_clean.add_task(tox_clean, 'tox') -@invoke.task -def codecov_clean(context): - "Remove code coverage reports" - #pylint: disable=unused-argument - dirs = set() - for name in os.listdir(os.curdir): - if name.startswith('.coverage'): - dirs.add(name) - rmrf(dirs) -namespace_clean.add_task(codecov_clean, 'coverage') - ##### # @@ -158,25 +152,25 @@ def clean_all(context): pass namespace_clean.add_task(clean_all, 'all') -@invoke.task +@invoke.task(pre=[clean_all]) def sdist(context): "Create a source distribution" context.run('python setup.py sdist') namespace.add_task(sdist) -@invoke.task +@invoke.task(pre=[clean_all]) def wheel(context): "Build a wheel distribution" context.run('python setup.py bdist_wheel') namespace.add_task(wheel) -@invoke.task(pre=[clean_all, sdist, wheel]) +@invoke.task(pre=[sdist, wheel]) def pypi(context): "Build and upload a distribution to pypi" context.run('twine upload dist/*') namespace.add_task(pypi) -@invoke.task(pre=[clean_all, sdist, wheel]) +@invoke.task(pre=[sdist, wheel]) def pypi_test(context): "Build and upload a distribution to https://test.pypi.org" context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*') |