diff --git a/main.py b/main.py index 84017e0..03f61b0 100644 --- a/main.py +++ b/main.py @@ -32,8 +32,6 @@ RECIPES_DIR = Path("../recipes").resolve() OUTPUT_DIR = Path("./test-output").resolve() -# exit() - subprocess.run( [ "pytest-abra", diff --git a/pytest_abra/cli.py b/pytest_abra/cli.py index 5d1d414..2b1dfa7 100644 --- a/pytest_abra/cli.py +++ b/pytest_abra/cli.py @@ -12,22 +12,15 @@ from pytest_abra.utils import get_datetime_string def run(): parser = argparse.ArgumentParser() parser.add_argument("--env_paths", type=str, help="List of loaded env files separated with ;") - parser.add_argument("--recipes_dir", type=str, help="List of loaded env files separated with ;") - parser.add_argument("--output_dir", type=str, help="List of loaded env files separated with ;") - + parser.add_argument("--recipes_dir", type=Path, help="List of loaded env files separated with ;") + parser.add_argument("--output_dir", type=Path, help="List of loaded env files separated with ;") + 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, only running tests without status 'passed'" - ) + parser.add_argument("--resume", action="store_true", help="Re-run the most recent test, skipping passed tests") args = parser.parse_args() ENV_FILES = [Path(s) for s in args.env_paths.split(";")] - # ----------------------------- define ouptut dir ---------------------------- # - - RECIPES_DIR = Path(args.recipes_dir) - OUTPUT_DIR = Path(args.output_dir) - # -------------------------- enable playwright debug ------------------------- # if args.debug: @@ -43,14 +36,19 @@ def run(): # ------------------------------- setup logging ------------------------------ # - DIR = DirManager(output_dir=OUTPUT_DIR, session_id=session_id) + # todo: move to Coordinator + DIR = DirManager(output_dir=args.output_dir, session_id=session_id) log_file = DIR.RECORDS / "coordinator.log" logger.add(log_file) # ---------------------------- initialize and run ---------------------------- # coordinator = Coordinator( - env_paths_list=ENV_FILES, output_dir=OUTPUT_DIR, session_id=session_id, recipes_dir=RECIPES_DIR + env_paths_list=ENV_FILES, + output_dir=args.output_dir, + session_id=session_id, + recipes_dir=args.recipes_dir, + timeout=args.timeout, ) coordinator.setup_test() coordinator.run_test() diff --git a/pytest_abra/coordinator.py b/pytest_abra/coordinator.py index 8dd6f0f..fb0f422 100644 --- a/pytest_abra/coordinator.py +++ b/pytest_abra/coordinator.py @@ -12,7 +12,9 @@ from pytest_abra.utils import rmtree class Coordinator: - def __init__(self, env_paths_list: list[Path], output_dir: Path, session_id: str, recipes_dir: Path) -> None: + def __init__( + self, env_paths_list: list[Path], output_dir: Path, session_id: str, recipes_dir: Path, timeout: int + ) -> None: # logging out_string = "".join([e.name + "\n" for e in env_paths_list]) out_string += f"output_dir = {output_dir}\n" @@ -22,6 +24,7 @@ class Coordinator: self.RUNNER_DICT = self.create_runner_dict(recipes_dir) self.DIR = DirManager(output_dir=output_dir, session_id=session_id, recipes_dir=recipes_dir) self.ENV = EnvManager(env_paths_list, self.RUNNER_DICT) + self.TIMEOUT = timeout def setup_test(self) -> None: logger.info("calling setup_test()") diff --git a/pytest_abra/runner.py b/pytest_abra/runner.py index ef3ac06..d17b756 100644 --- a/pytest_abra/runner.py +++ b/pytest_abra/runner.py @@ -133,6 +133,9 @@ class Runner: command_arguments.append("--session_id") command_arguments.append(self.DIR.session_id) + command_arguments.append("--timeout") + command_arguments.append(str(self.coordinator.TIMEOUT)) + # artifacts dir from pytest # warning: https://github.com/microsoft/playwright-pytest/issues/111 # --output only works with the given context and page fixture @@ -146,7 +149,7 @@ class Runner: # command_arguments.append("on") # Disable capturing. With -s set, prints will go to console as if pytest is not there. - command_arguments.append("-s") + # command_arguments.append("-s") # headed # command_arguments.append("--headed")