mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added code coverage tool for pgAdmin. Fixes #5048.
This commit is contained in:
committed by
Akshay Joshi
parent
a887019337
commit
66f5a40cd9
@@ -20,6 +20,7 @@ import sys
|
||||
import traceback
|
||||
import json
|
||||
import random
|
||||
import coverage
|
||||
|
||||
import unittest
|
||||
|
||||
@@ -48,6 +49,8 @@ if sys.path[0] != root:
|
||||
from pgadmin import create_app
|
||||
import config
|
||||
|
||||
COVERAGE_CONFIG_FILE = os.path.join(CURRENT_PATH, ".coveragerc")
|
||||
|
||||
if config.SERVER_MODE is True:
|
||||
config.SECURITY_RECOVERABLE = True
|
||||
config.SECURITY_CHANGEABLE = True
|
||||
@@ -297,6 +300,8 @@ def add_arguments():
|
||||
help='Skips execution of the test cases of particular package and '
|
||||
'sub-packages'
|
||||
)
|
||||
parser.add_argument('--coverage', nargs='?', const=True, type=bool,
|
||||
default=False, help='Enable code coverage feature')
|
||||
parser.add_argument(
|
||||
'--default_browser',
|
||||
help='Executes the feature test in specific browser'
|
||||
@@ -394,6 +399,7 @@ if __name__ == '__main__':
|
||||
# Failure detected?
|
||||
failure = False
|
||||
test_result = dict()
|
||||
cov = None
|
||||
|
||||
# Set signal handler for cleanup
|
||||
signal_list = dir(signal)
|
||||
@@ -430,6 +436,12 @@ if __name__ == '__main__':
|
||||
node_name = "all"
|
||||
if args['pkg'] is not None:
|
||||
node_name = args['pkg'].split('.')[-1]
|
||||
|
||||
# Start coverage
|
||||
if test_utils.is_coverage_enabled(args):
|
||||
cov = coverage.Coverage(config_file=COVERAGE_CONFIG_FILE)
|
||||
cov.start()
|
||||
|
||||
try:
|
||||
for server in servers_info:
|
||||
print("\n=============Running the test cases for '%s'============="
|
||||
@@ -557,6 +569,15 @@ if __name__ == '__main__':
|
||||
file=sys.stderr
|
||||
)
|
||||
|
||||
# Stop code coverage
|
||||
if test_utils.is_coverage_enabled(args):
|
||||
cov.stop()
|
||||
cov.save()
|
||||
|
||||
# # Print coverage only if coverage args given in command line
|
||||
if test_utils.is_coverage_enabled(args):
|
||||
test_utils.print_and_store_coverage_report(cov)
|
||||
|
||||
print("Please check output in file: %s/regression.log\n" % CURRENT_PATH)
|
||||
|
||||
# Unset environment variable
|
||||
|
||||
Reference in New Issue
Block a user