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

pantsbuild / pants / 19377500035

14 Nov 2025 09:01PM UTC coverage: 80.078% (-0.2%) from 80.29%
19377500035

Pull #22890

github

web-flow
Merge 90397d509 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%)

214 existing lines in 14 files now uncovered.

77661 of 96982 relevant lines covered (80.08%)

3.36 hits per line

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

81.82
/src/python/pants/goal/stats_aggregator_integration_test.py
1
# Copyright 2021 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
import json
1✔
7
import re
1✔
8
from pathlib import Path
1✔
9

10
from pants.testutil.pants_integration_test import run_pants, setup_tmpdir
1✔
11

12

13
def test_counters_and_histograms() -> None:
1✔
14
    # To get the cache read histogram, we must ensure the cache is populated, so we run twice.
15
    with setup_tmpdir(
1✔
16
        {"src/py/app.py": "print(0)\n", "src/py/BUILD": "python_sources()"}
17
    ) as tmpdir:
18
        argv = [
1✔
19
            "--backend-packages=['pants.backend.python', 'pants.backend.python.lint.black']",
20
            "--stats-log",
21
            "lint",
22
            f"{tmpdir}::",
23
        ]
24
        run_pants(argv).assert_success()
1✔
UNCOV
25
        result = run_pants(argv)
×
UNCOV
26
    result.assert_success()
×
UNCOV
27
    assert "Counters:" in result.stderr
×
UNCOV
28
    assert re.search(r"local_cache_requests: \d", result.stderr)
×
UNCOV
29
    assert "remote_cache_requests: 0" in result.stderr
×
UNCOV
30
    assert "Observation histogram summaries" in result.stderr
×
UNCOV
31
    assert "Summary of `local_store_read_blob_size` observation histogram:" in result.stderr
×
UNCOV
32
    assert re.search(r"min: \d", result.stderr)
×
UNCOV
33
    assert re.search(r"p25: \d", result.stderr)
×
UNCOV
34
    assert re.search(r"p99: \d", result.stderr)
×
35

36

37
def test_memory_summary() -> None:
1✔
38
    result = run_pants(["--stats-memory-summary", "--version"])
1✔
39
    result.assert_success()
1✔
40
    assert "Memory summary" in result.stderr
1✔
41
    assert "builtins.UnionMembership" in result.stderr
1✔
42

43

44
def test_writing_to_output_file_plain_text() -> None:
1✔
45
    with setup_tmpdir({"src/py/app.py": "print(0)\n", "src/py/BUILD": "python_sources()"}):
1✔
46
        argv1 = [
1✔
47
            "--backend-packages=['pants.backend.python']",
48
            "--stats-log",
49
            "--stats-memory-summary",
50
            "--stats-output-file=stats.txt",
51
            "roots",
52
        ]
53
        run_pants(argv1).assert_success()
1✔
54
        argv2 = [
1✔
55
            "--backend-packages=['pants.backend.python']",
56
            "--stats-log",
57
            "--stats-memory-summary",
58
            "--stats-output-file=stats.txt",
59
            "list",
60
            "::",
61
        ]
62
        run_pants(argv2).assert_success()
1✔
63
        output_file_contents = Path("stats.txt").read_text()
1✔
64
        for item in ("Counters:", "Memory summary"):
1✔
65
            assert output_file_contents.count(item) == 2
1✔
66

67
        for item in ("roots", "list"):
1✔
68
            assert item in output_file_contents
1✔
69

70
        for cmd in (argv1, argv2):
1✔
71
            assert " ".join(cmd) in output_file_contents
1✔
72

73

74
def test_writing_to_output_file_json() -> None:
1✔
75
    with setup_tmpdir({"src/py/app.py": "print(0)\n", "src/py/BUILD": "python_sources()"}):
1✔
76
        argv1 = [
1✔
77
            "--backend-packages=['pants.backend.python']",
78
            "--stats-log",
79
            "--stats-memory-summary",
80
            "--stats-format=jsonlines",
81
            "--stats-output-file=stats.jsonl",
82
            "roots",
83
        ]
84
        run_pants(argv1).assert_success()
1✔
85
        argv2 = [
1✔
86
            "--backend-packages=['pants.backend.python']",
87
            "--stats-log",
88
            "--stats-memory-summary",
89
            "--stats-format=jsonlines",
90
            "--stats-output-file=stats.jsonl",
91
            "list",
92
            "::",
93
        ]
94
        run_pants(argv2).assert_success()
1✔
95
        stats = []
1✔
96
        with open("stats.jsonl") as fh:
1✔
97
            for line in fh.readlines():
1✔
98
                stats.append(json.loads(line))
1✔
99

100
        assert len(stats) == 2
1✔
101

102
        for obj in stats:
1✔
103
            for key in (
1✔
104
                "timestamp",
105
                "command",
106
                "counters",
107
                "memory_summary",
108
                "observation_histograms",
109
            ):
110
                assert obj.get(key) is not None
1✔
111

112
            for field in ("name", "count"):
1✔
113
                assert obj["counters"][0].get(field) is not None
1✔
114

115
            for field in ("bytes", "count", "name"):
1✔
116
                assert obj["memory_summary"][0].get(field) is not None
1✔
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