• 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

70.97
/src/python/pants/backend/python/packaging/pyoxidizer/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
import platform
1✔
5
import subprocess
1✔
6
from pathlib import Path
1✔
7
from textwrap import dedent
1✔
8

9
import pytest
1✔
10

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

13
skip_on_linux_arm = pytest.mark.skipif(
1✔
14
    platform.system() == "Linux" and platform.machine() == "aarch64",
15
    reason="PyOxidizer is not supported on Linux ARM",
16
)
17

18

19
@skip_on_linux_arm
1✔
20
def test_end_to_end() -> None:
1✔
21
    """We test a couple edge cases:
22

23
    * Third-party dependencies can be used.
24
    * A `python_distribution` (implicitly) depending on another `python_distribution`.
25
    * `package` vs `run`
26
    """
27
    sources = {
1✔
28
        "hellotest/utils/greeter.py": "GREET = 'Hello world!'",
29
        "hellotest/utils/BUILD": dedent(
30
            """\
31
            python_sources(name="lib")
32

33
            python_distribution(
34
                name="dist",
35
                dependencies=[":lib"],
36
                provides=python_artifact(name="utils-dist", version="0.0.1"),
37
            )
38
            """
39
        ),
40
        "hellotest/main.py": dedent(
41
            """\
42
            import colors
43
            import sys
44
            from hellotest.utils.greeter import GREET
45

46
            print(GREET)
47
            sys.exit(42)
48
            """
49
        ),
50
        "hellotest/BUILD": dedent(
51
            """\
52
            python_requirement(name="req", requirements=["ansicolors==1.1.8"])
53

54
            python_sources(name="lib")
55

56
            python_distribution(
57
                name="dist",
58
                dependencies=[":lib"],
59
                provides=python_artifact(name="main-dist", version="0.0.1"),
60
            )
61

62
            pyoxidizer_binary(
63
                name="bin",
64
                entry_point="hellotest.main",
65
                dependencies=[":dist", "{tmpdir}/hellotest/utils:dist"],
66
            )
67
            """
68
        ),
69
    }
70
    with setup_tmpdir(sources) as tmpdir:
1✔
71
        package_args = [
1✔
72
            "--backend-packages=['pants.backend.python', 'pants.backend.experimental.python.packaging.pyoxidizer']",
73
            f"--source-root-patterns=['/{tmpdir}']",
74
            "package",
75
            f"{tmpdir}/hellotest:bin",
76
        ]
77
        package_result = run_pants(package_args)
1✔
78
        package_result.assert_success()
1✔
79

80
        # Check that the binary is executable.
UNCOV
81
        bin_path = next(Path("dist", f"{tmpdir}.hellotest", "bin").glob("*/debug/install/bin"))
×
UNCOV
82
        bin_result = subprocess.run([bin_path], stdout=subprocess.PIPE)
×
UNCOV
83
        assert bin_result.returncode == 42
×
UNCOV
84
        assert bin_result.stdout == b"Hello world!\n"
×
85

86
        # Check that the binary runs.
UNCOV
87
        run_args = [
×
88
            "--backend-packages=['pants.backend.python', 'pants.backend.experimental.python.packaging.pyoxidizer']",
89
            f"--source-root-patterns=['/{tmpdir}']",
90
            "run",
91
            f"{tmpdir}/hellotest:bin",
92
        ]
UNCOV
93
        run_result = run_pants(run_args)
×
UNCOV
94
        print(run_result)
×
UNCOV
95
        assert run_result.exit_code == 42
×
UNCOV
96
        assert run_result.stdout == "Hello world!\n"
×
97

98

99
@skip_on_linux_arm
1✔
100
def test_requires_wheels() -> None:
1✔
101
    sources = {
1✔
102
        "hellotest/BUILD": dedent(
103
            """\
104
            python_distribution(
105
                name="dist",
106
                wheel=False,
107
                provides=python_artifact(name="dist", version="0.0.1"),
108
            )
109

110
            pyoxidizer_binary(name="bin", dependencies=[":dist"])
111
            """
112
        ),
113
    }
114
    with setup_tmpdir(sources) as tmpdir:
1✔
115
        args = [
1✔
116
            "--backend-packages=['pants.backend.python', 'pants.backend.experimental.python.packaging.pyoxidizer']",
117
            f"--source-root-patterns=['/{tmpdir}']",
118
            "package",
119
            f"{tmpdir}/hellotest:bin",
120
        ]
121
        result = run_pants(args)
1✔
122
        result.assert_failure()
1✔
123
        assert "InvalidTargetException" in result.stderr
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

© 2025 Coveralls, Inc