Browse Source

refactor: Maintain common list for Frappe Coverage settings

* Maintain common settings for coverage settings of parallel and base test suites
* Expand FRAPPE_EXCLUSIONS list based on coveralls.io report
version-14
Gavin D'souza 4 years ago
parent
commit
2ac1c45c66
3 changed files with 43 additions and 41 deletions
  1. +4
    -20
      frappe/commands/utils.py
  2. +35
    -0
      frappe/coverage.py
  3. +4
    -21
      frappe/parallel_test_runner.py

+ 4
- 20
frappe/commands/utils.py View File

@@ -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,


+ 35
- 0
frappe/coverage.py View File

@@ -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/*",
]

+ 4
- 21
frappe/parallel_test_runner.py View File

@@ -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):


Loading…
Cancel
Save