• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 26342152999

23 May 2026 07:59PM UTC coverage: 91.165% (-1.6%) from 92.792%
26342152999

push

github

web-flow
Run Linux ARM CI on Depot runners (#23363)

RunsOn is deprecating their v2 stack, and rather than migrate
to v3 we should use the resources kindly donated by Depot.

GitHub also now has Linux ARM runners, should we need them.

87305 of 95766 relevant lines covered (91.16%)

3.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.63
/src/python/pants/backend/build_files/fmt/yapf/integration_test.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
2✔
5

6
import pytest
2✔
7

8
from pants.backend.build_files.fmt.yapf.register import YapfRequest
2✔
9
from pants.backend.build_files.fmt.yapf.register import rules as yapf_build_rules
2✔
10
from pants.backend.python.lint.yapf.rules import rules as yapf_fmt_rules
2✔
11
from pants.backend.python.lint.yapf.subsystem import Yapf
2✔
12
from pants.backend.python.lint.yapf.subsystem import rules as yapf_subsystem_rules
2✔
13
from pants.backend.python.target_types import PythonSourcesGeneratorTarget
2✔
14
from pants.core.goals.fmt import FmtResult
2✔
15
from pants.core.util_rules import config_files
2✔
16
from pants.engine.fs import PathGlobs
2✔
17
from pants.engine.internals.native_engine import Snapshot
2✔
18
from pants.testutil.python_interpreter_selection import all_major_minor_python_versions
2✔
19
from pants.testutil.rule_runner import QueryRule, RuleRunner
2✔
20

21

22
@pytest.fixture
2✔
23
def rule_runner() -> RuleRunner:
2✔
24
    return RuleRunner(
2✔
25
        rules=[
26
            *yapf_build_rules(),
27
            *yapf_fmt_rules(),
28
            *yapf_subsystem_rules(),
29
            *config_files.rules(),
30
            QueryRule(FmtResult, (YapfRequest.Batch,)),
31
        ],
32
        target_types=[PythonSourcesGeneratorTarget],
33
    )
34

35

36
def run_yapf(rule_runner: RuleRunner, *, extra_args: list[str] | None = None) -> FmtResult:
2✔
37
    rule_runner.set_options(
2✔
38
        ["--backend-packages=pants.backend.build_files.fmt.yapf", *(extra_args or ())],
39
        env_inherit={"PATH", "PYENV_ROOT", "HOME"},
40
    )
41
    snapshot = rule_runner.request(Snapshot, [PathGlobs(["**/BUILD"])])
2✔
42
    fmt_result = rule_runner.request(
2✔
43
        FmtResult,
44
        [
45
            YapfRequest.Batch("", snapshot.files, partition_metadata=None, snapshot=snapshot),
46
        ],
47
    )
48
    return fmt_result
2✔
49

50

51
@pytest.mark.platform_specific_behavior
2✔
52
@pytest.mark.parametrize(
2✔
53
    "major_minor_interpreter",
54
    all_major_minor_python_versions(Yapf.default_interpreter_constraints),
55
)
56
def test_passing(rule_runner: RuleRunner, major_minor_interpreter: str) -> None:
2✔
57
    rule_runner.write_files({"BUILD": 'python_sources(name="t")\n'})
2✔
58
    interpreter_constraint = (
2✔
59
        ">=3.6.2,<3.7" if major_minor_interpreter == "3.6" else f"=={major_minor_interpreter}.*"
60
    )
61
    fmt_result = run_yapf(
2✔
62
        rule_runner,
63
        extra_args=[f"--yapf-interpreter-constraints=['{interpreter_constraint}']"],
64
    )
65
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": 'python_sources(name="t")\n'})
2✔
66
    assert fmt_result.did_change is False
2✔
67

68

69
def test_failing(rule_runner: RuleRunner) -> None:
2✔
70
    rule_runner.write_files({"BUILD": 'python_sources(name = "t")\n'})
×
71
    fmt_result = run_yapf(rule_runner)
×
72
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": 'python_sources(name="t")\n'})
×
73
    assert fmt_result.did_change is True
×
74

75

76
def test_multiple_files(rule_runner: RuleRunner) -> None:
2✔
77
    rule_runner.write_files(
×
78
        {
79
            "good/BUILD": 'python_sources(name="t")\n',
80
            "bad/BUILD": 'python_sources(name = "t")\n',
81
        }
82
    )
83
    fmt_result = run_yapf(rule_runner)
×
84
    assert fmt_result.output == rule_runner.make_snapshot(
×
85
        {"good/BUILD": 'python_sources(name="t")\n', "bad/BUILD": 'python_sources(name="t")\n'},
86
    )
87
    assert fmt_result.did_change is True
×
88

89

90
@pytest.mark.parametrize(
2✔
91
    "path,section,extra_args",
92
    (
93
        (".style.yapf", "style", []),
94
        ("custom.style", "style", ["--yapf-config=custom.style"]),
95
    ),
96
)
97
def test_config_file(
2✔
98
    rule_runner: RuleRunner, path: str, section: str, extra_args: list[str]
99
) -> None:
100
    rule_runner.write_files(
×
101
        {
102
            "BUILD": 'python_sources(name = "t")\n',
103
            path: f"[{section}]\nspaces_around_default_or_named_assign = True\n",
104
        }
105
    )
106
    fmt_result = run_yapf(rule_runner, extra_args=extra_args)
×
107
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": 'python_sources(name = "t")\n'})
×
108
    assert fmt_result.did_change is False
×
109

110

111
def test_passthrough_args(rule_runner: RuleRunner) -> None:
2✔
112
    rule_runner.write_files({"BUILD": 'python_sources(name = "t")\n'})
×
113
    fmt_result = run_yapf(
×
114
        rule_runner,
115
        extra_args=["--yapf-args=--style='{spaces_around_default_or_named_assign: True}'"],
116
    )
117
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": 'python_sources(name = "t")\n'})
×
118
    assert fmt_result.did_change is False
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc