58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from loguru import logger
|
|
|
|
from pytest_abra import Coordinator, __version__
|
|
from pytest_abra.dir_manager import DirManager
|
|
from pytest_abra.utils import get_session_id
|
|
|
|
|
|
def get_version():
|
|
return __version__
|
|
|
|
|
|
def run():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--version", "-V", action="version", version=get_version(), help="output the version number")
|
|
parser.add_argument("--env_paths", type=str, help="List of loaded env files separated with ;", required=True)
|
|
parser.add_argument("--recipes_dir", type=Path, help="Dir of abra recipes and respective runners", required=True)
|
|
parser.add_argument("--output_dir", type=Path, help="Dir of test outputs", required=True)
|
|
parser.add_argument("--timeout", type=int, help="Set Playwright timeout in ms", default=20_000)
|
|
parser.add_argument("--debug", action="store_true", help="Enable Playwright debug mode")
|
|
parser.add_argument("--resume", action="store_true", help="Re-run the most recent test, skipping passed tests")
|
|
parser.add_argument("--session_id", help="Session dir name (inside output_dir). Overwrites --resume")
|
|
|
|
args = parser.parse_args()
|
|
env_paths = [Path(s) for s in args.env_paths.split(";")]
|
|
|
|
# -------------------------- enable playwright debug ------------------------- #
|
|
|
|
if args.debug:
|
|
os.environ["PWDEBUG"] = "1"
|
|
|
|
# ----------------------------- define session_id ---------------------------- #
|
|
|
|
session_id = get_session_id(args.output_dir, args.resume, args.session_id)
|
|
|
|
# ------------------------------- setup logging ------------------------------ #
|
|
|
|
# todo: move to Coordinator
|
|
DIR = DirManager(output_dir=args.output_dir, session_id=session_id)
|
|
log_file = DIR.RESULTS / "coordinator.log"
|
|
logger.add(log_file)
|
|
|
|
# ---------------------------- initialize and run ---------------------------- #
|
|
|
|
coordinator = Coordinator(
|
|
env_paths=env_paths,
|
|
output_dir=args.output_dir,
|
|
session_id=session_id,
|
|
recipes_dir=args.recipes_dir,
|
|
timeout=args.timeout,
|
|
)
|
|
coordinator.prepare_tests()
|
|
coordinator.run_tests()
|
|
coordinator.combine_html()
|
|
coordinator.collect_traces()
|