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

pantsbuild / pants / 19381742489

15 Nov 2025 12:52AM UTC coverage: 49.706% (-30.6%) from 80.29%
19381742489

Pull #22890

github

web-flow
Merge d961abf79 into 42e1ebd41
Pull Request #22890: Updated all python subsystem constraints to 3.14

4 of 5 new or added lines in 5 files covered. (80.0%)

14659 existing lines in 485 files now uncovered.

31583 of 63540 relevant lines covered (49.71%)

0.79 hits per line

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

77.5
/src/python/pants/backend/build_files/fmt/buildifier/rules_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
1✔
5

6
from textwrap import dedent
1✔
7

8
import pytest
1✔
9

10
from pants.backend.build_files.fmt.buildifier.rules import BuildifierRequest
1✔
11
from pants.backend.build_files.fmt.buildifier.rules import rules as buildifier_rules
1✔
12
from pants.backend.codegen.protobuf.target_types import rules as target_types_rules
1✔
13
from pants.core.goals.fmt import FmtResult
1✔
14
from pants.core.util_rules import external_tool
1✔
15
from pants.engine.fs import PathGlobs
1✔
16
from pants.engine.internals.native_engine import Snapshot
1✔
17
from pants.testutil.rule_runner import QueryRule, RuleRunner
1✔
18

19

20
class Materials:
1✔
21
    def __init__(self, **kwargs):
1✔
22
        pass
×
23

24

25
@pytest.fixture
1✔
26
def rule_runner() -> RuleRunner:
1✔
27
    return RuleRunner(
1✔
28
        rules=[
29
            *buildifier_rules(),
30
            *external_tool.rules(),
31
            *target_types_rules(),
32
            QueryRule(FmtResult, [BuildifierRequest.Batch]),
33
        ],
34
        # NB: Objects are easier to test with
35
        objects={"materials": Materials},
36
    )
37

38

39
GOOD_FILE = dedent(
1✔
40
    """\
41
    materials(
42
        drywall = 40,
43
        status = "paid",
44
        studs = 200,
45
    )
46
    """
47
)
48

49
BAD_FILE = dedent(
1✔
50
    """\
51
    materials(status='paid', studs=200, drywall=40)
52
    """
53
)
54

55

56
def run_buildifier(rule_runner: RuleRunner) -> FmtResult:
1✔
57
    rule_runner.set_options(
1✔
58
        ["--backend-packages=pants.backend.build_files.fmt.buildifier"],
59
        env_inherit={"PATH", "PYENV_ROOT"},
60
    )
61
    snapshot = rule_runner.request(Snapshot, [PathGlobs(["**/BUILD"])])
1✔
62
    fmt_result = rule_runner.request(
1✔
63
        FmtResult,
64
        [
65
            BuildifierRequest.Batch("", snapshot.files, partition_metadata=None, snapshot=snapshot),
66
        ],
67
    )
68
    return fmt_result
1✔
69

70

71
def test_passing(rule_runner: RuleRunner) -> None:
1✔
UNCOV
72
    rule_runner.write_files({"BUILD": GOOD_FILE})
×
UNCOV
73
    fmt_result = run_buildifier(rule_runner)
×
UNCOV
74
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": GOOD_FILE})
×
UNCOV
75
    assert fmt_result.did_change is False
×
76

77

78
@pytest.mark.platform_specific_behavior
1✔
79
def test_failing(rule_runner: RuleRunner) -> None:
1✔
80
    rule_runner.write_files({"BUILD": BAD_FILE})
1✔
81
    fmt_result = run_buildifier(rule_runner)
1✔
82
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": GOOD_FILE})
1✔
83
    assert fmt_result.did_change is True
1✔
84

85

86
def test_multiple_files(rule_runner: RuleRunner) -> None:
1✔
UNCOV
87
    rule_runner.write_files({"good/BUILD": GOOD_FILE, "bad/BUILD": BAD_FILE})
×
UNCOV
88
    fmt_result = run_buildifier(rule_runner)
×
UNCOV
89
    assert fmt_result.output == rule_runner.make_snapshot(
×
90
        {"good/BUILD": GOOD_FILE, "bad/BUILD": GOOD_FILE}
91
    )
UNCOV
92
    assert fmt_result.did_change is True
×
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