How to use the ptr.StepName 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
step(
            StepName.mypy_run,
            bool("run_mypy" in config and config["run_mypy"]),
            _generate_mypy_cmd(setup_py_path.parent, mypy_exe, config),
            f"Running mypy for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.black_run,
            bool("run_black" in config and config["run_black"]),
            _generate_black_cmd(setup_py_path.parent, black_exe),
            f"Running black for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.flake8_run,
            bool("run_flake8" in config and config["run_flake8"]),
            _generate_flake8_cmd(setup_py_path.parent, flake8_exe, config),
            f"Running flake8 for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.pylint_run,
            bool("run_pylint" in config and config["run_pylint"]),
            _generate_pylint_cmd(setup_py_path.parent, pylint_exe, config),
            f"Running pylint for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.pyre_run,
            bool("run_pyre" in config and config["run_pyre"] and not WINDOWS),
            _generate_pyre_cmd(setup_py_path.parent, pyre_exe, config),
github facebookincubator / ptr / ptr.py View on Github external
step(
            StepName.flake8_run,
            bool("run_flake8" in config and config["run_flake8"]),
            _generate_flake8_cmd(setup_py_path.parent, flake8_exe, config),
            f"Running flake8 for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.pylint_run,
            bool("run_pylint" in config and config["run_pylint"]),
            _generate_pylint_cmd(setup_py_path.parent, pylint_exe, config),
            f"Running pylint for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.pyre_run,
            bool("run_pyre" in config and config["run_pyre"] and not WINDOWS),
            _generate_pyre_cmd(setup_py_path.parent, pyre_exe, config),
            f"Running pyre for {setup_py_path}",
            config["test_suite_timeout"],
        ),
    )

    steps_ran = 0
    for a_step in steps:
        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)
github facebookincubator / ptr / ptr.py View on Github external
)

        if cover < cov_req:
            failed_coverage = True
            failed_output += "  {}: {} < {} - Missing: {}\n".format(
                afile,
                coverage_lines[afile].cover,
                cov_req,
                coverage_lines[afile].missing,
            )

    if failed_coverage:
        failed_cov_runtime = int(time() - test_run_start_time)
        return test_result(
            setup_py_path,
            StepName.analyze_coverage.value,
            failed_output,
            failed_cov_runtime,
            False,
        )

    return None
github facebookincubator / ptr / ptr.py View on Github external
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"],
        ),
        step(
            StepName.mypy_run,
            bool("run_mypy" in config and config["run_mypy"]),
            _generate_mypy_cmd(setup_py_path.parent, mypy_exe, config),
            f"Running mypy for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.black_run,
            bool("run_black" in config and config["run_black"]),
            _generate_black_cmd(setup_py_path.parent, black_exe),
            f"Running black for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.flake8_run,
            bool("run_flake8" in config and config["run_flake8"]),
            _generate_flake8_cmd(setup_py_path.parent, flake8_exe, config),
github facebookincubator / ptr / ptr.py View on Github external
test_results: Sequence[test_result], stats: Optional[Dict[str, int]] = None
) -> Dict[str, int]:
    if not stats:
        stats = defaultdict(int)

    stats["total.test_suites"] = len(test_results)

    fail_output = ""
    for result in sorted(test_results):
        if result.returncode:
            if result.timeout:
                stats["total.timeouts"] += 1
            else:
                stats["total.fails"] += 1
            fail_output += "{} (failed '{}' step):\n{}\n".format(
                result.setup_py_path, StepName(result.returncode).name, result.output
            )
        else:
            stats["total.passes"] += 1

    total_time = -1 if "runtime.all_tests" not in stats else stats["runtime.all_tests"]
    print(f"-- Summary (total time {total_time}s):\n")
    # TODO: Hardcode some workaround to ensure Windows always prints UTF8
    # https://github.com/facebookincubator/ptr/issues/34
    print(
        "✅ PASS: {}\n❌ FAIL: {}\n️⌛ TIMEOUT: {}\n🔒 DISABLED: {}\n💩 TOTAL: {}\n".format(
            stats["total.passes"],
            stats["total.fails"],
            stats["total.timeouts"],
            stats["total.disabled"],
            stats["total.test_suites"],
        )
github facebookincubator / ptr / ptr.py View on Github external
step(
            StepName.black_run,
            bool("run_black" in config and config["run_black"]),
            _generate_black_cmd(setup_py_path.parent, black_exe),
            f"Running black for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.flake8_run,
            bool("run_flake8" in config and config["run_flake8"]),
            _generate_flake8_cmd(setup_py_path.parent, flake8_exe, config),
            f"Running flake8 for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.pylint_run,
            bool("run_pylint" in config and config["run_pylint"]),
            _generate_pylint_cmd(setup_py_path.parent, pylint_exe, config),
            f"Running pylint for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.pyre_run,
            bool("run_pyre" in config and config["run_pyre"] and not WINDOWS),
            _generate_pyre_cmd(setup_py_path.parent, pyre_exe, config),
            f"Running pyre for {setup_py_path}",
            config["test_suite_timeout"],
        ),
    )

    steps_ran = 0
    for a_step in steps:
github facebookincubator / ptr / ptr.py View on Github external
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"],
        ),
        step(
            StepName.mypy_run,
            bool("run_mypy" in config and config["run_mypy"]),
            _generate_mypy_cmd(setup_py_path.parent, mypy_exe, config),
            f"Running mypy for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.black_run,
            bool("run_black" in config and config["run_black"]),
            _generate_black_cmd(setup_py_path.parent, black_exe),
            f"Running black for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.flake8_run,
            bool("run_flake8" in config and config["run_flake8"]),
            _generate_flake8_cmd(setup_py_path.parent, flake8_exe, config),
            f"Running flake8 for {setup_py_path}",
            config["test_suite_timeout"],
        ),
        step(
            StepName.pylint_run,
            bool("run_pylint" in config and config["run_pylint"]),
            _generate_pylint_cmd(setup_py_path.parent, pylint_exe, config),
github facebookincubator / ptr / ptr.py View on Github external
print_cov: bool = False,
) -> Tuple[Optional[test_result], int]:
    bin_dir = "Scripts" if WINDOWS else "bin"
    exe = ".exe" if WINDOWS else ""
    black_exe = venv_path / bin_dir / f"black{exe}"
    coverage_exe = venv_path / bin_dir / f"coverage{exe}"
    flake8_exe = venv_path / bin_dir / f"flake8{exe}"
    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