* Maintain common settings for coverage settings of parallel and base test suites * Expand FRAPPE_EXCLUSIONS list based on coveralls.io reportversion-14
@@ -551,32 +551,16 @@ def run_tests(context, app=None, module=None, doctype=None, test=(), profile=Fal | |||||
if coverage: | if coverage: | ||||
from coverage import Coverage | from coverage import Coverage | ||||
from frappe.coverage import STANDARD_INCLUSIONS, STANDARD_EXCLUSIONS, FRAPPE_EXCLUSIONS | |||||
# Generate coverage report only for app that is being tested | # Generate coverage report only for app that is being tested | ||||
source_path = os.path.join(get_bench_path(), 'apps', app or 'frappe') | source_path = os.path.join(get_bench_path(), 'apps', app or 'frappe') | ||||
incl = [ | |||||
'*.py', | |||||
] | |||||
omit = [ | |||||
'*.js', | |||||
'*.xml', | |||||
'*.pyc', | |||||
'*.css', | |||||
'*.less', | |||||
'*.scss', | |||||
'*.vue', | |||||
'*.html', | |||||
'*/test_*', | |||||
'*/node_modules/*', | |||||
'*/doctype/*/*_dashboard.py', | |||||
'*/patches/*', | |||||
] | |||||
omit = STANDARD_EXCLUSIONS[:] | |||||
if not app or app == 'frappe': | if not app or app == 'frappe': | ||||
omit.append('*/tests/*') | |||||
omit.append('*/commands/*') | |||||
omit.extend(FRAPPE_EXCLUSIONS) | |||||
cov = Coverage(source=[source_path], omit=omit, include=incl) | |||||
cov = Coverage(source=[source_path], omit=omit, include=STANDARD_INCLUSIONS) | |||||
cov.start() | cov.start() | ||||
ret = frappe.test_runner.main(app, module, doctype, context.verbose, tests=tests, | ret = frappe.test_runner.main(app, module, doctype, context.verbose, tests=tests, | ||||
@@ -0,0 +1,35 @@ | |||||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors | |||||
# MIT License. See LICENSE | |||||
""" | |||||
frappe.coverage | |||||
~~~~~~~~~~~~~~~~ | |||||
Coverage settings for frappe | |||||
""" | |||||
STANDARD_INCLUSIONS = ["*.py"] | |||||
STANDARD_EXCLUSIONS = [ | |||||
'*.js', | |||||
'*.xml', | |||||
'*.pyc', | |||||
'*.css', | |||||
'*.less', | |||||
'*.scss', | |||||
'*.vue', | |||||
'*.html', | |||||
'*/test_*', | |||||
'*/node_modules/*', | |||||
'*/doctype/*/*_dashboard.py', | |||||
'*/patches/*', | |||||
] | |||||
FRAPPE_EXCLUSIONS = [ | |||||
"*/tests/*", | |||||
"*/commands/*", | |||||
"*/frappe/change_log/*", | |||||
"*/frappe/exceptions*", | |||||
"*frappe/setup.py", | |||||
"*/doctype/*/*_dashboard.py", | |||||
"*/patches/*", | |||||
] |
@@ -111,33 +111,16 @@ class ParallelTestRunner(): | |||||
if self.with_coverage: | if self.with_coverage: | ||||
from coverage import Coverage | from coverage import Coverage | ||||
from frappe.utils import get_bench_path | from frappe.utils import get_bench_path | ||||
from frappe.coverage import STANDARD_INCLUSIONS, STANDARD_EXCLUSIONS, FRAPPE_EXCLUSIONS | |||||
# Generate coverage report only for app that is being tested | # Generate coverage report only for app that is being tested | ||||
source_path = os.path.join(get_bench_path(), 'apps', self.app) | source_path = os.path.join(get_bench_path(), 'apps', self.app) | ||||
incl = [ | |||||
'*.py', | |||||
] | |||||
omit = [ | |||||
'*.js', | |||||
'*.xml', | |||||
'*.pyc', | |||||
'*.css', | |||||
'*.less', | |||||
'*.scss', | |||||
'*.vue', | |||||
'*.pyc', | |||||
'*.html', | |||||
'*/test_*', | |||||
'*/node_modules/*', | |||||
'*/doctype/*/*_dashboard.py', | |||||
'*/patches/*', | |||||
] | |||||
omit = STANDARD_EXCLUSIONS[:] | |||||
if self.app == 'frappe': | if self.app == 'frappe': | ||||
omit.append('*/tests/*') | |||||
omit.append('*/commands/*') | |||||
omit.extend(FRAPPE_EXCLUSIONS) | |||||
self.coverage = Coverage(source=[source_path], omit=omit, include=incl) | |||||
self.coverage = Coverage(source=[source_path], omit=omit, include=STANDARD_INCLUSIONS) | |||||
self.coverage.start() | self.coverage.start() | ||||
def save_coverage(self): | def save_coverage(self): | ||||