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

pantsbuild / pants / 19250292619

11 Nov 2025 12:09AM UTC coverage: 77.865% (-2.4%) from 80.298%
19250292619

push

github

web-flow
flag non-runnable targets used with `code_quality_tool` (#22875)

2 of 5 new or added lines in 2 files covered. (40.0%)

1487 existing lines in 72 files now uncovered.

71448 of 91759 relevant lines covered (77.86%)

3.22 hits per line

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

45.56
/src/python/pants/backend/makeself/goals/package_run_integration_test.py
1
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3
from textwrap import dedent
2✔
4

5
import pytest
2✔
6

7
from pants.backend.makeself import subsystem
2✔
8
from pants.backend.makeself import system_binaries as makeself_system_binaries
2✔
9
from pants.backend.makeself.goals import package, run
2✔
10
from pants.backend.makeself.goals.package import (
2✔
11
    BuiltMakeselfArchiveArtifact,
12
    MakeselfArchiveFieldSet,
13
)
14
from pants.backend.makeself.subsystem import RunMakeselfArchive
2✔
15
from pants.backend.makeself.target_types import MakeselfArchiveTarget
2✔
16
from pants.backend.shell import register
2✔
17
from pants.core.goals.package import BuiltPackage
2✔
18
from pants.core.target_types import FilesGeneratorTarget, FileTarget
2✔
19
from pants.core.target_types import rules as core_target_types_rules
2✔
20
from pants.core.util_rules import system_binaries
2✔
21
from pants.engine.addresses import Address
2✔
22
from pants.engine.fs import DigestContents, FileContent
2✔
23
from pants.engine.process import ProcessResult
2✔
24
from pants.testutil.rule_runner import PYTHON_BOOTSTRAP_ENV, QueryRule, RuleRunner
2✔
25

26

27
@pytest.fixture
2✔
28
def rule_runner() -> RuleRunner:
2✔
29
    rule_runner = RuleRunner(
2✔
30
        target_types=[
31
            MakeselfArchiveTarget,
32
            FileTarget,
33
            FilesGeneratorTarget,
34
            *register.target_types(),
35
        ],
36
        rules=[
37
            *subsystem.rules(),
38
            *package.rules(),
39
            *run.rules(),
40
            *system_binaries.rules(),
41
            *register.rules(),
42
            *makeself_system_binaries.rules(),
43
            *core_target_types_rules(),
44
            QueryRule(BuiltPackage, [MakeselfArchiveFieldSet]),
45
            QueryRule(ProcessResult, [RunMakeselfArchive]),
46
        ],
47
    )
48
    rule_runner.set_options(args=[], env_inherit=PYTHON_BOOTSTRAP_ENV)
2✔
49
    return rule_runner
2✔
50

51

52
@pytest.mark.platform_specific_behavior
2✔
53
def test_simple_archive(rule_runner: RuleRunner) -> None:
2✔
54
    binary_name = "archive"
2✔
55

56
    rule_runner.write_files(
2✔
57
        {
58
            "files/BUILD": dedent(
59
                f"""
60
                files(sources=["*.txt"])
61
                makeself_archive(
62
                    name="{binary_name}",
63
                    args=["--notemp"],
64
                    files=["files/README.txt"],
65
                )
66
                """
67
            ),
68
            "files/README.txt": "TEST",
69
        }
70
    )
71

72
    target = rule_runner.get_target(Address("files", target_name=binary_name))
2✔
73
    field_set = MakeselfArchiveFieldSet.create(target)
2✔
74

75
    package = rule_runner.request(BuiltPackage, [field_set])
2✔
76

77
    assert len(package.artifacts) == 1, field_set
2✔
78
    assert isinstance(package.artifacts[0], BuiltMakeselfArchiveArtifact)
2✔
79
    relpath = f"files/{binary_name}.run"
2✔
80
    assert package.artifacts[0].relpath == relpath
2✔
81

82
    result = rule_runner.request(
2✔
83
        ProcessResult,
84
        [
85
            RunMakeselfArchive(
86
                exe=relpath,
87
                extra_args=("--quiet",),
88
                description="Run built subsystem archive",
89
                input_digest=package.digest,
90
                output_directory="_out",
91
            )
92
        ],
93
    )
94
    assert result.stdout == b""
2✔
95
    contents = rule_runner.request(DigestContents, [result.output_digest])
2✔
96
    assert contents == DigestContents([FileContent(path="_out/files/README.txt", content=b"TEST")])
2✔
97

98

99
def test_inline_script(rule_runner: RuleRunner) -> None:
2✔
UNCOV
100
    binary_name = "archive"
×
101

UNCOV
102
    rule_runner.write_files(
×
103
        {
104
            "src/shell/BUILD": dedent(
105
                f"""
106
                makeself_archive(
107
                    name="{binary_name}",
108
                    startup_script=["echo", "test"],
109
                )
110
                """
111
            ),
112
        }
113
    )
114

UNCOV
115
    target = rule_runner.get_target(Address("src/shell", target_name=binary_name))
×
UNCOV
116
    field_set = MakeselfArchiveFieldSet.create(target)
×
117

UNCOV
118
    package = rule_runner.request(BuiltPackage, [field_set])
×
119

UNCOV
120
    assert len(package.artifacts) == 1, field_set
×
UNCOV
121
    assert isinstance(package.artifacts[0], BuiltMakeselfArchiveArtifact)
×
UNCOV
122
    relpath = f"src.shell/{binary_name}.run"
×
UNCOV
123
    assert package.artifacts[0].relpath == relpath
×
124

UNCOV
125
    result = rule_runner.request(
×
126
        ProcessResult,
127
        [
128
            RunMakeselfArchive(
129
                exe=relpath,
130
                extra_args=("--quiet",),
131
                description="Run built subsystem archive",
132
                input_digest=package.digest,
133
            )
134
        ],
135
    )
UNCOV
136
    assert result.stdout == b"test\n"
×
137

138

139
def test_same_directory(rule_runner: RuleRunner) -> None:
2✔
UNCOV
140
    binary_name = "archive"
×
141

UNCOV
142
    rule_runner.write_files(
×
143
        {
144
            "src/shell/BUILD": dedent(
145
                f"""
146
                shell_sources(name="src")
147
                makeself_archive(
148
                    name="{binary_name}",
149
                    startup_script=["src/shell/run.sh"],
150
                    files=[":src"],
151
                )
152
                """
153
            ),
154
            "src/shell/run.sh": dedent(
155
                """
156
                #!/bin/bash
157
                echo test
158
                """
159
            ),
160
        }
161
    )
UNCOV
162
    rule_runner.chmod("src/shell/run.sh", 0o777)
×
163

UNCOV
164
    target = rule_runner.get_target(Address("src/shell", target_name=binary_name))
×
UNCOV
165
    field_set = MakeselfArchiveFieldSet.create(target)
×
166

UNCOV
167
    package = rule_runner.request(BuiltPackage, [field_set])
×
168

UNCOV
169
    assert len(package.artifacts) == 1, field_set
×
UNCOV
170
    assert isinstance(package.artifacts[0], BuiltMakeselfArchiveArtifact)
×
UNCOV
171
    relpath = f"src.shell/{binary_name}.run"
×
UNCOV
172
    assert package.artifacts[0].relpath == relpath
×
173

UNCOV
174
    result = rule_runner.request(
×
175
        ProcessResult,
176
        [
177
            RunMakeselfArchive(
178
                exe=relpath,
179
                extra_args=("--quiet",),
180
                description="Run built subsystem archive",
181
                input_digest=package.digest,
182
            )
183
        ],
184
    )
UNCOV
185
    assert result.stdout == b"test\n"
×
186

187

188
def test_different_directory(rule_runner: RuleRunner) -> None:
2✔
UNCOV
189
    binary_name = "archive"
×
190

UNCOV
191
    rule_runner.write_files(
×
192
        {
193
            "src/shell/BUILD": "shell_sources()",
194
            "src/shell/run.sh": dedent(
195
                """
196
                #!/bin/bash
197
                echo test
198
                """
199
            ),
200
            "project/BUILD": dedent(
201
                f"""
202
                makeself_archive(
203
                    name="{binary_name}",
204
                    startup_script=["src/shell/run.sh"],
205
                    files=["src/shell/run.sh"],
206
                )
207
                """
208
            ),
209
        }
210
    )
UNCOV
211
    rule_runner.chmod("src/shell/run.sh", 0o777)
×
212

UNCOV
213
    target = rule_runner.get_target(Address("project", target_name=binary_name))
×
UNCOV
214
    field_set = MakeselfArchiveFieldSet.create(target)
×
215

UNCOV
216
    package = rule_runner.request(BuiltPackage, [field_set])
×
217

UNCOV
218
    assert len(package.artifacts) == 1, field_set
×
UNCOV
219
    assert isinstance(package.artifacts[0], BuiltMakeselfArchiveArtifact)
×
UNCOV
220
    relpath = f"project/{binary_name}.run"
×
UNCOV
221
    assert package.artifacts[0].relpath == relpath
×
222

UNCOV
223
    result = rule_runner.request(
×
224
        ProcessResult,
225
        [
226
            RunMakeselfArchive(
227
                exe=relpath,
228
                extra_args=("--quiet",),
229
                description="Run built subsystem archive",
230
                input_digest=package.digest,
231
            )
232
        ],
233
    )
UNCOV
234
    assert result.stdout == b"test\n"
×
235

236

237
def test_multiple_scripts(rule_runner: RuleRunner) -> None:
2✔
UNCOV
238
    binary_name = "archive"
×
239

UNCOV
240
    rule_runner.write_files(
×
241
        {
242
            "src/shell/BUILD": dedent(
243
                f"""
244
                shell_sources(name="src")
245
                makeself_archive(
246
                    name="{binary_name}",
247
                    startup_script=["src/shell/run.sh"],
248
                    files=[":src"],
249
                )
250
                """
251
            ),
252
            "src/shell/hello.sh": dedent(
253
                """
254
                #!/bin/bash
255
                printf hello
256
                """
257
            ),
258
            "src/shell/world.sh": dedent(
259
                """
260
                #!/bin/bash
261
                printf world
262
                """
263
            ),
264
            "src/shell/run.sh": dedent(
265
                """
266
                #!/bin/bash
267
                src/shell/hello.sh
268
                src/shell/world.sh
269
                """
270
            ),
271
        }
272
    )
UNCOV
273
    rule_runner.chmod("src/shell/run.sh", 0o777)
×
UNCOV
274
    rule_runner.chmod("src/shell/hello.sh", 0o777)
×
UNCOV
275
    rule_runner.chmod("src/shell/world.sh", 0o777)
×
276

UNCOV
277
    target = rule_runner.get_target(Address("src/shell", target_name=binary_name))
×
UNCOV
278
    field_set = MakeselfArchiveFieldSet.create(target)
×
279

UNCOV
280
    package = rule_runner.request(BuiltPackage, [field_set])
×
281

UNCOV
282
    assert len(package.artifacts) == 1, field_set
×
UNCOV
283
    assert isinstance(package.artifacts[0], BuiltMakeselfArchiveArtifact)
×
UNCOV
284
    relpath = f"src.shell/{binary_name}.run"
×
UNCOV
285
    assert package.artifacts[0].relpath == relpath
×
286

UNCOV
287
    result = rule_runner.request(
×
288
        ProcessResult,
289
        [
290
            RunMakeselfArchive(
291
                exe=relpath,
292
                extra_args=("--quiet",),
293
                description="Run built subsystem archive",
294
                input_digest=package.digest,
295
            )
296
        ],
297
    )
UNCOV
298
    assert result.stdout == b"helloworld"
×
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