test-js-with-puppeteer: Extract code to prepare for puppeteer run.

This commit is contained in:
Puneeth Chaganti 2020-04-17 12:49:39 +05:30 committed by Tim Abbott
parent 572e188b36
commit dd6966b9af
2 changed files with 13 additions and 13 deletions

View File

@ -1,12 +1,15 @@
from typing import Optional, Tuple, Iterable, List from typing import Optional, Tuple, Iterable, List
import os import os
import subprocess
import sys import sys
from distutils.version import LooseVersion from distutils.version import LooseVersion
from version import PROVISION_VERSION from version import PROVISION_VERSION
from scripts.lib.zulip_tools import get_dev_uuid_var_path from scripts.lib.zulip_tools import get_dev_uuid_var_path
import glob import glob
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def get_major_version(v: str) -> int: def get_major_version(v: str) -> int:
return int(v.split('.')[0]) 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'))) test_files = sorted(glob.glob(os.path.join(test_dir, '*.js')))
return test_files 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)

View File

@ -3,7 +3,6 @@ import argparse
import subprocess import subprocess
import sys import sys
import os import os
import glob
import shlex import shlex
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 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 from tools.lib import sanity_check
sanity_check.check_venv(__file__) 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 tools.lib.test_server import test_server_running
from typing import Iterable 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: def run_tests(files: Iterable[str], external_host: str) -> None:
test_dir = os.path.join(ZULIP_PATH, 'frontend_tests/puppeteer_tests') test_dir = os.path.join(ZULIP_PATH, 'frontend_tests/puppeteer_tests')
test_files = find_js_test_files(test_dir, files) 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) sys.exit(ret)
external_host = "zulipdev.com:9981" external_host = "zulipdev.com:9981"
assert_provisioning_status_ok(options.force)
prepare_puppeteer_run()
run_tests(options.tests, external_host) run_tests(options.tests, external_host)
sys.exit(0) sys.exit(0)