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

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