dev: Expose coverage and built documentation to web.

This makes it much more convenient for developers to access coverage
and built developer documentation.
This commit is contained in:
Tim Abbott 2017-03-23 11:59:24 -07:00
parent 97e844e97c
commit 06492738b5
5 changed files with 27 additions and 8 deletions

View File

@ -42,9 +42,11 @@ cd docs/
make html make html
``` ```
and then opening `file:///path/to/zulip/docs/_build/html/index.html` in and then opening `http://127.0.0.1:9991/docs/index.html` in your
your browser (you can also use e.g. `firefox browser. The raw files are available at
docs/_build/html/index.html` from the root of your Zulip checkout). `file:///path/to/zulip/docs/_build/html/index.html` in your browser
(so you can also use e.g. `firefox docs/_build/html/index.html` from
the root of your Zulip checkout).
If you are adding a new page to the table of contents, you will want If you are adding a new page to the table of contents, you will want
to modify `docs/index.rst` and run `make clean` before `make html`, so to modify `docs/index.rst` and run `make clean` before `make html`, so

View File

@ -240,9 +240,13 @@ typically simulate their behavior using mocks.
- **Coverage** We have 100% line coverage on several of our backend - **Coverage** We have 100% line coverage on several of our backend
modules. You can use the `--coverage` option to generate coverage modules. You can use the `--coverage` option to generate coverage
reports, and new code should have 100% coverage, which generally requires reports, and new code should have 100% coverage, which generally
testing not only the "happy path" but also error handling code and requires testing not only the "happy path" but also error handling
edge cases. Note that `test-backend --coverage` will assert that code and edge cases. It will generate a nice HTML report that you can
view right from your browser (the tool prints the URL where the report
is exposed in your development environment).
Note that `test-backend --coverage` will assert that
various specific files in the project have 100% test coverage and various specific files in the project have 100% test coverage and
throw an error if their coverage has fallen. One of our project goals throw an error if their coverage has fallen. One of our project goals
is to expand that checking to ever-larger parts of the codebase. is to expand that checking to ever-larger parts of the codebase.

View File

@ -292,7 +292,7 @@ if __name__ == "__main__":
print("Printing coverage data") print("Printing coverage data")
cov.report(show_missing=False) cov.report(show_missing=False)
cov.html_report(directory='var/coverage') cov.html_report(directory='var/coverage')
print("HTML report saved to var/coverage") print("HTML report saved; visit at http://127.0.0.1:9991/coverage/index.html")
if full_suite and not failures and options.coverage: if full_suite and not failures and options.coverage:
# Assert that various files have full coverage # Assert that various files have full coverage
for path in enforce_fully_covered: for path in enforce_fully_covered:

View File

@ -386,10 +386,15 @@ def write_instrumentation_reports(full_suite):
assert len(pattern_cnt) > 100 assert len(pattern_cnt) > 100
untested_patterns = set([p for p in pattern_cnt if pattern_cnt[p] == 0]) untested_patterns = set([p for p in pattern_cnt if pattern_cnt[p] == 0])
# We exempt some patterns that are called via Tornado.
exempt_patterns = set([ exempt_patterns = set([
# We exempt some patterns that are called via Tornado.
'api/v1/events', 'api/v1/events',
'api/v1/register', 'api/v1/register',
# We also exempt some development environment debugging
# static content URLs, since the content they point to may
# or may not exist.
'coverage/(?P<path>.*)',
'docs/(?P<path>.*)',
]) ])
untested_patterns -= exempt_patterns untested_patterns -= exempt_patterns

View File

@ -11,10 +11,18 @@ use_prod_static = getattr(settings, 'PIPELINE_ENABLED', False)
static_root = os.path.join(settings.DEPLOY_ROOT, 'prod-static/serve' if use_prod_static else 'static') static_root = os.path.join(settings.DEPLOY_ROOT, 'prod-static/serve' if use_prod_static else 'static')
urls = [ urls = [
url(r'^coverage/(?P<path>.*)$',
serve, {'document_root':
os.path.join(settings.DEPLOY_ROOT, 'var/coverage'),
'show_indexes': True}),
url(r'^docs/(?P<path>.*)$',
serve, {'document_root':
os.path.join(settings.DEPLOY_ROOT, 'docs/_build/html')}),
url(r'^static/(?P<path>.*)$', serve, {'document_root': static_root}), url(r'^static/(?P<path>.*)$', serve, {'document_root': static_root}),
url(r'^devlogin/$', zerver.views.auth.login_page, url(r'^devlogin/$', zerver.views.auth.login_page,
{'template_name': 'zerver/dev_login.html'}, name='zerver.views.auth.login_page'), {'template_name': 'zerver/dev_login.html'}, name='zerver.views.auth.login_page'),
] ]
i18n_urls = [ i18n_urls = [
url(r'^confirmation_key/$', zerver.views.registration.confirmation_key), url(r'^confirmation_key/$', zerver.views.registration.confirmation_key),
] ]