forked from pex-tool/pex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The switch from sha1 to sha256 hashes in pex-tool#1661 did not cover this feature. Simplify and use the existing machinery to get at a PEX's distributions. Fixes pex-tool#1683
- Loading branch information
Showing
2 changed files
with
71 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import os.path | ||
import subprocess | ||
from textwrap import dedent | ||
|
||
from colors import crossed, red | ||
|
||
from pex.common import safe_open | ||
from pex.testing import run_pex_command | ||
from pex.typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import Any | ||
|
||
|
||
def test_requirements_pex(tmpdir): | ||
# type: (Any) -> None | ||
|
||
pex_root = os.path.join(str(tmpdir), "pex_root") | ||
requirements_pex = os.path.join(str(tmpdir), "requirements.pex") | ||
run_pex_command( | ||
args=[ | ||
"--pex-root", | ||
pex_root, | ||
"--runtime-pex-root", | ||
pex_root, | ||
"ansicolors==1.1.8", | ||
"-o", | ||
requirements_pex, | ||
] | ||
).assert_success() | ||
|
||
src_dir = os.path.join(str(tmpdir), "src") | ||
with safe_open(os.path.join(src_dir, "exe.py"), "w") as fp: | ||
fp.write( | ||
dedent( | ||
"""\ | ||
from colors import crossed, red | ||
print(red(crossed("Broken"))) | ||
""" | ||
) | ||
) | ||
|
||
app_pex = os.path.join(str(tmpdir), "app.pex") | ||
run_pex_command( | ||
args=[ | ||
"--pex-root", | ||
pex_root, | ||
"--runtime-pex-root", | ||
pex_root, | ||
"--requirements-pex", | ||
requirements_pex, | ||
"-D", | ||
src_dir, | ||
"-m", | ||
"exe", | ||
"-o", | ||
app_pex, | ||
] | ||
).assert_success() | ||
|
||
assert red(crossed("Broken")) == subprocess.check_output(args=[app_pex]).decode("utf-8").strip() |