Support tests for BinaryPaths.#10770
Merged
jsirois merged 2 commits intopantsbuild:masterfrom Sep 13, 2020
Merged
Conversation
A BinaryPathRequest can now include a test to run against each found binary to validate it works and optionally fingerprint it. Eventually fingerprinting the binary contents should be performed automatically and the optional test fingerprint mixed in with it when present as tracked by pantsbuild#10769. We leverage testing found binaries in PexEnvironment to ensure we find only interpreter paths compatible with Pex bootstrapping. This plugs an existing hole not yet encountered in the wild where a Python 2.6 binary (for example) could be chosen and then PEX file bootstrapping fail as a result. We additionally fingerprint interpreters passing the version range test to ensure we detect interpreter upgrades and pyenv shim switches. Even with the automatic hashing of binaries tracked in pantsbuild#10769 working, we'd still need to do this in the pyenv shim case since the same shim script can redirect to different interpreters depending on configuration external to the shim script. # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
This was referenced Sep 13, 2020
Eric-Arellano
approved these changes
Sep 13, 2020
Contributor
Eric-Arellano
left a comment
There was a problem hiding this comment.
Fantastic! Thanks John.
|
|
||
| found_paths = result.stdout.decode().splitlines() | ||
| if not request.test_args: | ||
| return dataclasses.replace(binary_paths, paths=[BinaryPath(path) for path in found_paths]) |
Contributor
There was a problem hiding this comment.
dataclasses.replace is neat, but also more cognitive load. How about instead having line 453 use return BinaryPaths(binary_name=request.binary_name), and likewise creating a new BinaryPaths with these returns?
Yes, more duplication. But simpler.
Contributor
Author
There was a problem hiding this comment.
I started with the more duplication code (and more nested code, which I'm fine with but you tend to push back on) and landed here so this appears to be eye of the beholder. Since dataclasses are ubiquitous in rules, using standard dataclasses APIs does not strike me as neat, its just pedestrian.
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Eric-Arellano
approved these changes
Sep 13, 2020
Contributor
Eric-Arellano
left a comment
There was a problem hiding this comment.
Looks great! Thanks.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A BinaryPathRequest can now include a test to run against each found
binary to validate it works and optionally fingerprint it. Eventually
fingerprinting the binary contents should be performed automatically
and the optional test fingerprint mixed in with it when present as
tracked by #10769.
We leverage testing found binaries in PexEnvironment to ensure we find
only interpreter paths compatible with Pex bootstrapping. This plugs an
existing hole not yet encountered in the wild where a Python 2.6 binary
(for example) could be chosen and then PEX file bootstrapping fail as a
result. We additionally fingerprint interpreters passing the version
range test to ensure we detect interpreter upgrades and pyenv shim
switches. Even with the automatic hashing of binaries tracked in #10769
working, we'd still need to do this in the pyenv shim case since the
same shim script can redirect to different interpreters depending on
configuration external to the shim script.
[ci skip-rust]
[ci skip-build-wheels]