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

pantsbuild / pants / 21552830208

31 Jan 2026 11:40PM UTC coverage: 80.277% (-0.05%) from 80.324%
21552830208

Pull #23062

github

web-flow
Merge 808a9786c into 2c4dcf9cf
Pull Request #23062: Remove support for Get

18 of 25 new or added lines in 4 files covered. (72.0%)

17119 existing lines in 541 files now uncovered.

78278 of 97510 relevant lines covered (80.28%)

3.36 hits per line

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

100.0
/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
3✔
4

5
import pytest
3✔
6

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

26

27
@pytest.fixture
3✔
28
def rule_runner() -> RuleRunner:
3✔
29
    rule_runner = RuleRunner(
3✔
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)
3✔
49
    return rule_runner
3✔
50

51

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

56
    rule_runner.write_files(
3✔
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))
3✔
73
    field_set = MakeselfArchiveFieldSet.create(target)
3✔
74

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

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

82
    result = rule_runner.request(
3✔
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""
3✔
95
    contents = rule_runner.request(DigestContents, [result.output_digest])
3✔
96
    assert contents == DigestContents([FileContent(path="_out/files/README.txt", content=b"TEST")])
3✔
97

98

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

UNCOV
102
    rule_runner.write_files(
1✔
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))
1✔
UNCOV
116
    field_set = MakeselfArchiveFieldSet.create(target)
1✔
117

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

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

UNCOV
125
    result = rule_runner.request(
1✔
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"
1✔
137

138

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

UNCOV
142
    rule_runner.write_files(
1✔
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)
1✔
163

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

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

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

UNCOV
174
    result = rule_runner.request(
1✔
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"
1✔
186

187

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

UNCOV
191
    rule_runner.write_files(
1✔
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)
1✔
212

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

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

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

UNCOV
223
    result = rule_runner.request(
1✔
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"
1✔
235

236

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

UNCOV
240
    rule_runner.write_files(
1✔
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)
1✔
UNCOV
274
    rule_runner.chmod("src/shell/hello.sh", 0o777)
1✔
UNCOV
275
    rule_runner.chmod("src/shell/world.sh", 0o777)
1✔
276

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

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

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

UNCOV
287
    result = rule_runner.request(
1✔
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"
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