py3: Switch almost all shebang lines to use `python3`.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2. In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.
One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2. See discussion on the respective previous
commits that made those explicit. There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2017-11-09 08:41:47 +01:00
|
|
|
import argparse
|
2020-02-09 14:47:22 +01:00
|
|
|
import glob
|
2017-04-05 17:47:13 +02:00
|
|
|
import os
|
2020-04-11 12:24:10 +02:00
|
|
|
import pwd
|
2017-04-05 17:47:13 +02:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2020-09-02 21:58:08 +02:00
|
|
|
from typing import Any, Dict, List
|
2017-04-05 17:47:13 +02:00
|
|
|
|
|
|
|
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
sys.path.insert(0, os.path.dirname(TOOLS_DIR))
|
|
|
|
ROOT_DIR = os.path.dirname(TOOLS_DIR)
|
|
|
|
|
|
|
|
# check for the venv
|
|
|
|
from tools.lib import sanity_check
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2017-04-05 17:47:13 +02:00
|
|
|
sanity_check.check_venv(__file__)
|
|
|
|
|
2017-10-18 07:20:41 +02:00
|
|
|
# Import this after we do the sanity_check so it doesn't crash.
|
2020-08-07 01:09:47 +02:00
|
|
|
import orjson
|
2020-06-11 00:54:34 +02:00
|
|
|
from zulint.printer import BOLDRED, CYAN, ENDC, GREEN
|
2020-02-09 15:09:37 +01:00
|
|
|
|
2020-01-26 15:49:01 +01:00
|
|
|
INDEX_JS = 'frontend_tests/zjsunit/index.js'
|
|
|
|
NODE_COVERAGE_PATH = 'var/node-coverage/coverage-final.json'
|
|
|
|
|
2017-04-05 17:47:13 +02:00
|
|
|
USAGE = '''
|
|
|
|
tools/test-js-with-node - to run all tests
|
|
|
|
tools/test-js-with-node util.js activity.js - to run just a couple tests
|
2019-03-09 22:01:13 +01:00
|
|
|
tools/test-js-with-node --coverage - to generate coverage report
|
2017-04-05 17:47:13 +02:00
|
|
|
'''
|
|
|
|
|
2020-02-09 14:47:22 +01:00
|
|
|
# We do not yet require 100% line coverage for these files:
|
|
|
|
EXEMPT_FILES = {
|
|
|
|
'static/js/admin.js',
|
|
|
|
'static/js/archive.js',
|
|
|
|
'static/js/attachments_ui.js',
|
|
|
|
'static/js/avatar.js',
|
|
|
|
'static/js/billing/helpers.js',
|
|
|
|
'static/js/blueslip.js',
|
|
|
|
'static/js/blueslip_stacktrace.ts',
|
2020-02-13 21:34:54 +01:00
|
|
|
'static/js/channel.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/click_handlers.js',
|
|
|
|
'static/js/compose_actions.js',
|
|
|
|
'static/js/composebox_typeahead.js',
|
|
|
|
'static/js/compose_fade.js',
|
|
|
|
'static/js/compose.js',
|
|
|
|
'static/js/condense.js',
|
|
|
|
'static/js/confirm_dialog.js',
|
|
|
|
'static/js/copy_and_paste.js',
|
|
|
|
'static/js/csrf.js',
|
|
|
|
'static/js/debug.js',
|
|
|
|
'static/js/drafts.js',
|
|
|
|
'static/js/echo.js',
|
|
|
|
'static/js/emoji_picker.js',
|
2020-02-21 00:20:39 +01:00
|
|
|
'static/js/emojisets.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/favicon.js',
|
|
|
|
'static/js/feedback_widget.js',
|
|
|
|
'static/js/floating_recipient_bar.js',
|
|
|
|
'static/js/gear_menu.js',
|
|
|
|
'static/js/global.d.ts',
|
|
|
|
'static/js/hashchange.js',
|
|
|
|
'static/js/hbs.d.ts',
|
|
|
|
'static/js/hotkey.js',
|
|
|
|
'static/js/hotspots.js',
|
|
|
|
'static/js/info_overlay.js',
|
|
|
|
'static/js/invite.js',
|
|
|
|
'static/js/lightbox_canvas.js',
|
|
|
|
'static/js/lightbox.js',
|
|
|
|
'static/js/list_util.js',
|
|
|
|
'static/js/loading.js',
|
|
|
|
'static/js/local_message.js',
|
|
|
|
'static/js/localstorage.js',
|
|
|
|
'static/js/message_edit.js',
|
2020-06-07 04:50:31 +02:00
|
|
|
'static/js/message_edit_history.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/message_events.js',
|
|
|
|
'static/js/message_fetch.js',
|
|
|
|
'static/js/message_flags.js',
|
|
|
|
'static/js/message_list_data.js',
|
|
|
|
'static/js/message_list.js',
|
|
|
|
'static/js/message_list_view.js',
|
|
|
|
'static/js/message_live_update.js',
|
|
|
|
'static/js/message_scroll.js',
|
|
|
|
'static/js/message_util.js',
|
|
|
|
'static/js/message_viewport.js',
|
|
|
|
'static/js/muting_ui.js',
|
|
|
|
'static/js/narrow.js',
|
|
|
|
'static/js/navigate.js',
|
|
|
|
'static/js/night_mode.js',
|
|
|
|
'static/js/notifications.js',
|
|
|
|
'static/js/overlays.js',
|
|
|
|
'static/js/padded_widget.js',
|
|
|
|
'static/js/page_params.js',
|
|
|
|
'static/js/panels.js',
|
|
|
|
'static/js/pm_list_dom.js',
|
|
|
|
'static/js/poll_widget.js',
|
|
|
|
'static/js/popovers.js',
|
|
|
|
'static/js/ready.js',
|
|
|
|
'static/js/realm_icon.js',
|
|
|
|
'static/js/realm_logo.js',
|
2020-08-06 21:29:05 +02:00
|
|
|
'static/js/recent_senders.js',
|
2020-06-20 10:17:44 +02:00
|
|
|
'static/js/recent_topics.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/reload.js',
|
|
|
|
'static/js/reload_state.js',
|
|
|
|
'static/js/reminder.js',
|
2020-05-21 00:53:14 +02:00
|
|
|
'static/js/rendered_markdown.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/resize.js',
|
|
|
|
'static/js/rows.js',
|
|
|
|
'static/js/scroll_bar.js',
|
|
|
|
'static/js/search_pill_widget.js',
|
|
|
|
'static/js/sent_messages.js',
|
|
|
|
'static/js/server_events.js',
|
2020-05-12 20:44:05 +02:00
|
|
|
'static/js/dropdown_list_widget.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/settings_account.js',
|
|
|
|
'static/js/settings_bots.js',
|
2020-02-21 14:26:11 +01:00
|
|
|
'static/js/settings_config.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/settings_display.js',
|
|
|
|
'static/js/settings_emoji.js',
|
|
|
|
'static/js/settings_exports.js',
|
|
|
|
'static/js/settings_invites.js',
|
|
|
|
'static/js/settings.js',
|
|
|
|
'static/js/settings_linkifiers.js',
|
|
|
|
'static/js/settings_notifications.js',
|
|
|
|
'static/js/settings_org.js',
|
|
|
|
'static/js/settings_panel_menu.js',
|
|
|
|
'static/js/settings_profile_fields.js',
|
|
|
|
'static/js/settings_sections.js',
|
|
|
|
'static/js/settings_streams.js',
|
|
|
|
'static/js/settings_toggle.js',
|
|
|
|
'static/js/settings_ui.js',
|
|
|
|
'static/js/settings_users.js',
|
|
|
|
'static/js/setup.js',
|
2020-04-04 22:14:34 +02:00
|
|
|
'static/js/spoilers.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/starred_messages.js',
|
|
|
|
'static/js/stream_color.js',
|
|
|
|
'static/js/stream_create.js',
|
|
|
|
'static/js/stream_edit.js',
|
|
|
|
'static/js/stream_list.js',
|
|
|
|
'static/js/stream_muting.js',
|
|
|
|
'static/js/stream_popover.js',
|
|
|
|
'static/js/stream_ui_updates.js',
|
|
|
|
'static/js/submessage.js',
|
|
|
|
'static/js/subs.js',
|
2020-07-08 23:44:01 +02:00
|
|
|
'static/js/message_view_header.js',
|
2020-02-09 14:47:22 +01:00
|
|
|
'static/js/templates.js',
|
|
|
|
'static/js/tictactoe_widget.js',
|
|
|
|
'static/js/timerender.js',
|
|
|
|
'static/js/todo_widget.js',
|
|
|
|
'static/js/topic_list.js',
|
|
|
|
'static/js/topic_zoom.js',
|
|
|
|
'static/js/tutorial.js',
|
|
|
|
'static/js/typing_events.js',
|
|
|
|
'static/js/typing.js',
|
|
|
|
'static/js/ui_init.js',
|
|
|
|
'static/js/ui.js',
|
|
|
|
'static/js/ui_report.js',
|
|
|
|
'static/js/ui_util.js',
|
|
|
|
'static/js/unread_ops.js',
|
|
|
|
'static/js/unread_ui.js',
|
|
|
|
'static/js/upload_widget.js',
|
|
|
|
'static/js/user_status_ui.js',
|
|
|
|
'static/js/zcommand.js',
|
|
|
|
'static/js/zform.js',
|
|
|
|
'static/js/zulip.js',
|
2017-06-07 04:24:39 +02:00
|
|
|
}
|
|
|
|
|
2017-11-09 08:41:47 +01:00
|
|
|
parser = argparse.ArgumentParser(USAGE)
|
2020-09-02 04:49:02 +02:00
|
|
|
parser.add_argument('--coverage',
|
2017-11-09 08:41:47 +01:00
|
|
|
action="store_true",
|
|
|
|
default=False, help='Get coverage report')
|
2020-09-02 04:49:02 +02:00
|
|
|
parser.add_argument('--force',
|
2017-11-09 08:41:47 +01:00
|
|
|
action="store_true",
|
|
|
|
default=False, help='Run tests despite possible problems.')
|
|
|
|
parser.add_argument('args', nargs=argparse.REMAINDER)
|
|
|
|
options = parser.parse_args()
|
2020-01-26 15:57:47 +01:00
|
|
|
individual_files = options.args
|
2017-04-05 17:47:13 +02:00
|
|
|
|
2019-06-20 18:27:09 +02:00
|
|
|
from tools.lib.test_script import assert_provisioning_status_ok
|
2017-04-05 17:47:13 +02:00
|
|
|
|
2019-06-20 18:27:09 +02:00
|
|
|
assert_provisioning_status_ok(options.force)
|
2017-04-05 17:47:13 +02:00
|
|
|
|
2020-04-11 12:24:10 +02:00
|
|
|
def get_dev_host() -> str:
|
|
|
|
# See similar code in dev_settings.py. We only use
|
|
|
|
# this to report where you can find coverage reports.
|
|
|
|
# We duplicate the code here to avoid depending on
|
|
|
|
# Django.
|
|
|
|
|
|
|
|
host = os.getenv('EXTERNAL_HOST')
|
|
|
|
if host is not None:
|
|
|
|
return host
|
|
|
|
|
|
|
|
user_id = os.getuid()
|
|
|
|
user_name = pwd.getpwuid(user_id).pw_name
|
|
|
|
if user_name == "zulipdev":
|
2020-04-24 11:54:55 +02:00
|
|
|
hostname = os.uname()[1].lower()
|
|
|
|
if '.zulipdev.org' not in hostname:
|
|
|
|
hostname += '.zulipdev.org'
|
|
|
|
return hostname + ':9991'
|
2020-04-11 12:24:10 +02:00
|
|
|
else:
|
|
|
|
# For local development environments, we use localhost by
|
|
|
|
# default, via the "zulipdev.com" hostname.
|
|
|
|
return 'zulipdev.com:9991'
|
|
|
|
|
2020-02-09 15:09:37 +01:00
|
|
|
def print_error(msg: str) -> None:
|
|
|
|
print(BOLDRED + 'ERROR:' + ENDC + ' ' + msg)
|
|
|
|
|
2020-09-02 21:58:08 +02:00
|
|
|
def clean_file(orig_fn: str) -> str:
|
|
|
|
fn = orig_fn
|
|
|
|
if not fn.endswith(".js"):
|
|
|
|
fn += ".js"
|
|
|
|
if "frontend_tests/" not in fn:
|
|
|
|
fn = os.path.join(ROOT_DIR, "frontend_tests", "node_tests", fn)
|
|
|
|
fn = os.path.abspath(fn)
|
|
|
|
if not os.path.exists(fn):
|
|
|
|
print(f"Cannot find {orig_fn} ({fn})")
|
|
|
|
sys.exit(1)
|
|
|
|
return fn
|
|
|
|
|
|
|
|
def clean_files(fns: List[str]) -> List[str]:
|
|
|
|
cleaned_files = [clean_file(fn) for fn in fns]
|
|
|
|
return cleaned_files
|
|
|
|
|
2020-01-26 15:57:47 +01:00
|
|
|
def run_tests_via_node_js() -> int:
|
|
|
|
os.environ['TZ'] = 'UTC'
|
|
|
|
|
|
|
|
# The index.js test runner is the real "driver" here, and we launch
|
|
|
|
# with either nyc or node, depending on whether we want coverage
|
|
|
|
# reports. Running under nyc is slower and creates funny
|
|
|
|
# tracebacks, so you generally want to get coverage reports only
|
|
|
|
# after making sure tests will pass.
|
|
|
|
node_tests_cmd = ['node', '--stack-trace-limit=100', INDEX_JS]
|
2020-09-02 21:58:08 +02:00
|
|
|
if individual_files:
|
|
|
|
files = individual_files
|
|
|
|
else:
|
|
|
|
files = sorted(glob.glob("frontend_tests/node_tests/*.js"))
|
|
|
|
|
|
|
|
node_tests_cmd += clean_files(files)
|
2020-01-26 15:57:47 +01:00
|
|
|
if options.coverage:
|
|
|
|
coverage_dir = os.path.join(ROOT_DIR, 'var/node-coverage')
|
|
|
|
|
2020-09-02 22:45:59 +02:00
|
|
|
nyc = os.path.join(ROOT_DIR, "node_modules/.bin/nyc")
|
|
|
|
command = [nyc, "--extension", ".hbs", "--extension", ".ts"]
|
|
|
|
command += ["--report-dir", coverage_dir]
|
|
|
|
command += ["--temp-directory", coverage_dir]
|
|
|
|
command += ["-r=lcov", "-r=json", "-r=text-summary"]
|
2020-01-26 15:57:47 +01:00
|
|
|
command += node_tests_cmd
|
|
|
|
else:
|
|
|
|
# Normal testing, no coverage analysis.
|
|
|
|
# Run the index.js test runner, which runs all the other tests.
|
|
|
|
command = node_tests_cmd
|
|
|
|
|
|
|
|
print('Starting node tests...')
|
|
|
|
|
|
|
|
# If we got this far, we can run the tests!
|
|
|
|
try:
|
|
|
|
ret = subprocess.check_call(command)
|
|
|
|
except OSError:
|
2020-06-10 06:41:04 +02:00
|
|
|
print(f'Bad command: {command}')
|
2020-01-26 15:57:47 +01:00
|
|
|
raise
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
print('\n** Tests failed, PLEASE FIX! **\n')
|
|
|
|
sys.exit(1)
|
|
|
|
return ret
|
2017-04-05 17:47:13 +02:00
|
|
|
|
python: Convert function type annotations to Python 3 style.
Generated by com2ann (slightly patched to avoid also converting
assignment type annotations, which require Python 3.6), followed by
some manual whitespace adjustment, and six fixes for runtime issues:
- def __init__(self, token: Token, parent: Optional[Node]) -> None:
+ def __init__(self, token: Token, parent: "Optional[Node]") -> None:
-def main(options: argparse.Namespace) -> NoReturn:
+def main(options: argparse.Namespace) -> "NoReturn":
-def fetch_request(url: str, callback: Any, **kwargs: Any) -> Generator[Callable[..., Any], Any, None]:
+def fetch_request(url: str, callback: Any, **kwargs: Any) -> "Generator[Callable[..., Any], Any, None]":
-def assert_server_running(server: subprocess.Popen[bytes], log_file: Optional[str]) -> None:
+def assert_server_running(server: "subprocess.Popen[bytes]", log_file: Optional[str]) -> None:
-def server_is_up(server: subprocess.Popen[bytes], log_file: Optional[str]) -> bool:
+def server_is_up(server: "subprocess.Popen[bytes]", log_file: Optional[str]) -> bool:
- method_kwarg_pairs: List[FuncKwargPair],
+ method_kwarg_pairs: "List[FuncKwargPair]",
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-19 03:48:37 +02:00
|
|
|
def check_line_coverage(fn: str, line_coverage: Dict[Any, Any], line_mapping: Dict[Any, Any], log: bool = True) -> bool:
|
2017-06-23 11:53:25 +02:00
|
|
|
missing_lines = []
|
|
|
|
for line in line_coverage:
|
|
|
|
if line_coverage[line] == 0:
|
|
|
|
actual_line = line_mapping[line]
|
|
|
|
missing_lines.append(str(actual_line["start"]["line"]))
|
|
|
|
if missing_lines:
|
|
|
|
if log:
|
2020-06-10 06:41:04 +02:00
|
|
|
print_error(f"{fn} no longer has complete node test coverage")
|
|
|
|
print(" Lines missing coverage: {}".format(", ".join(sorted(missing_lines, key=int))))
|
2017-06-23 11:53:25 +02:00
|
|
|
print()
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2018-04-16 15:46:40 +02:00
|
|
|
def read_coverage() -> Any:
|
2017-06-07 04:24:39 +02:00
|
|
|
coverage_json = None
|
|
|
|
try:
|
2020-08-07 01:09:47 +02:00
|
|
|
with open(NODE_COVERAGE_PATH, "rb") as f:
|
|
|
|
coverage_json = orjson.loads(f.read())
|
2020-04-09 21:51:58 +02:00
|
|
|
except OSError:
|
2017-06-07 04:24:39 +02:00
|
|
|
print(NODE_COVERAGE_PATH + " doesn't exist. Cannot enforce fully covered files.")
|
|
|
|
raise
|
2018-04-16 15:46:40 +02:00
|
|
|
return coverage_json
|
|
|
|
|
|
|
|
def enforce_proper_coverage(coverage_json: Any) -> bool:
|
2020-02-09 14:47:22 +01:00
|
|
|
all_js_files = set(
|
|
|
|
glob.glob('static/js/*.js') +
|
|
|
|
glob.glob('static/js/*.ts') +
|
|
|
|
glob.glob('static/shared/js/*.js') +
|
|
|
|
glob.glob('static/shared/js/*.ts') +
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
glob.glob('static/js/billing/*.js'),
|
2020-02-09 14:47:22 +01:00
|
|
|
)
|
|
|
|
enforce_fully_covered = all_js_files - EXEMPT_FILES
|
|
|
|
|
2018-04-16 15:46:40 +02:00
|
|
|
coverage_lost = False
|
2017-06-07 04:24:39 +02:00
|
|
|
for relative_path in enforce_fully_covered:
|
|
|
|
path = ROOT_DIR + "/" + relative_path
|
|
|
|
if not (path in coverage_json):
|
2020-02-09 15:11:49 +01:00
|
|
|
coverage_lost = True
|
2020-06-10 06:41:04 +02:00
|
|
|
print_error(f"{relative_path} has no node test coverage")
|
2017-06-07 04:24:39 +02:00
|
|
|
continue
|
|
|
|
line_coverage = coverage_json[path]['s']
|
2017-06-18 03:33:34 +02:00
|
|
|
line_mapping = coverage_json[path]['statementMap']
|
2018-04-16 15:46:40 +02:00
|
|
|
if not check_line_coverage(relative_path, line_coverage, line_mapping):
|
|
|
|
coverage_lost = True
|
|
|
|
if coverage_lost:
|
2018-03-25 08:53:40 +02:00
|
|
|
print()
|
2017-06-07 04:24:39 +02:00
|
|
|
print("It looks like your changes lost 100% test coverage in one or more files.")
|
2020-02-09 14:47:22 +01:00
|
|
|
print("Ideally, you should add some tests to restore coverage.")
|
|
|
|
print("A worse option is to update EXEMPT_FILES in `tools/test-js-with-node`.")
|
2017-06-07 04:24:39 +02:00
|
|
|
print("To run this check locally, use `test-js-with-node --coverage`.")
|
2020-02-09 14:47:22 +01:00
|
|
|
print()
|
2017-06-07 04:24:39 +02:00
|
|
|
|
2018-04-16 15:46:40 +02:00
|
|
|
coverage_not_enforced = False
|
2017-06-23 12:04:23 +02:00
|
|
|
for path in coverage_json:
|
2020-02-09 14:47:22 +01:00
|
|
|
relative_path = os.path.relpath(path, ROOT_DIR)
|
|
|
|
if relative_path in EXEMPT_FILES:
|
2017-06-23 12:04:23 +02:00
|
|
|
line_coverage = coverage_json[path]['s']
|
|
|
|
line_mapping = coverage_json[path]['statementMap']
|
2020-02-09 14:47:22 +01:00
|
|
|
if check_line_coverage(relative_path, line_coverage, line_mapping, log=False):
|
2018-04-16 15:46:40 +02:00
|
|
|
coverage_not_enforced = True
|
2020-06-09 00:25:09 +02:00
|
|
|
print_error(f"{relative_path} unexpectedly has 100% line coverage.")
|
2018-04-16 15:46:40 +02:00
|
|
|
|
|
|
|
if coverage_not_enforced:
|
2018-03-25 08:53:40 +02:00
|
|
|
print()
|
2020-02-09 14:47:22 +01:00
|
|
|
print("One or more fully covered files are miscategorized.")
|
|
|
|
print("Remove the file(s) from EXEMPT_FILES in `tools/test-js-with-node`.")
|
2018-04-16 15:46:40 +02:00
|
|
|
|
|
|
|
problems_encountered = (coverage_lost or coverage_not_enforced)
|
|
|
|
return problems_encountered
|
|
|
|
|
2020-01-26 15:57:47 +01:00
|
|
|
ret = run_tests_via_node_js()
|
|
|
|
|
2018-04-16 15:46:40 +02:00
|
|
|
if options.coverage and ret == 0:
|
|
|
|
if not individual_files:
|
|
|
|
coverage_json = read_coverage()
|
|
|
|
problems_encountered = enforce_proper_coverage(coverage_json)
|
|
|
|
if problems_encountered:
|
|
|
|
ret = 1
|
2017-06-23 12:04:23 +02:00
|
|
|
|
2018-03-25 08:53:40 +02:00
|
|
|
print()
|
2017-04-05 17:47:13 +02:00
|
|
|
if ret == 0:
|
2017-06-09 07:17:00 +02:00
|
|
|
if options.coverage:
|
2020-06-09 00:25:09 +02:00
|
|
|
reports_location = f'http://{get_dev_host()}/node-coverage/index.html'
|
2020-04-11 12:24:10 +02:00
|
|
|
print('View coverage reports at ' + CYAN + reports_location + ENDC)
|
|
|
|
|
2020-02-09 15:09:37 +01:00
|
|
|
print(GREEN + "Test(s) passed. SUCCESS!" + ENDC)
|
2017-04-05 17:47:13 +02:00
|
|
|
else:
|
2020-02-09 15:09:37 +01:00
|
|
|
print(BOLDRED + "FAIL - Test(s) failed" + ENDC)
|
2017-04-05 17:47:13 +02:00
|
|
|
|
|
|
|
sys.exit(ret)
|