mirror of https://github.com/zulip/zulip.git
Write untested_url_report.txt.
This commit is contained in:
parent
8b13530712
commit
2a37dafcbb
|
@ -225,17 +225,41 @@ def instrument_url(f):
|
||||||
return result
|
return result
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def write_instrumentation_report():
|
def write_instrumentation_reports():
|
||||||
|
# type: () -> None
|
||||||
if INSTRUMENTING:
|
if INSTRUMENTING:
|
||||||
|
calls = INSTRUMENTED_CALLS
|
||||||
var_dir = 'var' # TODO make sure path is robust here
|
var_dir = 'var' # TODO make sure path is robust here
|
||||||
fn = os.path.join(var_dir, 'url_coverage.txt')
|
fn = os.path.join(var_dir, 'url_coverage.txt')
|
||||||
with open(fn, 'w') as f:
|
with open(fn, 'w') as f:
|
||||||
for call in INSTRUMENTED_CALLS:
|
for call in calls:
|
||||||
line = ujson.dumps(call)
|
line = ujson.dumps(call)
|
||||||
f.write(line + '\n')
|
f.write(line + '\n')
|
||||||
|
|
||||||
print('URL coverage report is in %s' % (fn,))
|
print('URL coverage report is in %s' % (fn,))
|
||||||
print('Try running: ./tools/analyze-url-coverage')
|
print('Try running: ./tools/analyze-url-coverage')
|
||||||
|
|
||||||
|
# Find our untested urls.
|
||||||
|
from zproject.urls import urlpatterns
|
||||||
|
untested_patterns = []
|
||||||
|
for pattern in urlpatterns:
|
||||||
|
for call in calls:
|
||||||
|
url = call['url']
|
||||||
|
if url.startswith('/'):
|
||||||
|
url = url[1:]
|
||||||
|
if pattern.regex.match(url):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
untested_patterns.append(pattern.regex.pattern)
|
||||||
|
|
||||||
|
fn = os.path.join(var_dir, 'untested_url_report.txt')
|
||||||
|
with open(fn, 'w') as f:
|
||||||
|
f.write('untested urls\n')
|
||||||
|
for untested_pattern in sorted(untested_patterns):
|
||||||
|
f.write(' %s\n' % (untested_pattern,))
|
||||||
|
print('Untested-url report is in %s' % (fn,))
|
||||||
|
|
||||||
|
|
||||||
class AuthedTestCase(TestCase):
|
class AuthedTestCase(TestCase):
|
||||||
'''
|
'''
|
||||||
WRAPPER_COMMENT:
|
WRAPPER_COMMENT:
|
||||||
|
|
|
@ -9,7 +9,7 @@ from django.test.signals import template_rendered
|
||||||
from zerver.lib.cache import bounce_key_prefix_for_testing
|
from zerver.lib.cache import bounce_key_prefix_for_testing
|
||||||
from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection
|
from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection
|
||||||
from zerver.lib.test_helpers import (
|
from zerver.lib.test_helpers import (
|
||||||
get_all_templates, write_instrumentation_report,
|
get_all_templates, write_instrumentation_reports,
|
||||||
)
|
)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -206,5 +206,5 @@ class Runner(DiscoverRunner):
|
||||||
failed = self.run_suite(suite, fatal_errors=kwargs.get('fatal_errors'))
|
failed = self.run_suite(suite, fatal_errors=kwargs.get('fatal_errors'))
|
||||||
self.teardown_test_environment()
|
self.teardown_test_environment()
|
||||||
if not failed:
|
if not failed:
|
||||||
write_instrumentation_report()
|
write_instrumentation_reports()
|
||||||
return failed
|
return failed
|
||||||
|
|
Loading…
Reference in New Issue