tools: Extract code to find js test files to test_script.

This commit is contained in:
Puneeth Chaganti 2020-04-17 12:21:06 +05:30 committed by Tim Abbott
parent 26e199035d
commit 572e188b36
3 changed files with 23 additions and 27 deletions

View File

@ -66,7 +66,7 @@ sys.path.insert(0, ZULIP_PATH)
from tools.lib import sanity_check
sanity_check.check_venv(__file__)
from tools.lib.test_script import assert_provisioning_status_ok
from tools.lib.test_script import assert_provisioning_status_ok, find_js_test_files
from tools.lib.test_server import test_server_running
from typing import Iterable, List
@ -88,18 +88,7 @@ def reset_database() -> None:
def run_tests(files: Iterable[str], external_host: str) -> None:
test_dir = os.path.join(ZULIP_PATH, 'frontend_tests/casper_tests')
test_files = []
for file in files:
for file_name in os.listdir(test_dir):
if file_name.startswith(file):
file = file_name
break
if not os.path.exists(file):
file = os.path.join(test_dir, file)
test_files.append(os.path.abspath(file))
if not test_files:
test_files = sorted(glob.glob(os.path.join(test_dir, '*.js')))
test_files = find_js_test_files(test_dir, files)
# 10-admin.js is too flaky!
if options.skip_flaky:

View File

@ -1,10 +1,11 @@
from typing import Optional, Tuple
from typing import Optional, Tuple, Iterable, List
import os
import sys
from distutils.version import LooseVersion
from version import PROVISION_VERSION
from scripts.lib.zulip_tools import get_dev_uuid_var_path
import glob
def get_major_version(v: str) -> int:
return int(v.split('.')[0])
@ -77,3 +78,20 @@ def assert_provisioning_status_ok(force: bool) -> None:
print(msg)
print('If you really know what you are doing, use --force to run anyway.')
sys.exit(1)
def find_js_test_files(test_dir: str, files: Iterable[str]) -> List[str]:
test_files = []
for file in files:
for file_name in os.listdir(test_dir):
if file_name.startswith(file):
file = file_name
break
if not os.path.exists(file):
file = os.path.join(test_dir, file)
test_files.append(os.path.abspath(file))
if not test_files:
test_files = sorted(glob.glob(os.path.join(test_dir, '*.js')))
return test_files

View File

@ -38,7 +38,7 @@ sys.path.insert(0, ZULIP_PATH)
from tools.lib import sanity_check
sanity_check.check_venv(__file__)
from tools.lib.test_script import assert_provisioning_status_ok
from tools.lib.test_script import assert_provisioning_status_ok, find_js_test_files
from tools.lib.test_server import test_server_running
from typing import Iterable
@ -56,18 +56,7 @@ for f in glob.glob('var/puppeteer/puppeteer-failure*.png'):
def run_tests(files: Iterable[str], external_host: str) -> None:
test_dir = os.path.join(ZULIP_PATH, 'frontend_tests/puppeteer_tests')
test_files = []
for file in files:
for file_name in os.listdir(test_dir):
if file_name.startswith(file):
file = file_name
break
if not os.path.exists(file):
file = os.path.join(test_dir, file)
test_files.append(os.path.abspath(file))
if not test_files:
test_files = sorted(glob.glob(os.path.join(test_dir, '*.js')))
test_files = find_js_test_files(test_dir, files)
def run_tests() -> int:
ret = 1