How to use the ptr.StepName.tests_run function in ptr

To help you get started, we’ve selected a few ptr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebookincubator / ptr / ptr.py View on Github external
mypy_exe = venv_path / bin_dir / f"mypy{exe}"
    pip_exe = venv_path / bin_dir / f"pip{exe}"
    pylint_exe = venv_path / bin_dir / f"pylint{exe}"
    pyre_exe = venv_path / bin_dir / f"pyre{exe}"
    config = tests_to_run[setup_py_path]

    steps = (
        step(
            StepName.pip_install,
            True,
            _generate_install_cmd(str(pip_exe), str(setup_py_path.parent), config),
            f"Installing {setup_py_path} + deps",
            config["test_suite_timeout"],
        ),
        step(
            StepName.tests_run,
            bool("test_suite" in config and config["test_suite"]),
            _generate_test_suite_cmd(coverage_exe, config),
            f"Running {config.get('test_suite', '')} tests via coverage",
            config["test_suite_timeout"],
        ),
        step(
            StepName.analyze_coverage,
            bool(
                "required_coverage" in config
                and config["required_coverage"]
                and len(config["required_coverage"]) > 0
            ),
            (str(coverage_exe), "report", "-m"),
            f"Analyzing coverage report for {setup_py_path}",
            config["test_suite_timeout"],
        ),
github facebookincubator / ptr / ptr.py View on Github external
a_test_result = None
        # Skip test if disabled
        if not a_step.run_condition:
            LOG.info(f"Not running {a_step.log_message} step")
            continue

        LOG.info(a_step.log_message)
        stdout = b""
        steps_ran += 1
        try:
            if a_step.cmds:
                LOG.debug(f"CMD: {' '.join(a_step.cmds)}")

                # If we're running tests and we want warnings to be errors
                step_env = env
                if a_step.step_name == StepName.tests_run and error_on_warnings:
                    step_env = env.copy()
                    step_env["PYTHONWARNINGS"] = "error"
                    LOG.debug(f"Setting PYTHONWARNINGS to error: {step_env}")

                stdout, _stderr = await _gen_check_output(
                    a_step.cmds, a_step.timeout, env=step_env, cwd=setup_py_path.parent
                )
            else:
                LOG.debug(f"Skipping running a cmd for {a_step} step")
        except CalledProcessError as cpe:
            err_output = cpe.stdout.decode("utf8")

            LOG.debug(f"{a_step.log_message} FAILED for {setup_py_path}")
            a_test_result = test_result(
                setup_py_path,
                a_step.step_name.value,