mirror of https://github.com/zulip/zulip.git
test-js-with-puppeteer: Extract code to prepare for puppeteer run.
This commit is contained in:
parent
572e188b36
commit
dd6966b9af
|
@ -1,12 +1,15 @@
|
|||
from typing import Optional, Tuple, Iterable, List
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
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
|
||||
|
||||
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
def get_major_version(v: str) -> int:
|
||||
return int(v.split('.')[0])
|
||||
|
||||
|
@ -95,3 +98,10 @@ def find_js_test_files(test_dir: str, files: Iterable[str]) -> List[str]:
|
|||
test_files = sorted(glob.glob(os.path.join(test_dir, '*.js')))
|
||||
|
||||
return test_files
|
||||
|
||||
def prepare_puppeteer_run() -> None:
|
||||
os.chdir(ZULIP_PATH)
|
||||
subprocess.check_call(['node', 'node_modules/puppeteer/install.js'])
|
||||
os.makedirs('var/puppeteer', exist_ok=True)
|
||||
for f in glob.glob('var/puppeteer/puppeteer-failure*.png'):
|
||||
os.remove(f)
|
||||
|
|
|
@ -3,7 +3,6 @@ import argparse
|
|||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import glob
|
||||
import shlex
|
||||
|
||||
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
@ -38,22 +37,11 @@ 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, find_js_test_files
|
||||
from tools.lib.test_script import assert_provisioning_status_ok, find_js_test_files, prepare_puppeteer_run
|
||||
from tools.lib.test_server import test_server_running
|
||||
|
||||
from typing import Iterable
|
||||
|
||||
assert_provisioning_status_ok(options.force)
|
||||
|
||||
os.chdir(ZULIP_PATH)
|
||||
|
||||
subprocess.check_call(['node', 'node_modules/puppeteer/install.js'])
|
||||
|
||||
os.makedirs('var/puppeteer', exist_ok=True)
|
||||
|
||||
for f in glob.glob('var/puppeteer/puppeteer-failure*.png'):
|
||||
os.remove(f)
|
||||
|
||||
def run_tests(files: Iterable[str], external_host: str) -> None:
|
||||
test_dir = os.path.join(ZULIP_PATH, 'frontend_tests/puppeteer_tests')
|
||||
test_files = find_js_test_files(test_dir, files)
|
||||
|
@ -87,5 +75,7 @@ def run_tests(files: Iterable[str], external_host: str) -> None:
|
|||
sys.exit(ret)
|
||||
|
||||
external_host = "zulipdev.com:9981"
|
||||
assert_provisioning_status_ok(options.force)
|
||||
prepare_puppeteer_run()
|
||||
run_tests(options.tests, external_host)
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Reference in New Issue