Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add collection methods to RunfilesSubject #72

Open
rickeylev opened this issue Oct 3, 2023 · 0 comments
Open

Add collection methods to RunfilesSubject #72

rickeylev opened this issue Oct 3, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@rickeylev
Copy link
Collaborator

While asserting some runfiles, I needed to do something like:

target.runfiles().contains_at_least([
  <ends with "/foo">,
  <ends with "/foo.exe">
])

Unfortunately, there isn't a great way to do this.

At the least, I think these convenience methods need to be added:

  • .paths() -> CollectionSubject[str]: returns all the runfiles paths that are represented.
  • .path_map() -> DictSubject[str, File|None]: returns a mapping of path to File (or None, in the case of .empty_filenames). Unfortunately, this is, potentially, a lossy operation -- a symlink could have the same path as a regular file entry. So we would want to match Bazel's behavior for how it handles such cases as best we can.

And these two lower-level accessors need to be added:

  • .files() -> DepsetFileSubject: returns the Runfiles.file value as a subject
  • .empty_filenames() -> CollectionSubject[str]: Returns Runfiles.empty_filenames as a subject
  • .symlinks() -> DepsetSubject[SymlinkEntry]: Returns Runfiles.symlinks as a subject
  • .root_symlinks() -> DepsetSubject[SymlinKEntry]: Returns Runfiles.root_symlinks as a subject

I'm not sure how to best directly expose other methods because a runfiles object is a heterogenous collection -- Files, symlink entries, and str (empty file names). I think matching on the str paths is about the best we can do -- its the common denominator. For a more specific check, the other accessors can be used (e.g. to check that something is a symlink).

@rickeylev rickeylev added the enhancement New feature or request label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant